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 = common dso_local local_unnamed_addr global i32 0, align 4
11 define dso_local signext i32 @test1(i32* %b) local_unnamed_addr {
12 ; CHECK-PWR9-LABEL: test1:
13 ; CHECK-PWR9: # %bb.0: # %entry
14 ; CHECK-PWR9-NEXT: mflr r0
15 ; CHECK-PWR9-NEXT: .cfi_def_cfa_offset 48
16 ; CHECK-PWR9-NEXT: .cfi_offset lr, 16
17 ; CHECK-PWR9-NEXT: .cfi_offset r30, -16
18 ; CHECK-PWR9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
19 ; CHECK-PWR9-NEXT: std r0, 16(r1)
20 ; CHECK-PWR9-NEXT: stdu r1, -48(r1)
21 ; CHECK-PWR9-NEXT: mr r30, r3
22 ; CHECK-PWR9-NEXT: addis r3, r2, a@toc@ha
23 ; CHECK-PWR9-NEXT: lwa r3, a@toc@l(r3)
24 ; CHECK-PWR9-NEXT: cmpld r3, r30
25 ; CHECK-PWR9-NEXT: # implicit-def: $r3
26 ; CHECK-PWR9-NEXT: bne cr0, .LBB0_2
27 ; CHECK-PWR9-NEXT: # %bb.1: # %if.then
28 ; CHECK-PWR9-NEXT: bl callVoid
29 ; CHECK-PWR9-NEXT: nop
30 ; CHECK-PWR9-NEXT: mr r3, r30
31 ; CHECK-PWR9-NEXT: bl callNonVoid
32 ; CHECK-PWR9-NEXT: nop
33 ; CHECK-PWR9-NEXT: .LBB0_2: # %if.end
34 ; CHECK-PWR9-NEXT: extsw r3, r3
35 ; CHECK-PWR9-NEXT: addi r1, r1, 48
36 ; CHECK-PWR9-NEXT: ld r0, 16(r1)
37 ; CHECK-PWR9-NEXT: mtlr r0
38 ; CHECK-PWR9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
39 ; CHECK-PWR9-NEXT: blr
42 ; CHECK: # %bb.0: # %entry
44 ; CHECK-NEXT: std r0, 16(r1)
45 ; CHECK-NEXT: stdu r1, -128(r1)
46 ; CHECK-NEXT: .cfi_def_cfa_offset 128
47 ; CHECK-NEXT: .cfi_offset lr, 16
48 ; CHECK-NEXT: .cfi_offset r30, -16
49 ; CHECK-NEXT: addis r4, r2, a@toc@ha
50 ; CHECK-NEXT: std r30, 112(r1) # 8-byte Folded Spill
51 ; CHECK-NEXT: mr r30, r3
52 ; CHECK-NEXT: lwa r4, a@toc@l(r4)
53 ; CHECK-NEXT: cmpld r4, r3
54 ; CHECK-NEXT: # implicit-def: $r3
55 ; CHECK-NEXT: bne cr0, .LBB0_2
56 ; CHECK-NEXT: # %bb.1: # %if.then
57 ; CHECK-NEXT: bl callVoid
59 ; CHECK-NEXT: mr r3, r30
60 ; CHECK-NEXT: bl callNonVoid
62 ; CHECK-NEXT: .LBB0_2: # %if.end
63 ; CHECK-NEXT: ld r30, 112(r1) # 8-byte Folded Reload
64 ; CHECK-NEXT: extsw r3, r3
65 ; CHECK-NEXT: addi r1, r1, 128
66 ; CHECK-NEXT: ld r0, 16(r1)
70 %0 = load i32, i32* @a, align 4, !tbaa !2
71 %conv = sext i32 %0 to i64
72 %1 = inttoptr i64 %conv to i32*
73 %cmp = icmp eq i32* %1, %b
74 br i1 %cmp, label %if.then, label %if.end
76 if.then: ; preds = %entry
77 %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)()
78 %call2 = tail call signext i32 @callNonVoid(i32* %b)
81 if.end: ; preds = %if.then, %entry
82 %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ]
86 declare signext i32 @callVoid(...) local_unnamed_addr
88 declare signext i32 @callNonVoid(i32*) local_unnamed_addr
90 define dso_local signext i32 @test2(i32* %p1) local_unnamed_addr {
91 ; CHECK-PWR9-LABEL: test2:
92 ; CHECK-PWR9: # %bb.0: # %entry
93 ; CHECK-PWR9-NEXT: mflr r0
94 ; CHECK-PWR9-NEXT: .cfi_def_cfa_offset 48
95 ; CHECK-PWR9-NEXT: .cfi_offset lr, 16
96 ; CHECK-PWR9-NEXT: .cfi_offset r30, -16
97 ; CHECK-PWR9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
98 ; CHECK-PWR9-NEXT: std r0, 16(r1)
99 ; CHECK-PWR9-NEXT: stdu r1, -48(r1)
100 ; CHECK-PWR9-NEXT: mr r30, r3
101 ; CHECK-PWR9-NEXT: li r3, 0
102 ; CHECK-PWR9-NEXT: cmpldi r30, 0
103 ; CHECK-PWR9-NEXT: beq cr0, .LBB1_3
104 ; CHECK-PWR9-NEXT: # %bb.1: # %if.end
105 ; CHECK-PWR9-NEXT: addis r4, r2, a@toc@ha
106 ; CHECK-PWR9-NEXT: lwa r4, a@toc@l(r4)
107 ; CHECK-PWR9-NEXT: cmpld r4, r30
108 ; CHECK-PWR9-NEXT: bne cr0, .LBB1_3
109 ; CHECK-PWR9-NEXT: # %bb.2: # %if.then2
110 ; CHECK-PWR9-NEXT: bl callVoid
111 ; CHECK-PWR9-NEXT: nop
112 ; CHECK-PWR9-NEXT: mr r3, r30
113 ; CHECK-PWR9-NEXT: bl callNonVoid
114 ; CHECK-PWR9-NEXT: nop
115 ; CHECK-PWR9-NEXT: .LBB1_3: # %return
116 ; CHECK-PWR9-NEXT: extsw r3, r3
117 ; CHECK-PWR9-NEXT: addi r1, r1, 48
118 ; CHECK-PWR9-NEXT: ld r0, 16(r1)
119 ; CHECK-PWR9-NEXT: mtlr r0
120 ; CHECK-PWR9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
121 ; CHECK-PWR9-NEXT: blr
123 ; CHECK-LABEL: test2:
124 ; CHECK: # %bb.0: # %entry
125 ; CHECK-NEXT: mflr r0
126 ; CHECK-NEXT: std r0, 16(r1)
127 ; CHECK-NEXT: stdu r1, -128(r1)
128 ; CHECK-NEXT: .cfi_def_cfa_offset 128
129 ; CHECK-NEXT: .cfi_offset lr, 16
130 ; CHECK-NEXT: .cfi_offset r30, -16
131 ; CHECK-NEXT: std r30, 112(r1) # 8-byte Folded Spill
132 ; CHECK-NEXT: mr r30, r3
133 ; CHECK-NEXT: cmpldi r3, 0
134 ; CHECK-NEXT: li r3, 0
135 ; CHECK-NEXT: beq cr0, .LBB1_3
136 ; CHECK-NEXT: # %bb.1: # %if.end
137 ; CHECK-NEXT: addis r4, r2, a@toc@ha
138 ; CHECK-NEXT: lwa r4, a@toc@l(r4)
139 ; CHECK-NEXT: cmpld r4, r30
140 ; CHECK-NEXT: bne cr0, .LBB1_3
141 ; CHECK-NEXT: # %bb.2: # %if.then2
142 ; CHECK-NEXT: bl callVoid
144 ; CHECK-NEXT: mr r3, r30
145 ; CHECK-NEXT: bl callNonVoid
147 ; CHECK-NEXT: .LBB1_3: # %return
148 ; CHECK-NEXT: ld r30, 112(r1) # 8-byte Folded Reload
149 ; CHECK-NEXT: extsw r3, r3
150 ; CHECK-NEXT: addi r1, r1, 128
151 ; CHECK-NEXT: ld r0, 16(r1)
152 ; CHECK-NEXT: mtlr r0
155 %tobool = icmp eq i32* %p1, null
156 br i1 %tobool, label %return, label %if.end
158 if.end: ; preds = %entry
159 %0 = load i32, i32* @a, align 4, !tbaa !2
160 %conv = sext i32 %0 to i64
161 %1 = inttoptr i64 %conv to i32*
162 %cmp = icmp eq i32* %1, %p1
163 br i1 %cmp, label %if.then2, label %return
165 if.then2: ; preds = %if.end
166 %call = tail call signext i32 bitcast (i32 (...)* @callVoid to i32 ()*)()
167 %call3 = tail call signext i32 @callNonVoid(i32* nonnull %p1)
170 return: ; preds = %if.end, %entry, %if.then2
171 %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ]
176 define dso_local i8* @test3(i8** nocapture %p1, i8 zeroext %p2) local_unnamed_addr {
177 ; CHECK-PWR9-LABEL: test3:
178 ; CHECK-PWR9: # %bb.0: # %entry
179 ; CHECK-PWR9-NEXT: mflr r0
180 ; CHECK-PWR9-NEXT: .cfi_def_cfa_offset 64
181 ; CHECK-PWR9-NEXT: .cfi_offset lr, 16
182 ; CHECK-PWR9-NEXT: .cfi_offset r29, -24
183 ; CHECK-PWR9-NEXT: .cfi_offset r30, -16
184 ; CHECK-PWR9-NEXT: std r29, -24(r1) # 8-byte Folded Spill
185 ; CHECK-PWR9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
186 ; CHECK-PWR9-NEXT: std r0, 16(r1)
187 ; CHECK-PWR9-NEXT: stdu r1, -64(r1)
188 ; CHECK-PWR9-NEXT: ld r30, 0(r3)
189 ; CHECK-PWR9-NEXT: cmpldi r30, 0
190 ; CHECK-PWR9-NEXT: beq cr0, .LBB2_2
191 ; CHECK-PWR9-NEXT: # %bb.1: # %land.rhs
192 ; CHECK-PWR9-NEXT: mr r29, r3
193 ; CHECK-PWR9-NEXT: clrldi r4, r4, 32
194 ; CHECK-PWR9-NEXT: mr r3, r30
195 ; CHECK-PWR9-NEXT: bl bar
196 ; CHECK-PWR9-NEXT: nop
197 ; CHECK-PWR9-NEXT: std r3, 0(r29)
198 ; CHECK-PWR9-NEXT: .LBB2_2: # %land.end
199 ; CHECK-PWR9-NEXT: mr r3, r30
200 ; CHECK-PWR9-NEXT: addi r1, r1, 64
201 ; CHECK-PWR9-NEXT: ld r0, 16(r1)
202 ; CHECK-PWR9-NEXT: mtlr r0
203 ; CHECK-PWR9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
204 ; CHECK-PWR9-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
205 ; CHECK-PWR9-NEXT: blr
207 ; CHECK-LABEL: test3:
208 ; CHECK: # %bb.0: # %entry
209 ; CHECK-NEXT: mflr r0
210 ; CHECK-NEXT: std r0, 16(r1)
211 ; CHECK-NEXT: stdu r1, -144(r1)
212 ; CHECK-NEXT: .cfi_def_cfa_offset 144
213 ; CHECK-NEXT: .cfi_offset lr, 16
214 ; CHECK-NEXT: .cfi_offset r29, -24
215 ; CHECK-NEXT: .cfi_offset r30, -16
216 ; CHECK-NEXT: std r30, 128(r1) # 8-byte Folded Spill
217 ; CHECK-NEXT: ld r30, 0(r3)
218 ; CHECK-NEXT: std r29, 120(r1) # 8-byte Folded Spill
219 ; CHECK-NEXT: cmpldi r30, 0
220 ; CHECK-NEXT: beq cr0, .LBB2_2
221 ; CHECK-NEXT: # %bb.1: # %land.rhs
222 ; CHECK-NEXT: mr r29, r3
223 ; CHECK-NEXT: clrldi r4, r4, 32
224 ; CHECK-NEXT: mr r3, r30
227 ; CHECK-NEXT: std r3, 0(r29)
228 ; CHECK-NEXT: .LBB2_2: # %land.end
229 ; CHECK-NEXT: mr r3, r30
230 ; CHECK-NEXT: ld r30, 128(r1) # 8-byte Folded Reload
231 ; CHECK-NEXT: ld r29, 120(r1) # 8-byte Folded Reload
232 ; CHECK-NEXT: addi r1, r1, 144
233 ; CHECK-NEXT: ld r0, 16(r1)
234 ; CHECK-NEXT: mtlr r0
237 %0 = load i8*, i8** %p1, align 8, !tbaa !6
238 %tobool = icmp eq i8* %0, null
239 br i1 %tobool, label %land.end, label %land.rhs
241 land.rhs: ; preds = %entry
242 %call = tail call i8* @bar(i8* nonnull %0, i8 zeroext %p2)
243 store i8* %call, i8** %p1, align 8, !tbaa !6
246 land.end: ; preds = %entry, %land.rhs
250 declare i8* @bar(i8*, i8 zeroext) local_unnamed_addr
253 !llvm.module.flags = !{!0}
256 !0 = !{i32 1, !"wchar_size", i32 4}
257 !1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"}
258 !2 = !{!3, !3, i64 0}
259 !3 = !{!"int", !4, i64 0}
260 !4 = !{!"omnipotent char", !5, i64 0}
261 !5 = !{!"Simple C/C++ TBAA"}
262 !6 = !{!7, !7, i64 0}
263 !7 = !{!"any pointer", !4, i64 0}