Skip to content

Commit 992698c

Browse files
committed
[AArch64] Emit zext move when the source of the zext is AssertZext or AssertSext
When the source of the zext is AssertZext or AssertSext, it is hard to know any information about the upper 32 bits, so we should insert a zext move before emitting SUBREG_TO_REG to define the lower 32 bits. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D87771
1 parent 6e475e1 commit 992698c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,14 @@ namespace {
418418
// Any instruction that defines a 32-bit result zeros out the high half of the
419419
// register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may
420420
// be copying from a truncate. But any other 32-bit operation will zero-extend
421-
// up to 64 bits.
421+
// up to 64 bits. AssertSext/AssertZext aren't saying anything about the upper
422+
// 32 bits, they're probably just qualifying a CopyFromReg.
422423
// FIXME: X86 also checks for CMOV here. Do we need something similar?
423424
static inline bool isDef32(const SDNode &N) {
424425
unsigned Opc = N.getOpcode();
425426
return Opc != ISD::TRUNCATE && Opc != TargetOpcode::EXTRACT_SUBREG &&
426-
Opc != ISD::CopyFromReg;
427+
Opc != ISD::CopyFromReg && Opc != ISD::AssertSext &&
428+
Opc != ISD::AssertZext;
427429
}
428430

429431
} // end anonymous namespace

llvm/test/CodeGen/AArch64/shift_minsize.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ define dso_local { i64, i64 } @shl128(i64 %x.coerce0, i64 %x.coerce1, i8 signext
5959
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
6060
; CHECK-NEXT: .cfi_def_cfa_offset 16
6161
; CHECK-NEXT: .cfi_offset w30, -16
62-
; CHECK-NEXT: // kill: def $w2 killed $w2 def $x2
62+
; CHECK-NEXT: mov w2, w2
6363
; CHECK-NEXT: bl __ashlti3
6464
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
6565
; CHECK-NEXT: ret
@@ -86,7 +86,7 @@ define dso_local { i64, i64 } @ashr128(i64 %x.coerce0, i64 %x.coerce1, i8 signex
8686
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
8787
; CHECK-NEXT: .cfi_def_cfa_offset 16
8888
; CHECK-NEXT: .cfi_offset w30, -16
89-
; CHECK-NEXT: // kill: def $w2 killed $w2 def $x2
89+
; CHECK-NEXT: mov w2, w2
9090
; CHECK-NEXT: bl __ashrti3
9191
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
9292
; CHECK-NEXT: ret
@@ -112,7 +112,7 @@ define dso_local { i64, i64 } @lshr128(i64 %x.coerce0, i64 %x.coerce1, i8 signex
112112
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
113113
; CHECK-NEXT: .cfi_def_cfa_offset 16
114114
; CHECK-NEXT: .cfi_offset w30, -16
115-
; CHECK-NEXT: // kill: def $w2 killed $w2 def $x2
115+
; CHECK-NEXT: mov w2, w2
116116
; CHECK-NEXT: bl __lshrti3
117117
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
118118
; CHECK-NEXT: ret

0 commit comments

Comments
 (0)