1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=powerpc-unknown-linux-gnu -O0 < %s | FileCheck %s --check-prefix=PPC
3 ; RUN: llc -mcpu=ppc -mtriple=powerpc64-unknown-linux-gnu -O0 < %s | FileCheck %s --check-prefix=PPC64
4 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -O0 < %s | FileCheck %s --check-prefix=PPC64LE
6 ; Testing operations in soft-float mode
7 define double @foo() #0 {
9 ; PPC: # %bb.0: # %entry
11 ; PPC-NEXT: stwu 1, -32(1)
12 ; PPC-NEXT: stw 0, 36(1)
13 ; PPC-NEXT: lwz 3, 24(1)
14 ; PPC-NEXT: lwz 4, 28(1)
15 ; PPC-NEXT: lwz 5, 16(1)
16 ; PPC-NEXT: lwz 6, 20(1)
17 ; PPC-NEXT: bl __adddf3
18 ; PPC-NEXT: lwz 0, 36(1)
19 ; PPC-NEXT: addi 1, 1, 32
24 ; PPC64: # %bb.0: # %entry
26 ; PPC64-NEXT: stdu 1, -128(1)
27 ; PPC64-NEXT: std 0, 144(1)
28 ; PPC64-NEXT: ld 3, 120(1)
29 ; PPC64-NEXT: ld 4, 112(1)
30 ; PPC64-NEXT: bl __adddf3
32 ; PPC64-NEXT: addi 1, 1, 128
33 ; PPC64-NEXT: ld 0, 16(1)
38 ; PPC64LE: # %bb.0: # %entry
39 ; PPC64LE-NEXT: mflr 0
40 ; PPC64LE-NEXT: stdu 1, -48(1)
41 ; PPC64LE-NEXT: std 0, 64(1)
42 ; PPC64LE-NEXT: ld 3, 40(1)
43 ; PPC64LE-NEXT: ld 4, 32(1)
44 ; PPC64LE-NEXT: bl __adddf3
46 ; PPC64LE-NEXT: addi 1, 1, 48
47 ; PPC64LE-NEXT: ld 0, 16(1)
48 ; PPC64LE-NEXT: mtlr 0
51 %a = alloca double, align 8
52 %b = alloca double, align 8
53 %0 = load double, ptr %a, align 8
54 %1 = load double, ptr %b, align 8
55 %add = fadd double %0, %1
59 define double @foo1() #0 {
61 ; PPC: # %bb.0: # %entry
63 ; PPC-NEXT: stwu 1, -32(1)
64 ; PPC-NEXT: stw 0, 36(1)
65 ; PPC-NEXT: lwz 3, 24(1)
66 ; PPC-NEXT: lwz 4, 28(1)
67 ; PPC-NEXT: lwz 5, 16(1)
68 ; PPC-NEXT: lwz 6, 20(1)
69 ; PPC-NEXT: bl __muldf3
70 ; PPC-NEXT: lwz 0, 36(1)
71 ; PPC-NEXT: addi 1, 1, 32
76 ; PPC64: # %bb.0: # %entry
78 ; PPC64-NEXT: stdu 1, -128(1)
79 ; PPC64-NEXT: std 0, 144(1)
80 ; PPC64-NEXT: ld 3, 120(1)
81 ; PPC64-NEXT: ld 4, 112(1)
82 ; PPC64-NEXT: bl __muldf3
84 ; PPC64-NEXT: addi 1, 1, 128
85 ; PPC64-NEXT: ld 0, 16(1)
89 ; PPC64LE-LABEL: foo1:
90 ; PPC64LE: # %bb.0: # %entry
91 ; PPC64LE-NEXT: mflr 0
92 ; PPC64LE-NEXT: stdu 1, -48(1)
93 ; PPC64LE-NEXT: std 0, 64(1)
94 ; PPC64LE-NEXT: ld 3, 40(1)
95 ; PPC64LE-NEXT: ld 4, 32(1)
96 ; PPC64LE-NEXT: bl __muldf3
98 ; PPC64LE-NEXT: addi 1, 1, 48
99 ; PPC64LE-NEXT: ld 0, 16(1)
100 ; PPC64LE-NEXT: mtlr 0
103 %a = alloca double, align 8
104 %b = alloca double, align 8
105 %0 = load double, ptr %a, align 8
106 %1 = load double, ptr %b, align 8
107 %mul = fmul double %0, %1
111 define double @foo2() #0 {
113 ; PPC: # %bb.0: # %entry
115 ; PPC-NEXT: stwu 1, -32(1)
116 ; PPC-NEXT: stw 0, 36(1)
117 ; PPC-NEXT: lwz 3, 24(1)
118 ; PPC-NEXT: lwz 4, 28(1)
119 ; PPC-NEXT: lwz 5, 16(1)
120 ; PPC-NEXT: lwz 6, 20(1)
121 ; PPC-NEXT: bl __subdf3
122 ; PPC-NEXT: lwz 0, 36(1)
123 ; PPC-NEXT: addi 1, 1, 32
128 ; PPC64: # %bb.0: # %entry
130 ; PPC64-NEXT: stdu 1, -128(1)
131 ; PPC64-NEXT: std 0, 144(1)
132 ; PPC64-NEXT: ld 3, 120(1)
133 ; PPC64-NEXT: ld 4, 112(1)
134 ; PPC64-NEXT: bl __subdf3
136 ; PPC64-NEXT: addi 1, 1, 128
137 ; PPC64-NEXT: ld 0, 16(1)
141 ; PPC64LE-LABEL: foo2:
142 ; PPC64LE: # %bb.0: # %entry
143 ; PPC64LE-NEXT: mflr 0
144 ; PPC64LE-NEXT: stdu 1, -48(1)
145 ; PPC64LE-NEXT: std 0, 64(1)
146 ; PPC64LE-NEXT: ld 3, 40(1)
147 ; PPC64LE-NEXT: ld 4, 32(1)
148 ; PPC64LE-NEXT: bl __subdf3
150 ; PPC64LE-NEXT: addi 1, 1, 48
151 ; PPC64LE-NEXT: ld 0, 16(1)
152 ; PPC64LE-NEXT: mtlr 0
155 %a = alloca double, align 8
156 %b = alloca double, align 8
157 %0 = load double, ptr %a, align 8
158 %1 = load double, ptr %b, align 8
159 %sub = fsub double %0, %1
163 define double @foo3() #0 {
165 ; PPC: # %bb.0: # %entry
167 ; PPC-NEXT: stwu 1, -32(1)
168 ; PPC-NEXT: stw 0, 36(1)
169 ; PPC-NEXT: lwz 3, 24(1)
170 ; PPC-NEXT: lwz 4, 28(1)
171 ; PPC-NEXT: lwz 5, 16(1)
172 ; PPC-NEXT: lwz 6, 20(1)
173 ; PPC-NEXT: bl __divdf3
174 ; PPC-NEXT: lwz 0, 36(1)
175 ; PPC-NEXT: addi 1, 1, 32
180 ; PPC64: # %bb.0: # %entry
182 ; PPC64-NEXT: stdu 1, -128(1)
183 ; PPC64-NEXT: std 0, 144(1)
184 ; PPC64-NEXT: ld 3, 120(1)
185 ; PPC64-NEXT: ld 4, 112(1)
186 ; PPC64-NEXT: bl __divdf3
188 ; PPC64-NEXT: addi 1, 1, 128
189 ; PPC64-NEXT: ld 0, 16(1)
193 ; PPC64LE-LABEL: foo3:
194 ; PPC64LE: # %bb.0: # %entry
195 ; PPC64LE-NEXT: mflr 0
196 ; PPC64LE-NEXT: stdu 1, -48(1)
197 ; PPC64LE-NEXT: std 0, 64(1)
198 ; PPC64LE-NEXT: ld 3, 40(1)
199 ; PPC64LE-NEXT: ld 4, 32(1)
200 ; PPC64LE-NEXT: bl __divdf3
202 ; PPC64LE-NEXT: addi 1, 1, 48
203 ; PPC64LE-NEXT: ld 0, 16(1)
204 ; PPC64LE-NEXT: mtlr 0
207 %a = alloca double, align 8
208 %b = alloca double, align 8
209 %0 = load double, ptr %a, align 8
210 %1 = load double, ptr %b, align 8
211 %div = fdiv double %0, %1
215 ; Function Attrs: noinline nounwind optnone uwtable
216 define dso_local zeroext i32 @func(double noundef %0, double noundef %1) #0 {
220 ; PPC-NEXT: stwu 1, -32(1)
221 ; PPC-NEXT: stw 0, 36(1)
222 ; PPC-NEXT: # kill: def $r7 killed $r6
223 ; PPC-NEXT: # kill: def $r7 killed $r5
224 ; PPC-NEXT: # kill: def $r7 killed $r4
225 ; PPC-NEXT: # kill: def $r7 killed $r3
226 ; PPC-NEXT: stw 4, 28(1)
227 ; PPC-NEXT: stw 3, 24(1)
228 ; PPC-NEXT: stw 6, 20(1)
229 ; PPC-NEXT: stw 5, 16(1)
230 ; PPC-NEXT: lwz 3, 24(1)
231 ; PPC-NEXT: stw 3, 8(1) # 4-byte Folded Spill
232 ; PPC-NEXT: lwz 3, 28(1)
233 ; PPC-NEXT: stw 3, 12(1) # 4-byte Folded Spill
234 ; PPC-NEXT: lwz 3, 16(1)
235 ; PPC-NEXT: lwz 4, 20(1)
236 ; PPC-NEXT: lis 5, -15888
238 ; PPC-NEXT: bl __muldf3
240 ; PPC-NEXT: lwz 3, 8(1) # 4-byte Folded Reload
242 ; PPC-NEXT: lwz 4, 12(1) # 4-byte Folded Reload
243 ; PPC-NEXT: bl __adddf3
244 ; PPC-NEXT: bl __fixunsdfsi
245 ; PPC-NEXT: lwz 0, 36(1)
246 ; PPC-NEXT: addi 1, 1, 32
253 ; PPC64-NEXT: stdu 1, -144(1)
254 ; PPC64-NEXT: std 0, 160(1)
255 ; PPC64-NEXT: std 3, 136(1)
256 ; PPC64-NEXT: std 4, 128(1)
257 ; PPC64-NEXT: ld 3, 136(1)
258 ; PPC64-NEXT: std 3, 120(1) # 8-byte Folded Spill
259 ; PPC64-NEXT: ld 3, 128(1)
260 ; PPC64-NEXT: li 4, 3103
261 ; PPC64-NEXT: rldic 4, 4, 52, 0
262 ; PPC64-NEXT: bl __muldf3
264 ; PPC64-NEXT: mr 4, 3
265 ; PPC64-NEXT: ld 3, 120(1) # 8-byte Folded Reload
266 ; PPC64-NEXT: bl __adddf3
268 ; PPC64-NEXT: bl __fixunsdfsi
270 ; PPC64-NEXT: # kill: def $r3 killed $r3 killed $x3
271 ; PPC64-NEXT: clrldi 3, 3, 32
272 ; PPC64-NEXT: addi 1, 1, 144
273 ; PPC64-NEXT: ld 0, 16(1)
277 ; PPC64LE-LABEL: func:
279 ; PPC64LE-NEXT: mflr 0
280 ; PPC64LE-NEXT: stdu 1, -64(1)
281 ; PPC64LE-NEXT: std 0, 80(1)
282 ; PPC64LE-NEXT: std 3, 56(1)
283 ; PPC64LE-NEXT: std 4, 48(1)
284 ; PPC64LE-NEXT: ld 3, 56(1)
285 ; PPC64LE-NEXT: std 3, 40(1) # 8-byte Folded Spill
286 ; PPC64LE-NEXT: ld 3, 48(1)
287 ; PPC64LE-NEXT: li 4, 3103
288 ; PPC64LE-NEXT: rldic 4, 4, 52, 0
289 ; PPC64LE-NEXT: bl __muldf3
291 ; PPC64LE-NEXT: mr 4, 3
292 ; PPC64LE-NEXT: ld 3, 40(1) # 8-byte Folded Reload
293 ; PPC64LE-NEXT: bl __adddf3
295 ; PPC64LE-NEXT: bl __fixunsdfsi
297 ; PPC64LE-NEXT: # kill: def $r3 killed $r3 killed $x3
298 ; PPC64LE-NEXT: clrldi 3, 3, 32
299 ; PPC64LE-NEXT: addi 1, 1, 64
300 ; PPC64LE-NEXT: ld 0, 16(1)
301 ; PPC64LE-NEXT: mtlr 0
303 %3 = alloca double, align 8
304 %4 = alloca double, align 8
305 store double %0, ptr %3, align 8
306 store double %1, ptr %4, align 8
307 %5 = load double, ptr %3, align 8
308 %6 = load double, ptr %4, align 8
310 %8 = call double @llvm.fmuladd.f64(double %7, double 0x41F0000000000000, double %5)
311 %9 = fptoui double %8 to i32
315 ; To check ppc_fp128 soften without crash
316 define zeroext i1 @ppcf128_soften(ppc_fp128 %a) #0 {
317 ; PPC-LABEL: ppcf128_soften:
318 ; PPC: # %bb.0: # %entry
319 ; PPC-NEXT: stwu 1, -16(1)
320 ; PPC-NEXT: stw 5, 8(1) # 4-byte Folded Spill
322 ; PPC-NEXT: lwz 4, 8(1) # 4-byte Folded Reload
323 ; PPC-NEXT: stw 5, 12(1) # 4-byte Folded Spill
325 ; PPC-NEXT: lwz 3, 12(1) # 4-byte Folded Reload
326 ; PPC-NEXT: # kill: def $r4 killed $r3
327 ; PPC-NEXT: # kill: def $r4 killed $r5
328 ; PPC-NEXT: xoris 4, 5, 65520
329 ; PPC-NEXT: or 4, 3, 4
330 ; PPC-NEXT: cntlzw 4, 4
331 ; PPC-NEXT: clrlwi 5, 5, 1
332 ; PPC-NEXT: or 3, 3, 5
333 ; PPC-NEXT: cntlzw 3, 3
334 ; PPC-NEXT: or 3, 3, 4
335 ; PPC-NEXT: srwi 3, 3, 5
336 ; PPC-NEXT: addi 1, 1, 16
339 ; PPC64-LABEL: ppcf128_soften:
340 ; PPC64: # %bb.0: # %entry
341 ; PPC64-NEXT: li 4, 4095
342 ; PPC64-NEXT: rldic 4, 4, 52, 0
343 ; PPC64-NEXT: cmpld 7, 3, 4
344 ; PPC64-NEXT: mfcr 4 # cr7
345 ; PPC64-NEXT: rlwinm 4, 4, 31, 31, 31
346 ; PPC64-NEXT: clrldi 3, 3, 1
347 ; PPC64-NEXT: cmpldi 7, 3, 0
348 ; PPC64-NEXT: mfcr 3 # cr7
349 ; PPC64-NEXT: rlwinm 3, 3, 31, 31, 31
350 ; PPC64-NEXT: or 4, 3, 4
351 ; PPC64-NEXT: # implicit-def: $x3
352 ; PPC64-NEXT: mr 3, 4
353 ; PPC64-NEXT: clrldi 3, 3, 32
356 ; PPC64LE-LABEL: ppcf128_soften:
357 ; PPC64LE: # %bb.0: # %entry
358 ; PPC64LE-NEXT: li 3, 4095
359 ; PPC64LE-NEXT: rldic 3, 3, 52, 0
360 ; PPC64LE-NEXT: cmpd 4, 3
361 ; PPC64LE-NEXT: crmove 21, 2
362 ; PPC64LE-NEXT: clrldi. 3, 4, 1
363 ; PPC64LE-NEXT: crmove 20, 2
364 ; PPC64LE-NEXT: cror 20, 20, 21
365 ; PPC64LE-NEXT: li 4, 0
366 ; PPC64LE-NEXT: li 3, 1
367 ; PPC64LE-NEXT: isel 3, 3, 4, 20
370 %fpclass = tail call i1 @llvm.is.fpclass.ppcf128(ppc_fp128 %a, i32 100)
374 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
375 declare double @llvm.fmuladd.f64(double, double, double) #1
376 declare i1 @llvm.is.fpclass.ppcf128(ppc_fp128, i32 immarg) #1
378 attributes #0 = {"use-soft-float"="true" nounwind }
379 attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }