1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64 -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
4 # This test checks we don't crash when doing zext(trunc) legalizer combines.
6 name: zext_trunc_dead_inst_crash
8 tracksRegLiveness: true
10 ; CHECK-LABEL: name: zext_trunc_dead_inst_crash
12 ; CHECK: successors: %bb.1(0x80000000)
13 ; CHECK: [[DEF:%[0-9]+]]:_(s16) = G_IMPLICIT_DEF
15 ; CHECK: successors: %bb.2(0x80000000)
16 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI %32(s16), %bb.2, [[DEF]](s16), %bb.0
17 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
18 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
19 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C]]
20 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 46
21 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
22 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
23 ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
24 ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[COPY]], [[DEF1]]
25 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -33
26 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C2]]
27 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[AND1]](s32)
28 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 -65
29 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[C3]]
30 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
31 ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]]
32 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 26
33 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[AND2]](s32), [[C4]]
34 ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[ICMP1]](s32)
35 ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[OR]](s32)
36 ; CHECK: [[OR1:%[0-9]+]]:_(s32) = G_OR [[COPY3]], [[COPY4]]
37 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[OR1]](s32)
38 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.2
40 ; CHECK: successors: %bb.1(0x80000000)
41 ; CHECK: [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 64
44 %1:_(s8) = G_CONSTANT i8 46
45 %3:_(s1) = G_IMPLICIT_DEF
46 %5:_(s8) = G_CONSTANT i8 -33
47 %7:_(s8) = G_CONSTANT i8 -65
48 %9:_(s8) = G_CONSTANT i8 26
49 %13:_(s8) = G_IMPLICIT_DEF
52 %0:_(s8) = G_PHI %12(s8), %bb.4, %13(s8), %bb.1
53 %2:_(s1) = G_ICMP intpred(eq), %0(s8), %1
54 %4:_(s1) = G_OR %2, %3
55 %6:_(s8) = G_AND %0, %5
56 %8:_(s8) = G_ADD %6, %7
57 %10:_(s1) = G_ICMP intpred(ult), %8(s8), %9
58 %11:_(s1) = G_OR %10, %4
59 G_BRCOND %11(s1), %bb.4
62 %12:_(s8) = G_CONSTANT i8 64