1 # It is not safe to make the transformation if the definition is killed by a call.
2 # Use debug output for simplicity and test resilience.
4 # RUN: llc -mtriple=hexagon -run-pass amode-opt %s -print-after-all -o %t_1.mir 2>&1 | FileCheck %s
6 # CHECK-NOT: liveins: $r2
8 ; ModuleID = 'foo.reduced.i'
9 source_filename = "foo.reduced.i"
10 target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
11 target triple = "hexagon-unknown-unknown-elf"
13 %struct.struct_1 = type { i8, i8, [7 x %struct.struct_3] }
14 %struct.struct_3 = type { i8, %struct.struct_4 }
15 %struct.struct_4 = type { i32, i32 }
16 %struct.struct_2 = type { i32, i32 }
18 ; Function Attrs: nounwind
19 define dso_local zeroext i8 @fun_4(i32 noundef %arg_1, i8 noundef zeroext %arg_2, ptr nocapture noundef readonly %arg_3, ptr nocapture noundef readonly %arg_4) local_unnamed_addr #0 {
21 %conv = zext i8 %arg_2 to i32
22 %cmp = icmp ult i8 %arg_2, 7
23 br i1 %cmp, label %if.then, label %if.end
25 if.then: ; preds = %entry
26 tail call void @fun_2(ptr noundef null, i32 noundef %conv) #3
29 if.end: ; preds = %entry
30 %cgep = getelementptr inbounds %struct.struct_1, ptr %arg_3, i32 0, i32 2, i32 %conv
31 %cgep23 = getelementptr inbounds %struct.struct_3, ptr %cgep, i32 0, i32 1, i32 1
32 %0 = load i32, ptr %cgep23, align 4
33 %cmp3 = icmp eq i32 %0, 4
34 br i1 %cmp3, label %land.lhs.true, label %if.else
36 land.lhs.true: ; preds = %if.end
37 %cgep22 = getelementptr inbounds %struct.struct_3, ptr %cgep, i32 0, i32 1
38 %1 = load i32, ptr %cgep22, align 4
39 %call = tail call zeroext i8 @fun_5(i32 noundef %arg_1, i32 noundef %1) #4
40 %tobool.not = icmp eq i8 %call, 0
41 br i1 %tobool.not, label %if.else, label %if.end12
43 if.else: ; preds = %land.lhs.true, %if.end
44 %2 = load i8, ptr %cgep, align 4
45 %cmp.i = icmp eq i8 %2, 1
46 br i1 %cmp.i, label %if.then.i, label %fun_3.exit
48 if.then.i: ; preds = %if.else
49 %cgep2027 = bitcast ptr %arg_4 to ptr
50 %cgep26 = getelementptr inbounds %struct.struct_2, ptr %cgep2027, i32 0, i32 1
51 %3 = load i32, ptr %cgep26, align 4
52 %call.i = tail call i32 @fun_1(i32 noundef %arg_1) #4
53 %cmp2.i = icmp ult i32 %3, %call.i
54 %cgep25 = getelementptr inbounds %struct.struct_2, ptr %cgep2027, i32 0, i32 1
55 %4 = load i32, ptr %cgep25, align 4
56 %call6.i = tail call i32 @fun_1(i32 noundef %arg_1) #4
57 %cmp7.i = icmp ult i32 %4, %call6.i
58 %5 = select i1 %cmp2.i, i1 true, i1 %cmp7.i
61 fun_3.exit: ; preds = %if.else, %if.then.i
62 %resume_ttl.1.i = phi i1 [ false, %if.else ], [ %5, %if.then.i ]
63 %conv15.i = zext i1 %resume_ttl.1.i to i8
66 if.end12: ; preds = %land.lhs.true, %fun_3.exit
67 %resume_loops.0 = phi i8 [ %conv15.i, %fun_3.exit ], [ 1, %land.lhs.true ]
68 ret i8 %resume_loops.0
71 ; Function Attrs: noreturn
72 declare dso_local void @fun_2(ptr noundef, i32 noundef) local_unnamed_addr #1
74 declare dso_local zeroext i8 @fun_5(i32 noundef, i32 noundef) local_unnamed_addr #2
76 declare dso_local i32 @fun_1(i32 noundef) local_unnamed_addr #2
78 !llvm.module.flags = !{!0, !1}
81 !0 = !{i32 1, !"wchar_size", i32 4}
82 !1 = !{i32 7, !"frame-pointer", i32 2}
89 exposesReturnsTwice: false
91 regBankSelected: false
94 tracksRegLiveness: true
97 callsUnwindInit: false
103 failsVerification: false
104 tracksDebugUserValues: true
107 - { reg: '$r0', virtual-reg: '' }
108 - { reg: '$r1', virtual-reg: '' }
109 - { reg: '$r2', virtual-reg: '' }
110 - { reg: '$r3', virtual-reg: '' }
112 isFrameAddressTaken: false
113 isReturnAddressTaken: false
123 maxCallFrameSize: 4294967295
124 cvBytesOfCalleeSavedRegisters: 0
125 hasOpaqueSPAdjustment: false
127 hasMustTailInVarArgFunc: false
134 - { id: 0, name: '', type: spill-slot, offset: 0, size: 4, alignment: 4,
135 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
136 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
139 debugValueSubstitutions: []
141 machineFunctionInfo: {}
144 successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
145 liveins: $r0:0x0000000000000001, $r1:0x0000000000000001, $r2:0x0000000000000001, $r3:0x0000000000000001
147 renamable $p0 = C2_cmpgtui renamable $r1, 6
148 renamable $r16 = COPY killed $r3
149 renamable $r17 = COPY killed $r0
150 J2_jumpt killed renamable $p0, %bb.2, implicit-def dead $pc
151 J2_jump %bb.1, implicit-def dead $pc
155 liveins: $r1:0x0000000000000001
158 ADJCALLSTACKDOWN 0, 0, implicit-def $r29, implicit-def dead $r30, implicit killed $r31, implicit killed $r30, implicit $r29
159 PS_call_nr @fun_2, hexagoncsr, implicit killed $r0, implicit killed $r1, implicit-def $r29
160 ADJCALLSTACKUP 0, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit killed $r29
163 successors: %bb.3(0x40000000), %bb.4(0x40000000)
164 liveins: $r1:0x0000000000000001, $r2:0x0000000000000001, $r16:0x0000000000000001, $r17:0x0000000000000001
166 renamable $r2 = M2_macsip killed renamable $r2, killed renamable $r1, 12
167 renamable $r3 = L2_loadri_io renamable $r2, 12 :: (load (s32) from %ir.cgep23)
168 renamable $p0 = C2_cmpeqi killed renamable $r3, 4
169 renamable $r18 = A2_addi killed renamable $r2, 4
170 J2_jumpf killed renamable $p0, %bb.4, implicit-def dead $pc
171 J2_jump %bb.3, implicit-def dead $pc
174 successors: %bb.4(0x30000000), %bb.8(0x50000000)
175 liveins: $r16:0x0000000000000001, $r17:0x0000000000000001, $r18:0x0000000000000001
177 renamable $r1 = L2_loadri_io renamable $r18, 4 :: (load (s32) from %ir.cgep22)
178 ADJCALLSTACKDOWN 0, 0, implicit-def $r29, implicit-def dead $r30, implicit killed $r31, implicit killed $r30, implicit $r29
179 $r0 = COPY renamable $r17
180 J2_call @fun_5, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit $r0, implicit killed $r1, implicit-def $r29, implicit-def $r0
181 renamable $p0 = C2_cmpeqi killed renamable $r0, 0
182 ADJCALLSTACKUP 0, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit killed $r29
183 renamable $r0 = A2_tfrsi 1
184 J2_jumpf killed renamable $p0, %bb.8, implicit-def dead $pc
185 J2_jump %bb.4, implicit-def dead $pc
188 successors: %bb.6(0x40000000), %bb.5(0x40000000)
189 liveins: $r16:0x0000000000000001, $r17:0x0000000000000001, $r18:0x0000000000000001
191 renamable $r2 = L2_loadrb_io killed renamable $r18, 0 :: (load (s8) from %ir.cgep, align 4)
192 renamable $p0 = C2_cmpeqi killed renamable $r2, 1
193 J2_jumpt killed renamable $p0, %bb.6, implicit-def $pc
196 successors: %bb.7(0x80000000)
198 renamable $p0 = PS_false
199 J2_jump %bb.7, implicit-def $pc
202 successors: %bb.7(0x80000000)
203 liveins: $r16:0x0000000000000001, $r17:0x0000000000000001
205 ADJCALLSTACKDOWN 0, 0, implicit-def $r29, implicit-def dead $r30, implicit $r31, implicit $r30, implicit $r29
206 $r0 = COPY renamable $r17
207 renamable $r18 = L2_loadri_io renamable $r16, 4 :: (load (s32) from %ir.cgep26)
208 J2_call @fun_1, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit $r0, implicit-def $r29, implicit-def $r0
209 ADJCALLSTACKUP 0, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit $r29
210 renamable $p0 = C2_cmpgtu killed renamable $r0, killed renamable $r18
211 STriw_pred %stack.0, 0, killed renamable $p0 :: (store (s32) into %stack.0)
212 $r0 = COPY killed renamable $r17
213 ADJCALLSTACKDOWN 0, 0, implicit-def $r29, implicit-def dead $r30, implicit killed $r31, implicit killed $r30, implicit $r29
214 renamable $r16 = L2_loadri_io killed renamable $r16, 4 :: (load (s32) from %ir.cgep25)
215 J2_call @fun_1, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit $r0, implicit-def $r29, implicit-def $r0
216 renamable $p0 = C2_cmpgtu killed renamable $r0, killed renamable $r16
217 ADJCALLSTACKUP 0, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit killed $r29
218 renamable $p1 = LDriw_pred %stack.0, 0 :: (load (s32) from %stack.0)
219 renamable $p0 = C2_or killed renamable $p1, killed renamable $p0
222 successors: %bb.8(0x80000000)
225 renamable $r0 = C2_cmoveit renamable $p0, 1
226 renamable $r0 = C2_cmoveif killed renamable $p0, 0, implicit killed renamable $r0(tied-def 0)
229 liveins: $r0:0x0000000000000001
231 PS_jmpret killed $r31, implicit-def dead $pc, implicit killed $r0