1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -verify-machineinstrs -mtriple arm64-apple-ios -global-isel -run-pass=aarch64-prelegalizer-combiner -o - %s | FileCheck %s
7 tracksRegLiveness: true
9 ; CHECK-LABEL: name: can_fold_i8
11 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
12 ; CHECK-NEXT: liveins: $w0, $w1
14 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
15 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 8
16 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
17 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 8
18 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
19 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 256
20 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
21 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
22 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
23 ; CHECK-NEXT: G_BRCOND [[ICMP]](s1), %bb.2
24 ; CHECK-NEXT: G_BR %bb.1
27 ; CHECK-NEXT: successors:{{ $}}
29 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
32 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
33 ; CHECK-NEXT: RET_ReallyLR implicit $w0
35 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
39 %3:_(s32) = G_ASSERT_ZEXT %2, 8
40 %0:_(s8) = G_TRUNC %3(s32)
42 %5:_(s32) = G_ASSERT_ZEXT %4, 8
43 %1:_(s8) = G_TRUNC %5(s32)
44 %6:_(s8), %7:_(s1) = G_UADDO %0, %1
45 G_BRCOND %7(s1), %bb.2
51 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
54 %8:_(s32) = G_ZEXT %6(s8)
56 RET_ReallyLR implicit $w0
60 name: can_fold_i16_1_result_used_by_zext
61 tracksRegLiveness: true
63 ; CHECK-LABEL: name: can_fold_i16_1_result_used_by_zext
65 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
66 ; CHECK-NEXT: liveins: $w0, $w1
68 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
69 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
70 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
71 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
72 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
73 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
74 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
75 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
76 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
77 ; CHECK-NEXT: G_BRCOND [[ICMP]](s1), %bb.2
78 ; CHECK-NEXT: G_BR %bb.1
81 ; CHECK-NEXT: successors:{{ $}}
83 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
86 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
87 ; CHECK-NEXT: RET_ReallyLR implicit $w0
89 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
93 %3:_(s32) = G_ASSERT_ZEXT %2, 16
94 %0:_(s16) = G_TRUNC %3(s32)
96 %5:_(s32) = G_ASSERT_ZEXT %4, 16
97 %1:_(s16) = G_TRUNC %5(s32)
98 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
99 G_BRCOND %7(s1), %bb.2
105 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
108 %8:_(s32) = G_ZEXT %6(s16)
110 RET_ReallyLR implicit $w0
114 name: can_fold_i16_2_result_used_by_multiple_calls
115 tracksRegLiveness: true
117 ; CHECK-LABEL: name: can_fold_i16_2_result_used_by_multiple_calls
119 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
120 ; CHECK-NEXT: liveins: $w0, $w1, $x2
122 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
123 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
124 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
125 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
126 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
127 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
128 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
129 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
130 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
131 ; CHECK-NEXT: G_BRCOND [[ICMP]](s1), %bb.2
132 ; CHECK-NEXT: G_BR %bb.1
135 ; CHECK-NEXT: successors:{{ $}}
137 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
140 ; CHECK-NEXT: liveins: $x2
142 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
143 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
144 ; CHECK-NEXT: BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
145 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
146 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
147 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
148 ; CHECK-NEXT: BLR killed renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
149 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
150 ; CHECK-NEXT: RET_ReallyLR
152 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
153 liveins: $w0, $w1, $x2
156 %3:_(s32) = G_ASSERT_ZEXT %2, 16
157 %0:_(s16) = G_TRUNC %3(s32)
159 %5:_(s32) = G_ASSERT_ZEXT %4, 16
160 %1:_(s16) = G_TRUNC %5(s32)
161 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
162 G_BRCOND %7(s1), %bb.2
168 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
173 ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
174 %8:_(s32) = G_ANYEXT %6(s16)
176 BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
177 ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
178 ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
180 BLR killed renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
181 ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
186 name: can_fold_i16_3_result_used_by_anyext
187 tracksRegLiveness: true
189 ; CHECK-LABEL: name: can_fold_i16_3_result_used_by_anyext
191 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
192 ; CHECK-NEXT: liveins: $w0, $w1
194 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
195 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
196 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
197 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
198 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
199 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
200 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
201 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
202 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
203 ; CHECK-NEXT: G_BRCOND [[ICMP]](s1), %bb.2
204 ; CHECK-NEXT: G_BR %bb.1
207 ; CHECK-NEXT: successors:{{ $}}
209 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
212 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
213 ; CHECK-NEXT: RET_ReallyLR implicit $w0
215 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
219 %3:_(s32) = G_ASSERT_ZEXT %2, 16
220 %0:_(s16) = G_TRUNC %3(s32)
222 %5:_(s32) = G_ASSERT_ZEXT %4, 16
223 %1:_(s16) = G_TRUNC %5(s32)
224 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
225 G_BRCOND %7(s1), %bb.2
231 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
234 %8:_(s32) = G_ANYEXT %6(s16)
236 RET_ReallyLR implicit $w0
240 name: can_fold_i16_4_cond_dbg_user
241 tracksRegLiveness: true
243 ; CHECK-LABEL: name: can_fold_i16_4_cond_dbg_user
245 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
246 ; CHECK-NEXT: liveins: $w0, $w1
248 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
249 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
250 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
251 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
252 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
253 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
254 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
255 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
256 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
257 ; CHECK-NEXT: DBG_VALUE [[ICMP]](s1)
258 ; CHECK-NEXT: G_BRCOND [[ICMP]](s1), %bb.2
259 ; CHECK-NEXT: G_BR %bb.1
262 ; CHECK-NEXT: successors:{{ $}}
264 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
267 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
268 ; CHECK-NEXT: RET_ReallyLR implicit $w0
270 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
274 %3:_(s32) = G_ASSERT_ZEXT %2, 16
275 %0:_(s16) = G_TRUNC %3(s32)
277 %5:_(s32) = G_ASSERT_ZEXT %4, 16
278 %1:_(s16) = G_TRUNC %5(s32)
279 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
281 G_BRCOND %7(s1), %bb.2
287 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
290 %8:_(s32) = G_ZEXT %6(s16)
292 RET_ReallyLR implicit $w0
296 name: can_fold_i16_5_result_dbg_user
297 tracksRegLiveness: true
299 ; CHECK-LABEL: name: can_fold_i16_5_result_dbg_user
301 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
302 ; CHECK-NEXT: liveins: $w0, $w1
304 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
305 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
306 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
307 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
308 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
309 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
310 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
311 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
312 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
313 ; CHECK-NEXT: DBG_VALUE %6:_(s16)
314 ; CHECK-NEXT: G_BRCOND [[ICMP]](s1), %bb.2
315 ; CHECK-NEXT: G_BR %bb.1
318 ; CHECK-NEXT: successors:{{ $}}
320 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
323 ; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
324 ; CHECK-NEXT: RET_ReallyLR implicit $w0
326 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
330 %3:_(s32) = G_ASSERT_ZEXT %2, 16
331 %0:_(s16) = G_TRUNC %3(s32)
333 %5:_(s32) = G_ASSERT_ZEXT %4, 16
334 %1:_(s16) = G_TRUNC %5(s32)
335 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
337 G_BRCOND %7(s1), %bb.2
343 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
346 %8:_(s32) = G_ZEXT %6(s16)
348 RET_ReallyLR implicit $w0
352 name: cannot_fold_1_result_used_before_branch
353 tracksRegLiveness: true
355 ; CHECK-LABEL: name: cannot_fold_1_result_used_before_branch
357 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
358 ; CHECK-NEXT: liveins: $w0, $w1, $x2
360 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
361 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
362 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
363 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
364 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
365 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
366 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
367 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
368 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
369 ; CHECK-NEXT: $w0 = COPY [[ANYEXT]](s32)
370 ; CHECK-NEXT: BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
371 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
372 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
373 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
374 ; CHECK-NEXT: G_BRCOND [[XOR]](s1), %bb.2
375 ; CHECK-NEXT: G_BR %bb.1
378 ; CHECK-NEXT: successors:{{ $}}
380 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
383 ; CHECK-NEXT: liveins: $x2
385 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
386 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
387 ; CHECK-NEXT: $w0 = COPY [[ANYEXT1]](s32)
388 ; CHECK-NEXT: BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
389 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
390 ; CHECK-NEXT: RET_ReallyLR
392 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
393 liveins: $w0, $w1, $x2
396 %3:_(s32) = G_ASSERT_ZEXT %2, 16
397 %0:_(s16) = G_TRUNC %3(s32)
399 %5:_(s32) = G_ASSERT_ZEXT %4, 16
400 %1:_(s16) = G_TRUNC %5(s32)
401 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
402 ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
403 %8:_(s32) = G_ANYEXT %6(s16)
405 BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
406 ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
407 G_BRCOND %7(s1), %bb.2
413 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
418 ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
419 %9:_(s32) = G_ANYEXT %6(s16)
421 BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
422 ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
427 name: cannot_fold_2_result_used_in_fail_block
428 tracksRegLiveness: true
430 ; CHECK-LABEL: name: cannot_fold_2_result_used_in_fail_block
432 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
433 ; CHECK-NEXT: liveins: $w0, $w1
435 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
436 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
437 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
438 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
439 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
440 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
441 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 10
442 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
443 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
444 ; CHECK-NEXT: G_BRCOND [[UADDO1]](s1), %bb.2
445 ; CHECK-NEXT: G_BR %bb.1
448 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[C]](s32), %bb.2, [[ANYEXT]](s32), %bb.0
449 ; CHECK-NEXT: $w0 = COPY [[PHI]](s32)
450 ; CHECK-NEXT: RET_ReallyLR implicit $w0
453 ; CHECK-NEXT: successors: %bb.1(0x80000000)
455 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
456 ; CHECK-NEXT: $w0 = COPY [[ANYEXT1]](s32)
457 ; CHECK-NEXT: G_BR %bb.1
462 %3:_(s32) = G_ASSERT_ZEXT %2, 16
463 %0:_(s16) = G_TRUNC %3(s32)
465 %5:_(s32) = G_ASSERT_ZEXT %4, 16
466 %1:_(s16) = G_TRUNC %5(s32)
467 %11:_(s16) = G_CONSTANT i16 10
468 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
469 G_BRCOND %7(s1), %bb.3
473 %9:_(s16) = G_PHI %11(s16), %bb.3, %6(s16), %bb.1
474 %10:_(s32) = G_ANYEXT %9(s16)
476 RET_ReallyLR implicit $w0
479 %8:_(s32) = G_ANYEXT %6(s16)
485 name: cannot_fold_3_result_used_in_successor_before_fail_block
486 tracksRegLiveness: true
488 ; CHECK-LABEL: name: cannot_fold_3_result_used_in_successor_before_fail_block
490 ; CHECK-NEXT: successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
491 ; CHECK-NEXT: liveins: $w0, $w1, $x2
493 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
494 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
495 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
496 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
497 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
498 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
499 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
500 ; CHECK-NEXT: G_BR %bb.1
503 ; CHECK-NEXT: successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
504 ; CHECK-NEXT: liveins: $x2
506 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
507 ; CHECK-NEXT: $w0 = COPY [[ANYEXT]](s32)
508 ; CHECK-NEXT: BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
509 ; CHECK-NEXT: G_BRCOND [[UADDO1]](s1), %bb.2
510 ; CHECK-NEXT: G_BR %bb.3
513 ; CHECK-NEXT: successors:{{ $}}
515 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
518 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s16)
519 ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
520 ; CHECK-NEXT: RET_ReallyLR implicit $w0
522 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
523 liveins: $w0, $w1, $x2
526 %3:_(s32) = G_ASSERT_ZEXT %2, 16
527 %0:_(s16) = G_TRUNC %3(s32)
529 %5:_(s32) = G_ASSERT_ZEXT %4, 16
530 %1:_(s16) = G_TRUNC %5(s32)
531 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
536 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
538 %8:_(s32) = G_ANYEXT %6(s16)
540 BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
541 G_BRCOND %7(s1), %bb.2
547 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
550 %9:_(s32) = G_ZEXT %6(s16)
552 RET_ReallyLR implicit $w0
556 name: cannot_fold_i8_trunc_i
557 tracksRegLiveness: true
559 ; CHECK-LABEL: name: cannot_fold_i8_trunc_i
561 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
562 ; CHECK-NEXT: liveins: $w0, $w1
564 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
565 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
566 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
567 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
568 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 8
569 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_ZEXT1]](s32)
570 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC]](s16)
571 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s8), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC2]], [[TRUNC1]]
572 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
573 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
574 ; CHECK-NEXT: G_BRCOND [[XOR]](s1), %bb.2
575 ; CHECK-NEXT: G_BR %bb.1
578 ; CHECK-NEXT: successors:{{ $}}
580 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
583 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s8)
584 ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
585 ; CHECK-NEXT: RET_ReallyLR implicit $w0
587 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
591 %3:_(s32) = G_ASSERT_ZEXT %2, 16
592 %0:_(s16) = G_TRUNC %3(s32)
594 %5:_(s32) = G_ASSERT_ZEXT %4, 8
595 %1:_(s8) = G_TRUNC %5(s32)
596 %6:_(s8) = G_TRUNC %0(s16)
597 %7:_(s8), %8:_(s1) = G_UADDO %6, %1
598 G_BRCOND %8(s1), %bb.2
604 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
607 %9:_(s32) = G_ZEXT %7(s8)
609 RET_ReallyLR implicit $w0
613 name: cannot_fold_i8_trunc_b
614 tracksRegLiveness: true
616 ; CHECK-LABEL: name: cannot_fold_i8_trunc_b
618 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
619 ; CHECK-NEXT: liveins: $w0, $w1
621 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
622 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 8
623 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_ZEXT]](s32)
624 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
625 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
626 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
627 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC1]](s16)
628 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s8), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC2]]
629 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
630 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
631 ; CHECK-NEXT: G_BRCOND [[XOR]](s1), %bb.2
632 ; CHECK-NEXT: G_BR %bb.1
635 ; CHECK-NEXT: successors:{{ $}}
637 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
640 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s8)
641 ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
642 ; CHECK-NEXT: RET_ReallyLR implicit $w0
644 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
648 %3:_(s32) = G_ASSERT_ZEXT %2, 8
649 %0:_(s8) = G_TRUNC %3(s32)
651 %5:_(s32) = G_ASSERT_ZEXT %4, 16
652 %1:_(s16) = G_TRUNC %5(s32)
653 %6:_(s8) = G_TRUNC %1(s16)
654 %7:_(s8), %8:_(s1) = G_UADDO %0, %6
655 G_BRCOND %8(s1), %bb.2
661 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
664 %9:_(s32) = G_ZEXT %7(s8)
666 RET_ReallyLR implicit $w0
670 name: cannot_fold_i8_trunc_both
671 tracksRegLiveness: true
673 ; CHECK-LABEL: name: cannot_fold_i8_trunc_both
675 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
676 ; CHECK-NEXT: liveins: $w0, $w1
678 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
679 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
680 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
681 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
682 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
683 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
684 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC]](s16)
685 ; CHECK-NEXT: [[TRUNC3:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC1]](s16)
686 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s8), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC2]], [[TRUNC3]]
687 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
688 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
689 ; CHECK-NEXT: G_BRCOND [[XOR]](s1), %bb.2
690 ; CHECK-NEXT: G_BR %bb.1
693 ; CHECK-NEXT: successors:{{ $}}
695 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
698 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s8)
699 ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
700 ; CHECK-NEXT: RET_ReallyLR implicit $w0
702 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
706 %3:_(s32) = G_ASSERT_ZEXT %2, 16
707 %0:_(s16) = G_TRUNC %3(s32)
709 %5:_(s32) = G_ASSERT_ZEXT %4, 16
710 %1:_(s16) = G_TRUNC %5(s32)
711 %6:_(s8) = G_TRUNC %0(s16)
712 %7:_(s8) = G_TRUNC %1(s16)
713 %8:_(s8), %9:_(s1) = G_UADDO %6, %7
714 G_BRCOND %9(s1), %bb.2
720 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
723 %10:_(s32) = G_ZEXT %8(s8)
725 RET_ReallyLR implicit $w0
729 name: cannot_fold_overflow_status_used_in_select
730 tracksRegLiveness: true
735 ; CHECK-LABEL: name: cannot_fold_overflow_status_used_in_select
736 ; CHECK: liveins: $w0, $w1
738 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
739 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
740 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
741 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
742 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
743 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
744 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 10
745 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
746 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s16) = G_SELECT [[UADDO1]](s1), [[C]], [[UADDO]]
747 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[SELECT]](s16)
748 ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
749 ; CHECK-NEXT: RET_ReallyLR implicit $w0
751 %3:_(s32) = G_ASSERT_ZEXT %2, 16
752 %0:_(s16) = G_TRUNC %3(s32)
754 %5:_(s32) = G_ASSERT_ZEXT %4, 16
755 %1:_(s16) = G_TRUNC %5(s32)
756 %9:_(s16) = G_CONSTANT i16 10
757 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
758 %8:_(s16) = G_SELECT %7(s1), %9, %6
759 %10:_(s32) = G_ZEXT %8(s16)
761 RET_ReallyLR implicit $w0
765 name: cannot_fold_i16_inputs_not_assert_zext
766 tracksRegLiveness: true
768 ; CHECK-LABEL: name: cannot_fold_i16_inputs_not_assert_zext
770 ; CHECK-NEXT: successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
771 ; CHECK-NEXT: liveins: $w0, $w1
773 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
774 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
775 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
776 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
777 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
778 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
779 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
780 ; CHECK-NEXT: G_BRCOND [[XOR]](s1), %bb.2
781 ; CHECK-NEXT: G_BR %bb.1
784 ; CHECK-NEXT: successors:{{ $}}
786 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
789 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
790 ; CHECK-NEXT: $w0 = COPY [[ANYEXT]](s32)
791 ; CHECK-NEXT: RET_ReallyLR implicit $w0
793 successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
797 %0:_(s16) = G_TRUNC %2(s32)
799 %1:_(s16) = G_TRUNC %3(s32)
800 %4:_(s16), %5:_(s1) = G_UADDO %0, %1
801 G_BRCOND %5(s1), %bb.2
807 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
810 %6:_(s32) = G_ANYEXT %4(s16)
812 RET_ReallyLR implicit $w0
816 name: cannot_fold_branch_to_use_on_overflow
817 tracksRegLiveness: true
819 ; CHECK-LABEL: name: cannot_fold_branch_to_use_on_overflow
821 ; CHECK-NEXT: successors: %bb.1(0x7ffff800), %bb.2(0x00000800)
822 ; CHECK-NEXT: liveins: $w0, $w1
824 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
825 ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
826 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
827 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
828 ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
829 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
830 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
831 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
832 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
833 ; CHECK-NEXT: G_BRCOND [[XOR]](s1), %bb.2
834 ; CHECK-NEXT: G_BR %bb.1
837 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s16)
838 ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
839 ; CHECK-NEXT: RET_ReallyLR implicit $w0
842 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
844 successors: %bb.2(0x7ffff800), %bb.3(0x00000800)
848 %3:_(s32) = G_ASSERT_ZEXT %2, 16
849 %0:_(s16) = G_TRUNC %3(s32)
851 %5:_(s32) = G_ASSERT_ZEXT %4, 16
852 %1:_(s16) = G_TRUNC %5(s32)
853 %6:_(s16), %7:_(s1) = G_UADDO %0, %1
854 G_BRCOND %7(s1), %bb.2
858 %8:_(s32) = G_ZEXT %6(s16)
860 RET_ReallyLR implicit $w0
863 G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)