1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names \
3 ; RUN: -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-PWR9
4 ; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names \
5 ; RUN: -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
7 ; Check CSR split can work properly for tests below.
9 @a = dso_local local_unnamed_addr global i32 0, align 4
11 define dso_local signext i32 @test1(ptr %b) local_unnamed_addr {
12 ; CHECK-PWR9-LABEL: test1:
13 ; CHECK-PWR9: # %bb.0: # %entry
14 ; CHECK-PWR9-NEXT: addis r4, r2, a@toc@ha
15 ; CHECK-PWR9-NEXT: lwa r4, a@toc@l(r4)
16 ; CHECK-PWR9-NEXT: cmpld r4, r3
17 ; CHECK-PWR9-NEXT: # implicit-def: $r4
18 ; CHECK-PWR9-NEXT: beq cr0, .LBB0_2
19 ; CHECK-PWR9-NEXT: # %bb.1: # %if.end
20 ; CHECK-PWR9-NEXT: extsw r3, r4
21 ; CHECK-PWR9-NEXT: blr
22 ; CHECK-PWR9-NEXT: .LBB0_2: # %if.then
23 ; CHECK-PWR9-NEXT: mflr r0
24 ; CHECK-PWR9-NEXT: .cfi_def_cfa_offset 48
25 ; CHECK-PWR9-NEXT: .cfi_offset lr, 16
26 ; CHECK-PWR9-NEXT: .cfi_offset r30, -16
27 ; CHECK-PWR9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
28 ; CHECK-PWR9-NEXT: stdu r1, -48(r1)
29 ; CHECK-PWR9-NEXT: std r0, 64(r1)
30 ; CHECK-PWR9-NEXT: mr r30, r3
31 ; CHECK-PWR9-NEXT: bl callVoid
32 ; CHECK-PWR9-NEXT: nop
33 ; CHECK-PWR9-NEXT: mr r3, r30
34 ; CHECK-PWR9-NEXT: bl callNonVoid
35 ; CHECK-PWR9-NEXT: nop
36 ; CHECK-PWR9-NEXT: mr r4, r3
37 ; CHECK-PWR9-NEXT: addi r1, r1, 48
38 ; CHECK-PWR9-NEXT: ld r0, 16(r1)
39 ; CHECK-PWR9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
40 ; CHECK-PWR9-NEXT: mtlr r0
41 ; CHECK-PWR9-NEXT: extsw r3, r4
42 ; CHECK-PWR9-NEXT: blr
45 ; CHECK: # %bb.0: # %entry
46 ; CHECK-NEXT: addis r4, r2, a@toc@ha
47 ; CHECK-NEXT: lwa r4, a@toc@l(r4)
48 ; CHECK-NEXT: cmpld r4, r3
49 ; CHECK-NEXT: # implicit-def: $r4
50 ; CHECK-NEXT: beq cr0, .LBB0_2
51 ; CHECK-NEXT: # %bb.1: # %if.end
52 ; CHECK-NEXT: extsw r3, r4
54 ; CHECK-NEXT: .LBB0_2: # %if.then
56 ; CHECK-NEXT: stdu r1, -128(r1)
57 ; CHECK-NEXT: std r0, 144(r1)
58 ; CHECK-NEXT: .cfi_def_cfa_offset 128
59 ; CHECK-NEXT: .cfi_offset lr, 16
60 ; CHECK-NEXT: .cfi_offset r30, -16
61 ; CHECK-NEXT: std r30, 112(r1) # 8-byte Folded Spill
62 ; CHECK-NEXT: mr r30, r3
63 ; CHECK-NEXT: bl callVoid
65 ; CHECK-NEXT: mr r3, r30
66 ; CHECK-NEXT: bl callNonVoid
68 ; CHECK-NEXT: ld r30, 112(r1) # 8-byte Folded Reload
69 ; CHECK-NEXT: mr r4, r3
70 ; CHECK-NEXT: addi r1, r1, 128
71 ; CHECK-NEXT: ld r0, 16(r1)
73 ; CHECK-NEXT: extsw r3, r4
76 %0 = load i32, ptr @a, align 4, !tbaa !2
77 %conv = sext i32 %0 to i64
78 %1 = inttoptr i64 %conv to ptr
79 %cmp = icmp eq ptr %1, %b
80 br i1 %cmp, label %if.then, label %if.end
82 if.then: ; preds = %entry
83 %call = tail call signext i32 @callVoid()
84 %call2 = tail call signext i32 @callNonVoid(ptr %b)
87 if.end: ; preds = %if.then, %entry
88 %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ]
92 declare signext i32 @callVoid(...) local_unnamed_addr
94 declare signext i32 @callNonVoid(ptr) local_unnamed_addr
96 define dso_local signext i32 @test2(ptr %p1) local_unnamed_addr {
97 ; CHECK-PWR9-LABEL: test2:
98 ; CHECK-PWR9: # %bb.0: # %entry
99 ; CHECK-PWR9-NEXT: mflr r0
100 ; CHECK-PWR9-NEXT: .cfi_def_cfa_offset 48
101 ; CHECK-PWR9-NEXT: .cfi_offset lr, 16
102 ; CHECK-PWR9-NEXT: .cfi_offset r30, -16
103 ; CHECK-PWR9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
104 ; CHECK-PWR9-NEXT: stdu r1, -48(r1)
105 ; CHECK-PWR9-NEXT: mr r30, r3
106 ; CHECK-PWR9-NEXT: li r3, 0
107 ; CHECK-PWR9-NEXT: std r0, 64(r1)
108 ; CHECK-PWR9-NEXT: cmpldi r30, 0
109 ; CHECK-PWR9-NEXT: beq cr0, .LBB1_3
110 ; CHECK-PWR9-NEXT: # %bb.1: # %if.end
111 ; CHECK-PWR9-NEXT: addis r4, r2, a@toc@ha
112 ; CHECK-PWR9-NEXT: lwa r4, a@toc@l(r4)
113 ; CHECK-PWR9-NEXT: cmpld r4, r30
114 ; CHECK-PWR9-NEXT: bne cr0, .LBB1_3
115 ; CHECK-PWR9-NEXT: # %bb.2: # %if.then2
116 ; CHECK-PWR9-NEXT: bl callVoid
117 ; CHECK-PWR9-NEXT: nop
118 ; CHECK-PWR9-NEXT: mr r3, r30
119 ; CHECK-PWR9-NEXT: bl callNonVoid
120 ; CHECK-PWR9-NEXT: nop
121 ; CHECK-PWR9-NEXT: .LBB1_3: # %return
122 ; CHECK-PWR9-NEXT: addi r1, r1, 48
123 ; CHECK-PWR9-NEXT: ld r0, 16(r1)
124 ; CHECK-PWR9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
125 ; CHECK-PWR9-NEXT: mtlr r0
126 ; CHECK-PWR9-NEXT: blr
128 ; CHECK-LABEL: test2:
129 ; CHECK: # %bb.0: # %entry
130 ; CHECK-NEXT: mflr r0
131 ; CHECK-NEXT: stdu r1, -128(r1)
132 ; CHECK-NEXT: std r0, 144(r1)
133 ; CHECK-NEXT: .cfi_def_cfa_offset 128
134 ; CHECK-NEXT: .cfi_offset lr, 16
135 ; CHECK-NEXT: .cfi_offset r30, -16
136 ; CHECK-NEXT: std r30, 112(r1) # 8-byte Folded Spill
137 ; CHECK-NEXT: mr r30, r3
138 ; CHECK-NEXT: li r3, 0
139 ; CHECK-NEXT: cmpldi r30, 0
140 ; CHECK-NEXT: beq cr0, .LBB1_3
141 ; CHECK-NEXT: # %bb.1: # %if.end
142 ; CHECK-NEXT: addis r4, r2, a@toc@ha
143 ; CHECK-NEXT: lwa r4, a@toc@l(r4)
144 ; CHECK-NEXT: cmpld r4, r30
145 ; CHECK-NEXT: bne cr0, .LBB1_3
146 ; CHECK-NEXT: # %bb.2: # %if.then2
147 ; CHECK-NEXT: bl callVoid
149 ; CHECK-NEXT: mr r3, r30
150 ; CHECK-NEXT: bl callNonVoid
152 ; CHECK-NEXT: .LBB1_3: # %return
153 ; CHECK-NEXT: ld r30, 112(r1) # 8-byte Folded Reload
154 ; CHECK-NEXT: addi r1, r1, 128
155 ; CHECK-NEXT: ld r0, 16(r1)
156 ; CHECK-NEXT: mtlr r0
159 %tobool = icmp eq ptr %p1, null
160 br i1 %tobool, label %return, label %if.end
162 if.end: ; preds = %entry
163 %0 = load i32, ptr @a, align 4, !tbaa !2
164 %conv = sext i32 %0 to i64
165 %1 = inttoptr i64 %conv to ptr
166 %cmp = icmp eq ptr %1, %p1
167 br i1 %cmp, label %if.then2, label %return
169 if.then2: ; preds = %if.end
170 %call = tail call signext i32 @callVoid()
171 %call3 = tail call signext i32 @callNonVoid(ptr nonnull %p1)
174 return: ; preds = %if.end, %entry, %if.then2
175 %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ]
180 define dso_local ptr @test3(ptr nocapture %p1, i8 zeroext %p2) local_unnamed_addr {
181 ; CHECK-PWR9-LABEL: test3:
182 ; CHECK-PWR9: # %bb.0: # %entry
183 ; CHECK-PWR9-NEXT: mflr r0
184 ; CHECK-PWR9-NEXT: .cfi_def_cfa_offset 64
185 ; CHECK-PWR9-NEXT: .cfi_offset lr, 16
186 ; CHECK-PWR9-NEXT: .cfi_offset r29, -24
187 ; CHECK-PWR9-NEXT: .cfi_offset r30, -16
188 ; CHECK-PWR9-NEXT: std r29, -24(r1) # 8-byte Folded Spill
189 ; CHECK-PWR9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
190 ; CHECK-PWR9-NEXT: stdu r1, -64(r1)
191 ; CHECK-PWR9-NEXT: std r0, 80(r1)
192 ; CHECK-PWR9-NEXT: ld r30, 0(r3)
193 ; CHECK-PWR9-NEXT: cmpldi r30, 0
194 ; CHECK-PWR9-NEXT: beq cr0, .LBB2_2
195 ; CHECK-PWR9-NEXT: # %bb.1: # %land.rhs
196 ; CHECK-PWR9-NEXT: mr r29, r3
197 ; CHECK-PWR9-NEXT: mr r3, r30
198 ; CHECK-PWR9-NEXT: bl bar
199 ; CHECK-PWR9-NEXT: nop
200 ; CHECK-PWR9-NEXT: std r3, 0(r29)
201 ; CHECK-PWR9-NEXT: .LBB2_2: # %land.end
202 ; CHECK-PWR9-NEXT: mr r3, r30
203 ; CHECK-PWR9-NEXT: addi r1, r1, 64
204 ; CHECK-PWR9-NEXT: ld r0, 16(r1)
205 ; CHECK-PWR9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
206 ; CHECK-PWR9-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
207 ; CHECK-PWR9-NEXT: mtlr r0
208 ; CHECK-PWR9-NEXT: blr
210 ; CHECK-LABEL: test3:
211 ; CHECK: # %bb.0: # %entry
212 ; CHECK-NEXT: mflr r0
213 ; CHECK-NEXT: stdu r1, -144(r1)
214 ; CHECK-NEXT: std r0, 160(r1)
215 ; CHECK-NEXT: .cfi_def_cfa_offset 144
216 ; CHECK-NEXT: .cfi_offset lr, 16
217 ; CHECK-NEXT: .cfi_offset r29, -24
218 ; CHECK-NEXT: .cfi_offset r30, -16
219 ; CHECK-NEXT: std r30, 128(r1) # 8-byte Folded Spill
220 ; CHECK-NEXT: ld r30, 0(r3)
221 ; CHECK-NEXT: std r29, 120(r1) # 8-byte Folded Spill
222 ; CHECK-NEXT: cmpldi r30, 0
223 ; CHECK-NEXT: beq cr0, .LBB2_2
224 ; CHECK-NEXT: # %bb.1: # %land.rhs
225 ; CHECK-NEXT: mr r29, r3
226 ; CHECK-NEXT: mr r3, r30
229 ; CHECK-NEXT: std r3, 0(r29)
230 ; CHECK-NEXT: .LBB2_2: # %land.end
231 ; CHECK-NEXT: mr r3, r30
232 ; CHECK-NEXT: ld r30, 128(r1) # 8-byte Folded Reload
233 ; CHECK-NEXT: ld r29, 120(r1) # 8-byte Folded Reload
234 ; CHECK-NEXT: addi r1, r1, 144
235 ; CHECK-NEXT: ld r0, 16(r1)
236 ; CHECK-NEXT: mtlr r0
239 %0 = load ptr, ptr %p1, align 8, !tbaa !6
240 %tobool = icmp eq ptr %0, null
241 br i1 %tobool, label %land.end, label %land.rhs
243 land.rhs: ; preds = %entry
244 %call = tail call ptr @bar(ptr nonnull %0, i8 zeroext %p2)
245 store ptr %call, ptr %p1, align 8, !tbaa !6
248 land.end: ; preds = %entry, %land.rhs
252 declare ptr @bar(ptr, i8 zeroext) local_unnamed_addr
255 !llvm.module.flags = !{!0}
258 !0 = !{i32 1, !"wchar_size", i32 4}
259 !1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"}
260 !2 = !{!3, !3, i64 0}
261 !3 = !{!"int", !4, i64 0}
262 !4 = !{!"omnipotent char", !5, i64 0}
263 !5 = !{!"Simple C/C++ TBAA"}
264 !6 = !{!7, !7, i64 0}
265 !7 = !{!"any pointer", !4, i64 0}