1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-unknown-unknown -run-pass=instruction-select -global-isel-abort=1 -verify-machineinstrs %s -o - | FileCheck %s
4 # Test widening and narrowing on test bit operations using subregister copies
7 @glob = external dso_local unnamed_addr global i1, align 4
8 define void @p0_no_copy() { ret void }
9 define void @widen_s32_to_s64() { ret void }
10 define void @widen_s16_to_s64() { ret void }
11 define void @narrow_s64_to_s32() { ret void }
19 tracksRegLiveness: true
21 ; CHECK-LABEL: name: p0_no_copy
23 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
25 ; CHECK-NEXT: %glob:gpr64common = MOVaddr target-flags(aarch64-page) @glob, target-flags(aarch64-pageoff, aarch64-nc) @glob
26 ; CHECK-NEXT: %load:gpr32 = LDRBBui %glob, 0 :: (dereferenceable load (s8) from @glob, align 4)
27 ; CHECK-NEXT: TBNZW %load, 0, %bb.1
31 ; CHECK-NEXT: RET_ReallyLR
33 successors: %bb.0, %bb.1
34 %glob:gpr(p0) = G_GLOBAL_VALUE @glob
35 %load:gpr(s32) = G_LOAD %glob(p0) :: (dereferenceable load (s8) from @glob, align 4)
37 ; Look through G_TRUNC to get the load. The load is into a s8, which will
38 ; be selected to a GPR32, so we don't need a copy.
45 name: widen_s32_to_s64
49 tracksRegLiveness: true
51 ; CHECK-LABEL: name: widen_s32_to_s64
53 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
54 ; CHECK-NEXT: liveins: $w0
56 ; CHECK-NEXT: %reg:gpr32all = COPY $w0
57 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64all = SUBREG_TO_REG 0, %reg, %subreg.sub_32
58 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY [[SUBREG_TO_REG]]
59 ; CHECK-NEXT: TBZX [[COPY]], 33, %bb.1
63 ; CHECK-NEXT: RET_ReallyLR
65 successors: %bb.0, %bb.1
67 %reg:gpr(s32) = COPY $w0
68 %zext:gpr(s64) = G_ZEXT %reg(s32)
69 %bit:gpr(s64) = G_CONSTANT i64 8589934592
70 %zero:gpr(s64) = G_CONSTANT i64 0
71 %and:gpr(s64) = G_AND %zext, %bit
72 %cmp:gpr(s32) = G_ICMP intpred(eq), %and(s64), %zero
74 ; We should widen using a SUBREG_TO_REG here, because we need a TBZX to get
75 ; bit 33. The subregister should be sub_32.
82 name: widen_s16_to_s64
86 tracksRegLiveness: true
88 ; CHECK-LABEL: name: widen_s16_to_s64
90 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
92 ; CHECK-NEXT: %reg:gpr32 = IMPLICIT_DEF
93 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64all = SUBREG_TO_REG 0, %reg, %subreg.sub_32
94 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY [[SUBREG_TO_REG]]
95 ; CHECK-NEXT: TBZX [[COPY]], 33, %bb.1
99 ; CHECK-NEXT: RET_ReallyLR
101 successors: %bb.0, %bb.1
102 %reg:gpr(s16) = G_IMPLICIT_DEF
103 %zext:gpr(s64) = G_ZEXT %reg(s16)
104 %bit:gpr(s64) = G_CONSTANT i64 8589934592
105 %zero:gpr(s64) = G_CONSTANT i64 0
106 %and:gpr(s64) = G_AND %zext, %bit
107 %cmp:gpr(s32) = G_ICMP intpred(eq), %and(s64), %zero
109 ; We should widen using a SUBREG_TO_REG here, because we need a TBZX to get
110 ; bit 33. The subregister should be sub_32, because s16 will end up on a
118 name: narrow_s64_to_s32
121 regBankSelected: true
122 tracksRegLiveness: true
124 ; CHECK-LABEL: name: narrow_s64_to_s32
126 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
127 ; CHECK-NEXT: liveins: $x0
129 ; CHECK-NEXT: %wide:gpr64all = COPY $x0
130 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32all = COPY %wide.sub_32
131 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
132 ; CHECK-NEXT: TBNZW [[COPY1]], 0, %bb.1
133 ; CHECK-NEXT: B %bb.0
136 ; CHECK-NEXT: RET_ReallyLR
138 successors: %bb.0, %bb.1
140 %wide:gpr(s64) = COPY $x0
142 ; We should narrow using a subregister copy here.
143 %trunc:gpr(s32) = G_TRUNC %wide(s64)
144 G_BRCOND %trunc, %bb.1