1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64 -global-isel -verify-machineinstrs -run-pass=legalizer %s -o - | FileCheck %s
3 # RUN: llc -mtriple=aarch64 -global-isel -verify-machineinstrs -mattr=+cssc -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=CHECK-CSSC
8 tracksRegLiveness: true
12 ; CHECK-LABEL: name: s8
15 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
16 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 256
17 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[DEF]], [[C]]
18 ; CHECK-NEXT: [[BITREVERSE:%[0-9]+]]:_(s32) = G_BITREVERSE [[OR]]
19 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[BITREVERSE]](s32)
20 ; CHECK-NEXT: $w0 = COPY [[CTLZ]](s32)
21 ; CHECK-NEXT: RET_ReallyLR implicit $w0
22 ; CHECK-CSSC-LABEL: name: s8
23 ; CHECK-CSSC: liveins: $w0
24 ; CHECK-CSSC-NEXT: {{ $}}
25 ; CHECK-CSSC-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
26 ; CHECK-CSSC-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 256
27 ; CHECK-CSSC-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[DEF]], [[C]]
28 ; CHECK-CSSC-NEXT: [[CTTZ:%[0-9]+]]:_(s32) = G_CTTZ [[OR]](s32)
29 ; CHECK-CSSC-NEXT: $w0 = COPY [[CTTZ]](s32)
30 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $w0
31 %val:_(s8) = G_IMPLICIT_DEF
32 %cttz:_(s8) = G_CTTZ %val(s8)
33 %ext:_(s32) = G_ANYEXT %cttz(s8)
35 RET_ReallyLR implicit $w0
40 tracksRegLiveness: true
44 ; CHECK-LABEL: name: s16
47 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
48 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
49 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[DEF]], [[C]]
50 ; CHECK-NEXT: [[BITREVERSE:%[0-9]+]]:_(s32) = G_BITREVERSE [[OR]]
51 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[BITREVERSE]](s32)
52 ; CHECK-NEXT: $w0 = COPY [[CTLZ]](s32)
53 ; CHECK-NEXT: RET_ReallyLR implicit $w0
54 ; CHECK-CSSC-LABEL: name: s16
55 ; CHECK-CSSC: liveins: $w0
56 ; CHECK-CSSC-NEXT: {{ $}}
57 ; CHECK-CSSC-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
58 ; CHECK-CSSC-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
59 ; CHECK-CSSC-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[DEF]], [[C]]
60 ; CHECK-CSSC-NEXT: [[CTTZ:%[0-9]+]]:_(s32) = G_CTTZ [[OR]](s32)
61 ; CHECK-CSSC-NEXT: $w0 = COPY [[CTTZ]](s32)
62 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $w0
63 %val:_(s16) = G_IMPLICIT_DEF
64 %cttz:_(s16) = G_CTTZ %val(s16)
65 %ext:_(s32) = G_ANYEXT %cttz(s16)
67 RET_ReallyLR implicit $w0
73 tracksRegLiveness: true
78 ; CHECK-LABEL: name: s32
81 ; CHECK-NEXT: %val:_(s32) = COPY $w0
82 ; CHECK-NEXT: [[BITREVERSE:%[0-9]+]]:_(s32) = G_BITREVERSE %val
83 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[BITREVERSE]](s32)
84 ; CHECK-NEXT: $w0 = COPY [[CTLZ]](s32)
85 ; CHECK-NEXT: RET_ReallyLR implicit $w0
86 ; CHECK-CSSC-LABEL: name: s32
87 ; CHECK-CSSC: liveins: $w0
88 ; CHECK-CSSC-NEXT: {{ $}}
89 ; CHECK-CSSC-NEXT: %val:_(s32) = COPY $w0
90 ; CHECK-CSSC-NEXT: [[CTTZ:%[0-9]+]]:_(s32) = G_CTTZ %val(s32)
91 ; CHECK-CSSC-NEXT: $w0 = COPY [[CTTZ]](s32)
92 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $w0
93 %val:_(s32) = COPY $w0
94 %1:_(s32) = G_CTTZ %val(s32)
96 RET_ReallyLR implicit $w0
102 tracksRegLiveness: true
107 ; CHECK-LABEL: name: s64
108 ; CHECK: liveins: $x0
110 ; CHECK-NEXT: %val:_(s64) = COPY $x0
111 ; CHECK-NEXT: [[BITREVERSE:%[0-9]+]]:_(s64) = G_BITREVERSE %val
112 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[BITREVERSE]](s64)
113 ; CHECK-NEXT: $x0 = COPY [[CTLZ]](s64)
114 ; CHECK-NEXT: RET_ReallyLR implicit $x0
115 ; CHECK-CSSC-LABEL: name: s64
116 ; CHECK-CSSC: liveins: $x0
117 ; CHECK-CSSC-NEXT: {{ $}}
118 ; CHECK-CSSC-NEXT: %val:_(s64) = COPY $x0
119 ; CHECK-CSSC-NEXT: [[CTTZ:%[0-9]+]]:_(s64) = G_CTTZ %val(s64)
120 ; CHECK-CSSC-NEXT: $x0 = COPY [[CTTZ]](s64)
121 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $x0
122 %val:_(s64) = COPY $x0
123 %1:_(s64) = G_CTTZ %val(s64)
125 RET_ReallyLR implicit $x0
130 tracksRegLiveness: true
135 ; CHECK-LABEL: name: v4s32
136 ; CHECK: liveins: $q0
138 ; CHECK-NEXT: %val:_(<4 x s32>) = COPY $q0
139 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
140 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32), [[C]](s32), [[C]](s32)
141 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(<4 x s32>) = G_XOR %val, [[BUILD_VECTOR]]
142 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(<4 x s32>) = G_ADD %val, [[BUILD_VECTOR]]
143 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(<4 x s32>) = G_AND [[XOR]], [[ADD]]
144 ; CHECK-NEXT: [[CTPOP:%[0-9]+]]:_(<4 x s32>) = G_CTPOP [[AND]](<4 x s32>)
145 ; CHECK-NEXT: $q0 = COPY [[CTPOP]](<4 x s32>)
146 ; CHECK-NEXT: RET_ReallyLR implicit $q0
147 ; CHECK-CSSC-LABEL: name: v4s32
148 ; CHECK-CSSC: liveins: $q0
149 ; CHECK-CSSC-NEXT: {{ $}}
150 ; CHECK-CSSC-NEXT: %val:_(<4 x s32>) = COPY $q0
151 ; CHECK-CSSC-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
152 ; CHECK-CSSC-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32), [[C]](s32), [[C]](s32)
153 ; CHECK-CSSC-NEXT: [[XOR:%[0-9]+]]:_(<4 x s32>) = G_XOR %val, [[BUILD_VECTOR]]
154 ; CHECK-CSSC-NEXT: [[ADD:%[0-9]+]]:_(<4 x s32>) = G_ADD %val, [[BUILD_VECTOR]]
155 ; CHECK-CSSC-NEXT: [[AND:%[0-9]+]]:_(<4 x s32>) = G_AND [[XOR]], [[ADD]]
156 ; CHECK-CSSC-NEXT: [[CTPOP:%[0-9]+]]:_(<4 x s32>) = G_CTPOP [[AND]](<4 x s32>)
157 ; CHECK-CSSC-NEXT: $q0 = COPY [[CTPOP]](<4 x s32>)
158 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $q0
159 %val:_(<4 x s32>) = COPY $q0
160 %1:_(<4 x s32>) = G_CTTZ %val(<4 x s32>)
161 $q0 = COPY %1(<4 x s32>)
162 RET_ReallyLR implicit $q0
168 tracksRegLiveness: true
173 ; CHECK-LABEL: name: s35
174 ; CHECK: liveins: $x0
176 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
177 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 34359738368
178 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[COPY]], [[C]]
179 ; CHECK-NEXT: [[BITREVERSE:%[0-9]+]]:_(s64) = G_BITREVERSE [[OR]]
180 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[BITREVERSE]](s64)
181 ; CHECK-NEXT: $x0 = COPY [[CTLZ]](s64)
182 ; CHECK-NEXT: RET_ReallyLR implicit $x0
183 ; CHECK-CSSC-LABEL: name: s35
184 ; CHECK-CSSC: liveins: $x0
185 ; CHECK-CSSC-NEXT: {{ $}}
186 ; CHECK-CSSC-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
187 ; CHECK-CSSC-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 34359738368
188 ; CHECK-CSSC-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[COPY]], [[C]]
189 ; CHECK-CSSC-NEXT: [[CTTZ:%[0-9]+]]:_(s64) = G_CTTZ [[OR]](s64)
190 ; CHECK-CSSC-NEXT: $x0 = COPY [[CTTZ]](s64)
191 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $x0
193 %0:_(s35) = G_TRUNC %1(s64)
194 %2:_(s35) = G_CTTZ %0(s35)
195 %3:_(s64) = G_ANYEXT %2(s35)
197 RET_ReallyLR implicit $x0
202 tracksRegLiveness: true
207 ; CHECK-LABEL: name: s65
208 ; CHECK: liveins: $x0, $x1
210 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
211 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
212 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
213 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
214 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[COPY]], [[C]]
215 ; CHECK-NEXT: [[OR1:%[0-9]+]]:_(s64) = G_OR [[COPY1]], [[C1]]
216 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[OR]](s64), [[C]]
217 ; CHECK-NEXT: [[BITREVERSE:%[0-9]+]]:_(s64) = G_BITREVERSE [[OR1]]
218 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[BITREVERSE]](s64)
219 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
220 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[CTLZ]], [[C2]]
221 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
222 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C3]]
223 ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE [[C]], [[C]], [[AND]]
224 ; CHECK-NEXT: [[BITREVERSE1:%[0-9]+]]:_(s64) = G_BITREVERSE [[OR]]
225 ; CHECK-NEXT: [[CTLZ1:%[0-9]+]]:_(s64) = G_CTLZ [[BITREVERSE1]](s64)
226 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C3]]
227 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s32), [[UADDO]], [[CTLZ1]]
228 ; CHECK-NEXT: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s32), [[UADDE]], [[C]]
229 ; CHECK-NEXT: $x0 = COPY [[SELECT]](s64)
230 ; CHECK-NEXT: $x1 = COPY [[SELECT1]](s64)
231 ; CHECK-NEXT: RET_ReallyLR implicit $x0, implicit $x1
232 ; CHECK-CSSC-LABEL: name: s65
233 ; CHECK-CSSC: liveins: $x0, $x1
234 ; CHECK-CSSC-NEXT: {{ $}}
235 ; CHECK-CSSC-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
236 ; CHECK-CSSC-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
237 ; CHECK-CSSC-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
238 ; CHECK-CSSC-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
239 ; CHECK-CSSC-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[COPY]], [[C]]
240 ; CHECK-CSSC-NEXT: [[OR1:%[0-9]+]]:_(s64) = G_OR [[COPY1]], [[C1]]
241 ; CHECK-CSSC-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[OR]](s64), [[C]]
242 ; CHECK-CSSC-NEXT: [[CTTZ:%[0-9]+]]:_(s64) = G_CTTZ [[OR1]](s64)
243 ; CHECK-CSSC-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
244 ; CHECK-CSSC-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[CTTZ]], [[C2]]
245 ; CHECK-CSSC-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
246 ; CHECK-CSSC-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C3]]
247 ; CHECK-CSSC-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE [[C]], [[C]], [[AND]]
248 ; CHECK-CSSC-NEXT: [[CTTZ1:%[0-9]+]]:_(s64) = G_CTTZ [[OR]](s64)
249 ; CHECK-CSSC-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C3]]
250 ; CHECK-CSSC-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s32), [[UADDO]], [[CTTZ1]]
251 ; CHECK-CSSC-NEXT: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s32), [[UADDE]], [[C]]
252 ; CHECK-CSSC-NEXT: $x0 = COPY [[SELECT]](s64)
253 ; CHECK-CSSC-NEXT: $x1 = COPY [[SELECT1]](s64)
254 ; CHECK-CSSC-NEXT: RET_ReallyLR implicit $x0, implicit $x1
257 %3:_(s128) = G_MERGE_VALUES %1(s64), %2(s64)
258 %0:_(s65) = G_TRUNC %3(s128)
259 %4:_(s65) = G_CTTZ %0(s65)
260 %7:_(s128) = G_ANYEXT %4(s65)
261 %5:_(s64), %6:_(s64) = G_UNMERGE_VALUES %7(s128)
264 RET_ReallyLR implicit $x0, implicit $x1