mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
fef8e383eb
If we know that a particular 64-bit constant has all high bits zero, then we can rely on the fact that 32-bit ARM64 instructions automatically zero out the high bits of an x-register. This gives the expansion logic less constraints to satisfy and so sometimes allows it to pick better sequences. Came up while porting test/CodeGen/AArch64/movw-consts.ll: this will allow a 32-bit MOVN to be used in @test8 soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206379 91177308-0d34-0410-b5e6-96231b3b80d8
60 lines
2.1 KiB
LLVM
60 lines
2.1 KiB
LLVM
; RUN: llc < %s -march=arm64 -mcpu=cyclone | FileCheck %s
|
|
|
|
define i128 @shl(i128 %r, i128 %s) nounwind readnone {
|
|
; CHECK-LABEL: shl:
|
|
; CHECK: lslv [[XREG_0:x[0-9]+]], x1, x2
|
|
; CHECK-NEXT: orr w[[XREG_1:[0-9]+]], wzr, #0x40
|
|
; CHECK-NEXT: sub [[XREG_2:x[0-9]+]], x[[XREG_1]], x2
|
|
; CHECK-NEXT: lsrv [[XREG_3:x[0-9]+]], x0, [[XREG_2]]
|
|
; CHECK-NEXT: orr [[XREG_6:x[0-9]+]], [[XREG_3]], [[XREG_0]]
|
|
; CHECK-NEXT: sub [[XREG_4:x[0-9]+]], x2, #64
|
|
; CHECK-NEXT: lslv [[XREG_5:x[0-9]+]], x0, [[XREG_4]]
|
|
; CHECK-NEXT: cmp [[XREG_4]], #0
|
|
; CHECK-NEXT: csel x1, [[XREG_5]], [[XREG_6]], ge
|
|
; CHECK-NEXT: lslv [[SMALLSHIFT_LO:x[0-9]+]], x0, x2
|
|
; CHECK-NEXT: csel x0, xzr, [[SMALLSHIFT_LO]], ge
|
|
; CHECK-NEXT: ret
|
|
|
|
%shl = shl i128 %r, %s
|
|
ret i128 %shl
|
|
}
|
|
|
|
define i128 @ashr(i128 %r, i128 %s) nounwind readnone {
|
|
; CHECK-LABEL: ashr:
|
|
; CHECK: lsrv [[XREG_0:x[0-9]+]], x0, x2
|
|
; CHECK-NEXT: orr w[[XREG_1:[0-9]+]], wzr, #0x40
|
|
; CHECK-NEXT: sub [[XREG_2:x[0-9]+]], x[[XREG_1]], x2
|
|
; CHECK-NEXT: lslv [[XREG_3:x[0-9]+]], x1, [[XREG_2]]
|
|
; CHECK-NEXT: orr [[XREG_4:x[0-9]+]], [[XREG_0]], [[XREG_3]]
|
|
; CHECK-NEXT: sub [[XREG_5:x[0-9]+]], x2, #64
|
|
; CHECK-NEXT: asrv [[XREG_6:x[0-9]+]], x1, [[XREG_5]]
|
|
; CHECK-NEXT: cmp [[XREG_5]], #0
|
|
; CHECK-NEXT: csel x0, [[XREG_6]], [[XREG_4]], ge
|
|
; CHECK-NEXT: asrv [[SMALLSHIFT_HI:x[0-9]+]], x1, x2
|
|
; CHECK-NEXT: asr [[BIGSHIFT_HI:x[0-9]+]], x1, #63
|
|
; CHECK-NEXT: csel x1, [[BIGSHIFT_HI]], [[SMALLSHIFT_HI]], ge
|
|
; CHECK-NEXT: ret
|
|
|
|
%shr = ashr i128 %r, %s
|
|
ret i128 %shr
|
|
}
|
|
|
|
define i128 @lshr(i128 %r, i128 %s) nounwind readnone {
|
|
; CHECK-LABEL: lshr:
|
|
; CHECK: lsrv [[XREG_0:x[0-9]+]], x0, x2
|
|
; CHECK-NEXT: orr w[[XREG_1:[0-9]+]], wzr, #0x40
|
|
; CHECK-NEXT: sub [[XREG_2:x[0-9]+]], x[[XREG_1]], x2
|
|
; CHECK-NEXT: lslv [[XREG_3:x[0-9]+]], x1, [[XREG_2]]
|
|
; CHECK-NEXT: orr [[XREG_4:x[0-9]+]], [[XREG_0]], [[XREG_3]]
|
|
; CHECK-NEXT: sub [[XREG_5:x[0-9]+]], x2, #64
|
|
; CHECK-NEXT: lsrv [[XREG_6:x[0-9]+]], x1, [[XREG_5]]
|
|
; CHECK-NEXT: cmp [[XREG_5]], #0
|
|
; CHECK-NEXT: csel x0, [[XREG_6]], [[XREG_4]], ge
|
|
; CHECK-NEXT: lsrv [[SMALLSHIFT_HI:x[0-9]+]], x1, x2
|
|
; CHECK-NEXT: csel x1, xzr, [[SMALLSHIFT_HI]], ge
|
|
; CHECK-NEXT: ret
|
|
|
|
%shr = lshr i128 %r, %s
|
|
ret i128 %shr
|
|
}
|