1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2 # RUN: llc --run-pass=machine-sink %s -o - | FileCheck %s
4 # Test that the "killed" flags are cleared in the ORRWrs and SUBSWrr instructions
5 # in 'f and @g, respectively
8 source_filename = "crash.ll"
9 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
10 target triple = "aarch64-linux"
12 define i32 @f(ptr %image, i32 %i) {
15 %idx = zext i32 %add to i64
18 A: ; preds = %B, %A, %entry
19 %sunkaddr = getelementptr i8, ptr %image, i64 %idx
20 %0 = load i8, ptr %sunkaddr, align 1
21 %cmp153 = icmp eq i8 %0, 0
22 br i1 %cmp153, label %B, label %A
25 store i32 0, ptr %image, align 1
29 define i32 @g(i32 %i, i32 %j) {
35 A: ; preds = %B, %A, %entry
36 %0 = call i8 @h(i32 %add)
38 br i1 %c, label %B, label %A
41 %1 = call i8 @h(i32 %neg)
51 tracksRegLiveness: true
53 - { id: 0, class: gpr64, preferred-register: '' }
54 - { id: 1, class: gpr64common, preferred-register: '' }
55 - { id: 2, class: gpr32common, preferred-register: '' }
56 - { id: 3, class: gpr32common, preferred-register: '' }
57 - { id: 4, class: gpr32, preferred-register: '' }
58 - { id: 5, class: gpr32, preferred-register: '' }
59 - { id: 6, class: gpr32, preferred-register: '' }
61 - { reg: '$x0', virtual-reg: '%1' }
62 - { reg: '$w1', virtual-reg: '%2' }
64 ; CHECK-LABEL: name: f
66 ; CHECK-NEXT: successors: %bb.1(0x80000000)
67 ; CHECK-NEXT: liveins: $x0, $w1
69 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32common = COPY $w1
70 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64common = COPY $x0
71 ; CHECK-NEXT: [[ADDWri:%[0-9]+]]:gpr32common = ADDWri [[COPY]], 1, 0
72 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, [[ADDWri]], 0
75 ; CHECK-NEXT: successors: %bb.2(0x30000000), %bb.1(0x50000000)
77 ; CHECK-NEXT: [[LDRBBroW:%[0-9]+]]:gpr32 = LDRBBroW [[COPY1]], [[ADDWri]], 0, 0 :: (load (s8) from %ir.sunkaddr)
78 ; CHECK-NEXT: CBNZW killed [[LDRBBroW]], %bb.1
82 ; CHECK-NEXT: successors: %bb.1(0x80000000)
84 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
85 ; CHECK-NEXT: STRWui [[COPY2]], [[COPY1]], 0 :: (store (s32) into %ir.image, align 1)
88 successors: %bb.1(0x80000000)
91 %2:gpr32common = COPY $w1
92 %1:gpr64common = COPY $x0
93 %3:gpr32common = ADDWri %2, 1, 0
94 %4:gpr32 = ORRWrs $wzr, killed %3, 0
95 %0:gpr64 = SUBREG_TO_REG 0, killed %4, %subreg.sub_32
98 successors: %bb.2(0x30000000), %bb.1(0x50000000)
100 %5:gpr32 = LDRBBroX %1, %0, 0, 0 :: (load (s8) from %ir.sunkaddr)
101 CBNZW killed %5, %bb.1
105 successors: %bb.1(0x80000000)
108 STRWui %6, %1, 0 :: (store (s32) into %ir.image, align 1)
115 - { id: 0, class: gpr32all, preferred-register: '' }
116 - { id: 1, class: gpr32all, preferred-register: '' }
117 - { id: 2, class: gpr32, preferred-register: '' }
118 - { id: 3, class: gpr32, preferred-register: '' }
119 - { id: 4, class: gpr32, preferred-register: '' }
120 - { id: 5, class: gpr32, preferred-register: '' }
121 - { id: 6, class: gpr32, preferred-register: '' }
122 - { id: 7, class: gpr32, preferred-register: '' }
123 - { id: 8, class: gpr32common, preferred-register: '' }
124 - { id: 9, class: gpr32all, preferred-register: '' }
126 - { reg: '$w0', virtual-reg: '%2' }
127 - { reg: '$w1', virtual-reg: '%3' }
129 ; CHECK-LABEL: name: g
131 ; CHECK-NEXT: successors: %bb.1(0x80000000)
132 ; CHECK-NEXT: liveins: $w0, $w1
134 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w1
135 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w0
136 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
137 ; CHECK-NEXT: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr [[COPY2]], [[COPY1]], implicit-def dead $nzcv
138 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr32all = COPY [[SUBSWrr]]
140 ; CHECK-NEXT: bb.1.A:
141 ; CHECK-NEXT: successors: %bb.2(0x30000000), %bb.1(0x50000000)
143 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
144 ; CHECK-NEXT: $w0 = ADDWrr [[COPY1]], [[COPY]]
145 ; CHECK-NEXT: BL @h, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0
146 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
147 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gpr32 = COPY $w0
148 ; CHECK-NEXT: $wzr = ANDSWri [[COPY4]], 7, implicit-def $nzcv
149 ; CHECK-NEXT: Bcc 1, %bb.1, implicit $nzcv
150 ; CHECK-NEXT: B %bb.2
152 ; CHECK-NEXT: bb.2.B:
153 ; CHECK-NEXT: successors: %bb.1(0x80000000)
155 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
156 ; CHECK-NEXT: $w0 = COPY [[COPY3]]
157 ; CHECK-NEXT: BL @h, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0
158 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
159 ; CHECK-NEXT: B %bb.1
161 successors: %bb.1(0x80000000)
166 %4:gpr32 = ADDWrr %2, killed %3
167 %0:gpr32all = COPY %4
169 %6:gpr32 = SUBSWrr %5, killed %2, implicit-def dead $nzcv
170 %1:gpr32all = COPY %6
173 successors: %bb.2(0x30000000), %bb.1(0x50000000)
175 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
177 BL @h, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0
178 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
180 $wzr = ANDSWri %7, 7, implicit-def $nzcv
181 Bcc 1, %bb.1, implicit $nzcv
185 successors: %bb.1(0x80000000)
187 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
189 BL @h, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0
190 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp