1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=aarch64-unknown-unknown -verify-machineinstrs -global-isel-abort=0 -run-pass=legalizer %s -o - | FileCheck %s
6 exposesReturnsTwice: false
10 tracksRegLiveness: true
12 - { id: 0, class: _, preferred-register: '' }
13 - { id: 1, class: _, preferred-register: '' }
14 - { id: 2, class: _, preferred-register: '' }
15 - { id: 3, class: _, preferred-register: '' }
16 - { id: 4, class: _, preferred-register: '' }
17 - { id: 5, class: _, preferred-register: '' }
18 - { id: 6, class: _, preferred-register: '' }
19 - { id: 7, class: _, preferred-register: '' }
20 - { id: 8, class: _, preferred-register: '' }
21 - { id: 9, class: _, preferred-register: '' }
22 - { id: 10, class: _, preferred-register: '' }
25 ; CHECK-LABEL: name: legalize_phi
27 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
29 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
30 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
31 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
32 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
33 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
34 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
35 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
38 ; CHECK: successors: %bb.3(0x80000000)
39 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
40 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
43 ; CHECK: successors: %bb.3(0x80000000)
44 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
45 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
47 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
48 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
49 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
50 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
51 ; CHECK: $w0 = COPY [[AND]](s32)
52 ; CHECK: RET_ReallyLR implicit $w0
54 ; Test that we insert legalization artifacts(Truncs here) into the correct BBs
55 ; while legalizing the G_PHI to s16.
58 successors: %bb.1(0x40000000), %bb.2(0x40000000)
62 %1(s32) = G_CONSTANT i32 0
63 %3(s32) = G_CONSTANT i32 1
64 %6(s32) = G_CONSTANT i32 2
65 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
66 G_BRCOND %2(s1), %bb.1
70 successors: %bb.3(0x80000000)
72 %4(s32) = G_ADD %0, %3
73 %5(s1) = G_TRUNC %4(s32)
77 successors: %bb.3(0x80000000)
79 %7(s32) = G_ADD %0, %6
80 %8(s1) = G_TRUNC %7(s32)
83 %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
84 %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
85 %10(s32) = G_ZEXT %9(s1)
87 RET_ReallyLR implicit $w0
91 name: legalize_phi_ptr
93 exposesReturnsTwice: false
95 regBankSelected: false
97 tracksRegLiveness: true
99 - { id: 0, class: _, preferred-register: '' }
100 - { id: 1, class: _, preferred-register: '' }
101 - { id: 2, class: _, preferred-register: '' }
102 - { id: 3, class: _, preferred-register: '' }
103 - { id: 4, class: _, preferred-register: '' }
104 - { id: 5, class: _, preferred-register: '' }
107 ; CHECK-LABEL: name: legalize_phi_ptr
109 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
110 ; CHECK: liveins: $w2, $x0, $x1
111 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
112 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
113 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
114 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32)
115 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
118 ; CHECK: successors: %bb.2(0x80000000)
120 ; CHECK: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
121 ; CHECK: $x0 = COPY [[PHI]](p0)
122 ; CHECK: RET_ReallyLR implicit $x0
125 successors: %bb.2, %bb.3
126 liveins: $w2, $x0, $x1
131 %2(s1) = G_TRUNC %4(s32)
132 G_BRCOND %2(s1), %bb.2
139 %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
141 RET_ReallyLR implicit $x0
145 name: legalize_phi_empty
147 exposesReturnsTwice: false
149 regBankSelected: false
151 tracksRegLiveness: true
153 - { id: 0, class: _, preferred-register: '' }
154 - { id: 1, class: _, preferred-register: '' }
155 - { id: 2, class: _, preferred-register: '' }
156 - { id: 3, class: _, preferred-register: '' }
157 - { id: 4, class: _, preferred-register: '' }
158 - { id: 5, class: _, preferred-register: '' }
159 - { id: 6, class: _, preferred-register: '' }
160 - { id: 7, class: _, preferred-register: '' }
161 - { id: 8, class: _, preferred-register: '' }
162 - { id: 9, class: _, preferred-register: '' }
163 - { id: 10, class: _, preferred-register: '' }
166 ; CHECK-LABEL: name: legalize_phi_empty
168 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
169 ; CHECK: liveins: $w0
170 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
171 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
172 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
173 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
174 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
175 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
176 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
177 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
180 ; CHECK: successors: %bb.3(0x80000000)
181 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
182 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
185 ; CHECK: successors: %bb.3(0x80000000)
186 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
188 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
189 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
190 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
191 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
192 ; CHECK: $w0 = COPY [[AND]](s32)
193 ; CHECK: RET_ReallyLR implicit $w0
195 successors: %bb.1(0x40000000), %bb.2(0x40000000)
197 ; Test that we properly legalize a phi with a predecessor that's empty
203 %1(s32) = G_CONSTANT i32 0
204 %3(s32) = G_CONSTANT i32 3
205 %6(s32) = G_CONSTANT i32 1
206 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
207 %4(s32) = G_ADD %0, %3
208 %5(s1) = G_TRUNC %4(s32)
209 G_BRCOND %2(s1), %bb.1
213 successors: %bb.3(0x80000000)
215 %7(s32) = G_ADD %0, %6
216 %8(s1) = G_TRUNC %7(s32)
220 successors: %bb.3(0x80000000)
224 %9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
225 %10(s32) = G_ZEXT %9(s1)
227 RET_ReallyLR implicit $w0
231 name: legalize_phi_loop
233 exposesReturnsTwice: false
235 regBankSelected: false
237 tracksRegLiveness: true
239 - { id: 0, class: _, preferred-register: '' }
240 - { id: 1, class: _, preferred-register: '' }
241 - { id: 2, class: _, preferred-register: '' }
242 - { id: 3, class: _, preferred-register: '' }
243 - { id: 4, class: _, preferred-register: '' }
244 - { id: 5, class: _, preferred-register: '' }
245 - { id: 6, class: _, preferred-register: '' }
246 - { id: 7, class: _, preferred-register: '' }
249 ; CHECK-LABEL: name: legalize_phi_loop
251 ; CHECK: successors: %bb.1(0x80000000)
252 ; CHECK: liveins: $w0
253 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
254 ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
256 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
257 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %13(s16), %bb.1
258 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
259 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
260 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[C1]]
261 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
262 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
263 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
264 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
265 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
266 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
267 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
269 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
270 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
271 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C3]]
272 ; CHECK: $w0 = COPY [[AND1]](s32)
273 ; CHECK: RET_ReallyLR implicit $w0
275 successors: %bb.1(0x80000000)
277 ; Test that we properly legalize a phi that uses a value from the same BB
280 %2(s8) = G_CONSTANT i8 1
281 %7(s8) = G_CONSTANT i8 0
284 successors: %bb.1(0x40000000), %bb.3(0x40000000)
286 %1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
287 %3(s8) = G_ADD %1, %2
288 %4(s32) = G_ZEXT %3(s8)
289 %5(s1) = G_ICMP intpred(ugt), %4(s32), %0
290 G_BRCOND %5(s1), %bb.1
293 %6(s32) = G_ZEXT %3(s8)
295 RET_ReallyLR implicit $w0
299 name: legalize_phi_cycle
301 exposesReturnsTwice: false
303 regBankSelected: false
305 tracksRegLiveness: true
307 - { id: 0, class: _, preferred-register: '' }
308 - { id: 1, class: _, preferred-register: '' }
309 - { id: 2, class: _, preferred-register: '' }
310 - { id: 3, class: _, preferred-register: '' }
311 - { id: 4, class: _, preferred-register: '' }
314 ; CHECK-LABEL: name: legalize_phi_cycle
316 ; CHECK: successors: %bb.1(0x80000000)
317 ; CHECK: liveins: $w0
318 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
319 ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
321 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
322 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %7(s16), %bb.1
323 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
324 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
325 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
326 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
327 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
328 ; CHECK: [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
329 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
331 ; CHECK: $w0 = COPY [[AND]](s32)
332 ; CHECK: RET_ReallyLR implicit $w0
334 successors: %bb.1(0x80000000)
336 ; Test that we properly legalize a phi that uses itself
340 %4(s8) = G_CONSTANT i8 0
343 successors: %bb.1(0x40000000), %bb.3(0x40000000)
345 %1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
346 %2(s32) = G_ZEXT %1(s8)
347 %3(s1) = G_ICMP intpred(ugt), %2(s32), %0
348 G_BRCOND %3(s1), %bb.1
352 RET_ReallyLR implicit $w0
356 name: legalize_phi_same_bb
358 exposesReturnsTwice: false
360 regBankSelected: false
362 tracksRegLiveness: true
364 - { id: 0, class: _, preferred-register: '' }
365 - { id: 1, class: _, preferred-register: '' }
366 - { id: 2, class: _, preferred-register: '' }
367 - { id: 3, class: _, preferred-register: '' }
368 - { id: 4, class: _, preferred-register: '' }
369 - { id: 5, class: _, preferred-register: '' }
370 - { id: 6, class: _, preferred-register: '' }
371 - { id: 7, class: _, preferred-register: '' }
372 - { id: 8, class: _, preferred-register: '' }
373 - { id: 9, class: _, preferred-register: '' }
374 - { id: 10, class: _, preferred-register: '' }
375 - { id: 11, class: _, preferred-register: '' }
376 - { id: 12, class: _, preferred-register: '' }
377 - { id: 13, class: _, preferred-register: '' }
378 - { id: 14, class: _, preferred-register: '' }
381 ; CHECK-LABEL: name: legalize_phi_same_bb
383 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
384 ; CHECK: liveins: $w0
385 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
386 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
387 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
388 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
389 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
390 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
391 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
392 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
395 ; CHECK: successors: %bb.3(0x80000000)
396 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
397 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
398 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
401 ; CHECK: successors: %bb.3(0x80000000)
402 ; CHECK: [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 42
403 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
405 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC3]](s16), %bb.2
406 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[C3]](s16), %bb.2
407 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
408 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
409 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
410 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
411 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C4]]
412 ; CHECK: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
413 ; CHECK: $w0 = COPY [[ADD2]](s32)
414 ; CHECK: RET_ReallyLR implicit $w0
416 successors: %bb.1(0x40000000), %bb.2(0x40000000)
418 ; Make sure that we correctly insert the new legalized G_PHI at the
419 ; correct location (ie make sure G_PHIs are the first insts in the BB).
425 %1(s32) = G_CONSTANT i32 0
426 %3(s32) = G_CONSTANT i32 3
427 %6(s32) = G_CONSTANT i32 1
428 %14(s8) = G_CONSTANT i8 42
429 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
430 %4(s32) = G_ADD %0, %3
431 %5(s8) = G_TRUNC %4(s32)
432 G_BRCOND %2(s1), %bb.1
436 successors: %bb.3(0x80000000)
438 %7(s32) = G_ADD %0, %6
439 %8(s8) = G_TRUNC %7(s32)
443 successors: %bb.3(0x80000000)
447 %9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
448 %10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
449 %11(s32) = G_ZEXT %9(s8)
450 %12(s32) = G_ZEXT %10(s8)
451 %13(s32) = G_ADD %11, %12
453 RET_ReallyLR implicit $w0
457 name: legalize_phi_diff_bb
459 exposesReturnsTwice: false
461 regBankSelected: false
463 tracksRegLiveness: true
465 - { id: 0, class: _, preferred-register: '' }
466 - { id: 1, class: _, preferred-register: '' }
467 - { id: 2, class: _, preferred-register: '' }
468 - { id: 3, class: _, preferred-register: '' }
469 - { id: 4, class: _, preferred-register: '' }
470 - { id: 5, class: _, preferred-register: '' }
471 - { id: 6, class: _, preferred-register: '' }
472 - { id: 7, class: _, preferred-register: '' }
473 - { id: 8, class: _, preferred-register: '' }
474 - { id: 9, class: _, preferred-register: '' }
475 - { id: 10, class: _, preferred-register: '' }
476 - { id: 11, class: _, preferred-register: '' }
477 - { id: 12, class: _, preferred-register: '' }
478 - { id: 13, class: _, preferred-register: '' }
479 - { id: 14, class: _, preferred-register: '' }
480 - { id: 15, class: _, preferred-register: '' }
483 ; CHECK-LABEL: name: legalize_phi_diff_bb
485 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
486 ; CHECK: liveins: $w0, $w1
487 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
488 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
489 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
490 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
491 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
492 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
493 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
494 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
495 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
496 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
497 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
498 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
501 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
502 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.0, %21(s16), %bb.1
503 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
504 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
505 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
506 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
507 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
508 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
509 ; CHECK: [[COPY2:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
510 ; CHECK: [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 43
511 ; CHECK: G_BRCOND [[TRUNC3]](s1), %bb.2
514 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY2]](s16), %bb.1, [[TRUNC1]](s16), %bb.0
515 ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
516 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
517 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
518 ; CHECK: $w0 = COPY [[AND1]](s32)
519 ; CHECK: RET_ReallyLR implicit $w0
521 successors: %bb.1(0x40000000), %bb.3(0x40000000)
523 ; Make sure that we correctly legalize PHIs sharing common defs
530 %2(s32) = G_CONSTANT i32 0
531 %4(s32) = G_CONSTANT i32 3
532 %9(s32) = G_CONSTANT i32 1
533 %11(s32) = G_CONSTANT i32 44
534 %15(s8) = G_CONSTANT i8 43
535 %3(s1) = G_ICMP intpred(ugt), %0(s32), %2
536 %5(s32) = G_ADD %0, %4
537 %6(s8) = G_TRUNC %5(s32)
538 G_BRCOND %3(s1), %bb.1
542 successors: %bb.3(0x40000000), %bb.1(0x40000000)
544 %7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
545 %8(s32) = G_ZEXT %7(s8)
546 %10(s32) = G_ADD %8, %9
547 %12(s1) = G_ICMP intpred(ugt), %10(s32), %11
548 G_BRCOND %12(s1), %bb.3
552 %13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
553 %14(s32) = G_ZEXT %13(s8)
555 RET_ReallyLR implicit $w0
559 name: legalize_phi_check_insertpt
561 exposesReturnsTwice: false
563 regBankSelected: false
565 tracksRegLiveness: true
567 ; CHECK-LABEL: name: legalize_phi_check_insertpt
569 ; CHECK: successors: %bb.1(0x80000000)
570 ; CHECK: liveins: $x0, $x1
571 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
572 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
573 ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
576 ; CHECK: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
577 ; CHECK: [[PHI1:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
578 ; CHECK: [[PHI2:%[0-9]+]]:_(s64) = G_PHI [[COPY]](s64), %bb.0
579 ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[PHI]](s64), [[PHI1]](s64)
580 ; CHECK: G_STORE [[MV]](s128), [[COPY1]](p0) :: (store (s128))
581 ; CHECK: G_STORE [[PHI2]](s64), [[COPY1]](p0) :: (store (s64))
582 ; CHECK: RET_ReallyLR
583 ; Check that the G_MERGE here gets inserted after all the PHIs.
585 successors: %bb.1(0x40000000)
590 %2:_(s128) = G_IMPLICIT_DEF
594 %3:_(s128) = G_PHI %2(s128), %bb.0
595 %4:_(s64) = G_PHI %0(s64), %bb.0
596 G_STORE %3(s128), %1(p0) :: (store (s128))
597 G_STORE %4(s64), %1(p0) :: (store (s64))
602 name: legalize_phi_vector
603 tracksRegLiveness: true
605 ; CHECK-LABEL: name: legalize_phi_vector
607 ; CHECK: successors: %bb.1(0x80000000)
608 ; CHECK: liveins: $q0, $x1
609 ; CHECK: [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0
612 ; CHECK: [[PHI:%[0-9]+]]:_(<16 x s8>) = G_PHI [[COPY]](<16 x s8>), %bb.0
613 ; CHECK: $q0 = COPY [[PHI]](<16 x s8>)
614 ; CHECK: RET_ReallyLR
619 %0:_(<16 x s8>) = COPY $q0
623 %3:_(<16 x s8>) = G_PHI %0(<16 x s8>), %bb.0
624 $q0 = COPY %3(<16 x s8>)
629 tracksRegLiveness: true
632 ; CHECK-LABEL: name: s88
634 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
635 ; CHECK: liveins: $x0
636 ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF
637 ; CHECK: G_BRCOND %cond(s1), %bb.1
640 ; CHECK: successors: %bb.3(0x80000000)
641 ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
644 ; CHECK: successors: %bb.3(0x80000000)
645 ; CHECK: [[DEF1:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
647 ; CHECK: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.1, [[DEF1]](s64), %bb.2
648 ; CHECK: $x0 = COPY [[PHI]](s64)
649 ; CHECK: RET_ReallyLR implicit $x0
651 successors: %bb.1(0x40000000), %bb.2(0x40000000)
653 %cond:_(s1) = G_IMPLICIT_DEF
654 G_BRCOND %cond(s1), %bb.1
657 successors: %bb.3(0x80000000)
658 %imp_1:_(s88) = G_IMPLICIT_DEF
661 successors: %bb.3(0x80000000)
662 %imp_2:_(s88) = G_IMPLICIT_DEF
664 %phi:_(s88) = G_PHI %imp_1:_(s88), %bb.1, %imp_2:_(s88), %bb.2
665 %trunc:_(s64) = G_TRUNC %phi
667 RET_ReallyLR implicit $x0
672 tracksRegLiveness: true
674 ; CHECK-LABEL: name: v4s64
676 ; CHECK: successors: %bb.1(0x50000000), %bb.2(0x30000000)
677 ; CHECK: liveins: $x0, $x1
678 ; CHECK: %ptr1:_(p0) = COPY $x1
679 ; CHECK: %ptr2:_(p0) = COPY $x0
680 ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF
681 ; CHECK: [[LOAD:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr1(p0) :: (load (<2 x s64>), align 32)
682 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
683 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr1, [[C]](s64)
684 ; CHECK: [[LOAD1:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD]](p0) :: (load (<2 x s64>) from unknown-address + 16)
685 ; CHECK: G_BRCOND %cond(s1), %bb.2
688 ; CHECK: successors: %bb.2(0x80000000)
689 ; CHECK: [[LOAD2:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr2(p0) :: (load (<2 x s64>), align 32)
690 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
691 ; CHECK: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr2, [[C1]](s64)
692 ; CHECK: [[LOAD3:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD1]](p0) :: (load (<2 x s64>) from unknown-address + 16)
694 ; CHECK: [[PHI:%[0-9]+]]:_(<2 x s64>) = G_PHI [[LOAD2]](<2 x s64>), %bb.1, [[LOAD]](<2 x s64>), %bb.0
695 ; CHECK: [[PHI1:%[0-9]+]]:_(<2 x s64>) = G_PHI [[LOAD3]](<2 x s64>), %bb.1, [[LOAD1]](<2 x s64>), %bb.0
696 ; CHECK: $q0 = COPY [[PHI]](<2 x s64>)
697 ; CHECK: $q1 = COPY [[PHI1]](<2 x s64>)
698 ; CHECK: RET_ReallyLR implicit $q0, implicit $q1
700 successors: %bb.1(0x50000000), %bb.2(0x30000000)
703 %ptr1:_(p0) = COPY $x1
704 %ptr2:_(p0) = COPY $x0
705 %cond:_(s1) = G_IMPLICIT_DEF
706 %val_1:_(<4 x s64>) = G_LOAD %ptr1(p0) :: (load (<4 x s64>))
707 G_BRCOND %cond(s1), %bb.2
710 %val_2:_(<4 x s64>) = G_LOAD %ptr2(p0) :: (load (<4 x s64>))
712 %phi:_(<4 x s64>) = G_PHI %val_2(<4 x s64>), %bb.1, %val_1(<4 x s64>), %bb.0
713 %unmerge_1:_(<2 x s64>), %unmerge_2:_(<2 x s64>) = G_UNMERGE_VALUES %phi(<4 x s64>)
714 $q0 = COPY %unmerge_1(<2 x s64>)
715 $q1 = COPY %unmerge_2(<2 x s64>)
716 RET_ReallyLR implicit $q0, implicit $q1
721 tracksRegLiveness: true
723 ; CHECK-LABEL: name: v8s32
725 ; CHECK: successors: %bb.1(0x50000000), %bb.2(0x30000000)
726 ; CHECK: liveins: $x0, $x1
727 ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF
728 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
729 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF]](s32), [[DEF]](s32), [[DEF]](s32), [[DEF]](s32)
730 ; CHECK: [[BUILD_VECTOR1:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF]](s32), [[DEF]](s32), [[DEF]](s32), [[DEF]](s32)
731 ; CHECK: G_BRCOND %cond(s1), %bb.2
734 ; CHECK: successors: %bb.2(0x80000000)
735 ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
736 ; CHECK: [[BUILD_VECTOR2:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32)
737 ; CHECK: [[BUILD_VECTOR3:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32)
739 ; CHECK: [[PHI:%[0-9]+]]:_(<4 x s32>) = G_PHI [[BUILD_VECTOR2]](<4 x s32>), %bb.1, [[BUILD_VECTOR]](<4 x s32>), %bb.0
740 ; CHECK: [[PHI1:%[0-9]+]]:_(<4 x s32>) = G_PHI [[BUILD_VECTOR3]](<4 x s32>), %bb.1, [[BUILD_VECTOR1]](<4 x s32>), %bb.0
741 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
742 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
743 ; CHECK: %extract:_(s32) = G_EXTRACT_VECTOR_ELT [[PHI]](<4 x s32>), [[C]](s64)
744 ; CHECK: $w0 = COPY %extract(s32)
745 ; CHECK: RET_ReallyLR implicit $w0
747 successors: %bb.1(0x50000000), %bb.2(0x30000000)
749 %cond:_(s1) = G_IMPLICIT_DEF
750 %val_1:_(<8 x s32>) = G_IMPLICIT_DEF
751 G_BRCOND %cond(s1), %bb.2
754 %val_2:_(<8 x s32>) = G_IMPLICIT_DEF
756 %phi:_(<8 x s32>) = G_PHI %val_2(<8 x s32>), %bb.1, %val_1(<8 x s32>), %bb.0
757 %one:_(s32) = G_CONSTANT i32 1
758 %extract:_(s32) = G_EXTRACT_VECTOR_ELT %phi(<8 x s32>), %one(s32)
760 RET_ReallyLR implicit $w0
765 tracksRegLiveness: true
767 ; CHECK-LABEL: name: v16s16
769 ; CHECK: successors: %bb.1(0x50000000), %bb.2(0x30000000)
770 ; CHECK: liveins: $x0, $x1
771 ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF
772 ; CHECK: [[DEF:%[0-9]+]]:_(s16) = G_IMPLICIT_DEF
773 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16)
774 ; CHECK: [[BUILD_VECTOR1:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16)
775 ; CHECK: G_BRCOND %cond(s1), %bb.2
778 ; CHECK: successors: %bb.2(0x80000000)
779 ; CHECK: [[DEF1:%[0-9]+]]:_(s16) = G_IMPLICIT_DEF
780 ; CHECK: [[BUILD_VECTOR2:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16)
781 ; CHECK: [[BUILD_VECTOR3:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16)
783 ; CHECK: [[PHI:%[0-9]+]]:_(<8 x s16>) = G_PHI [[BUILD_VECTOR2]](<8 x s16>), %bb.1, [[BUILD_VECTOR]](<8 x s16>), %bb.0
784 ; CHECK: [[PHI1:%[0-9]+]]:_(<8 x s16>) = G_PHI [[BUILD_VECTOR3]](<8 x s16>), %bb.1, [[BUILD_VECTOR1]](<8 x s16>), %bb.0
785 ; CHECK: %one:_(s16) = G_CONSTANT i16 1
786 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
787 ; CHECK: %extract:_(s16) = G_EXTRACT_VECTOR_ELT [[PHI]](<8 x s16>), [[C]](s64)
788 ; CHECK: $h0 = COPY %extract(s16)
789 ; CHECK: RET_ReallyLR implicit $h0
791 successors: %bb.1(0x50000000), %bb.2(0x30000000)
793 %cond:_(s1) = G_IMPLICIT_DEF
794 %val_1:_(<16 x s16>) = G_IMPLICIT_DEF
795 G_BRCOND %cond(s1), %bb.2
798 %val_2:_(<16 x s16>) = G_IMPLICIT_DEF
800 %phi:_(<16 x s16>) = G_PHI %val_2(<16 x s16>), %bb.1, %val_1(<16 x s16>), %bb.0
801 %one:_(s16) = G_CONSTANT i16 1
802 %extract:_(s16) = G_EXTRACT_VECTOR_ELT %phi(<16 x s16>), %one(s16)
804 RET_ReallyLR implicit $h0
809 tracksRegLiveness: true
811 ; CHECK-LABEL: name: v32s8
813 ; CHECK: successors: %bb.1(0x50000000), %bb.2(0x30000000)
814 ; CHECK: liveins: $x0, $x1
815 ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF
816 ; CHECK: %val_1:_(<32 x s8>) = G_IMPLICIT_DEF
817 ; CHECK: G_BRCOND %cond(s1), %bb.2
820 ; CHECK: successors: %bb.2(0x80000000)
821 ; CHECK: %val_2:_(<32 x s8>) = G_IMPLICIT_DEF
823 ; CHECK: %phi:_(<32 x s8>) = G_PHI %val_2(<32 x s8>), %bb.1, %val_1(<32 x s8>), %bb.0
824 ; CHECK: %one:_(s8) = G_CONSTANT i8 1
825 ; CHECK: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT %one(s8)
826 ; CHECK: %extract:_(s8) = G_EXTRACT_VECTOR_ELT %phi(<32 x s8>), [[SEXT]](s64)
827 ; CHECK: $b0 = COPY %extract(s8)
828 ; CHECK: RET_ReallyLR implicit $b0
830 successors: %bb.1(0x50000000), %bb.2(0x30000000)
832 %cond:_(s1) = G_IMPLICIT_DEF
833 %val_1:_(<32 x s8>) = G_IMPLICIT_DEF
834 G_BRCOND %cond(s1), %bb.2
837 %val_2:_(<32 x s8>) = G_IMPLICIT_DEF
839 %phi:_(<32 x s8>) = G_PHI %val_2(<32 x s8>), %bb.1, %val_1(<32 x s8>), %bb.0
840 %one:_(s8) = G_CONSTANT i8 1
841 %extract:_(s8) = G_EXTRACT_VECTOR_ELT %phi(<32 x s8>), %one(s8)
843 RET_ReallyLR implicit $b0
848 tracksRegLiveness: true
850 ; CHECK-LABEL: name: v4p0
852 ; CHECK: successors: %bb.1(0x50000000), %bb.2(0x30000000)
853 ; CHECK: liveins: $x0, $x1
854 ; CHECK: %ptr1:_(p0) = COPY $x1
855 ; CHECK: %ptr2:_(p0) = COPY $x0
856 ; CHECK: %cond:_(s1) = G_IMPLICIT_DEF
857 ; CHECK: [[LOAD:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr1(p0) :: (load (<2 x s64>), align 32)
858 ; CHECK: [[BITCAST:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD]](<2 x s64>)
859 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
860 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr1, [[C]](s64)
861 ; CHECK: [[LOAD1:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD]](p0) :: (load (<2 x s64>) from unknown-address + 16)
862 ; CHECK: [[BITCAST1:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD1]](<2 x s64>)
863 ; CHECK: G_BRCOND %cond(s1), %bb.2
866 ; CHECK: successors: %bb.2(0x80000000)
867 ; CHECK: [[LOAD2:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr2(p0) :: (load (<2 x s64>), align 32)
868 ; CHECK: [[BITCAST2:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD2]](<2 x s64>)
869 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
870 ; CHECK: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr2, [[C1]](s64)
871 ; CHECK: [[LOAD3:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD1]](p0) :: (load (<2 x s64>) from unknown-address + 16)
872 ; CHECK: [[BITCAST3:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD3]](<2 x s64>)
874 ; CHECK: [[PHI:%[0-9]+]]:_(<2 x p0>) = G_PHI [[BITCAST2]](<2 x p0>), %bb.1, [[BITCAST]](<2 x p0>), %bb.0
875 ; CHECK: [[PHI1:%[0-9]+]]:_(<2 x p0>) = G_PHI [[BITCAST3]](<2 x p0>), %bb.1, [[BITCAST1]](<2 x p0>), %bb.0
876 ; CHECK: $q0 = COPY [[PHI]](<2 x p0>)
877 ; CHECK: $q1 = COPY [[PHI1]](<2 x p0>)
878 ; CHECK: RET_ReallyLR implicit $q0, implicit $q1
880 successors: %bb.1(0x50000000), %bb.2(0x30000000)
883 %ptr1:_(p0) = COPY $x1
884 %ptr2:_(p0) = COPY $x0
885 %cond:_(s1) = G_IMPLICIT_DEF
886 %val_1:_(<4 x p0>) = G_LOAD %ptr1(p0) :: (load (<4 x p0>))
887 G_BRCOND %cond(s1), %bb.2
890 %val_2:_(<4 x p0>) = G_LOAD %ptr2(p0) :: (load (<4 x p0>))
892 %phi:_(<4 x p0>) = G_PHI %val_2(<4 x p0>), %bb.1, %val_1(<4 x p0>), %bb.0
893 %unmerge_1:_(<2 x p0>), %unmerge_2:_(<2 x p0>) = G_UNMERGE_VALUES %phi(<4 x p0>)
894 $q0 = COPY %unmerge_1(<2 x p0>)
895 $q1 = COPY %unmerge_2(<2 x p0>)
896 RET_ReallyLR implicit $q0, implicit $q1