1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -O3 < %s \
3 ; RUN: -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 | FileCheck %s
4 ; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -O3 < %s \
5 ; RUN: -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 | FileCheck %s --check-prefix=CHECK-P8
6 ; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -ppc-fma-rp-factor=0.0 -O3 < %s \
7 ; RUN: -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 | FileCheck %s --check-prefix=CHECK-FMA
9 @global_val = external global float, align 4
11 define float @foo_float(float %0, float %1, float %2, float %3) {
12 ; CHECK-LABEL: foo_float:
14 ; CHECK-NEXT: addis r3, r2, .LCPI0_0@toc@ha
15 ; CHECK-NEXT: xsmulsp f1, f2, f1
16 ; CHECK-NEXT: xssubsp f0, f3, f4
17 ; CHECK-NEXT: lfs f2, .LCPI0_0@toc@l(r3)
18 ; CHECK-NEXT: xsmaddasp f1, f0, f2
21 ; CHECK-P8-LABEL: foo_float:
23 ; CHECK-P8-NEXT: addis r3, r2, .LCPI0_0@toc@ha
24 ; CHECK-P8-NEXT: xsmulsp f1, f2, f1
25 ; CHECK-P8-NEXT: xssubsp f0, f3, f4
26 ; CHECK-P8-NEXT: lfs f2, .LCPI0_0@toc@l(r3)
27 ; CHECK-P8-NEXT: xsmaddasp f1, f0, f2
30 ; CHECK-FMA-LABEL: foo_float:
32 ; CHECK-FMA-NEXT: addis r3, r2, .LCPI0_0@toc@ha
33 ; CHECK-FMA-NEXT: xsmulsp f1, f2, f1
34 ; CHECK-FMA-NEXT: lfs f0, .LCPI0_0@toc@l(r3)
35 ; CHECK-FMA-NEXT: addis r3, r2, .LCPI0_1@toc@ha
36 ; CHECK-FMA-NEXT: lfs f2, .LCPI0_1@toc@l(r3)
37 ; CHECK-FMA-NEXT: xsmaddasp f1, f4, f2
38 ; CHECK-FMA-NEXT: xsmaddasp f1, f3, f0
40 %5 = fmul contract reassoc nsz float %1, %0
41 %6 = fsub contract reassoc nsz float %2, %3
42 %7 = fmul contract reassoc nsz float %6, 0x3DB2533FE0000000
43 %8 = fadd contract reassoc nsz float %7, %5
47 define double @foo_double(double %0, double %1, double %2, double %3) {
48 ; CHECK-LABEL: foo_double:
50 ; CHECK-NEXT: xsmuldp f1, f2, f1
51 ; CHECK-NEXT: xssubdp f0, f3, f4
52 ; CHECK-NEXT: addis r3, r2, .LCPI1_0@toc@ha
53 ; CHECK-NEXT: lfd f2, .LCPI1_0@toc@l(r3)
54 ; CHECK-NEXT: xsmaddadp f1, f0, f2
57 ; CHECK-P8-LABEL: foo_double:
59 ; CHECK-P8-NEXT: addis r3, r2, .LCPI1_0@toc@ha
60 ; CHECK-P8-NEXT: xsmuldp f1, f2, f1
61 ; CHECK-P8-NEXT: xssubdp f0, f3, f4
62 ; CHECK-P8-NEXT: lfd f2, .LCPI1_0@toc@l(r3)
63 ; CHECK-P8-NEXT: xsmaddadp f1, f0, f2
66 ; CHECK-FMA-LABEL: foo_double:
68 ; CHECK-FMA-NEXT: addis r3, r2, .LCPI1_0@toc@ha
69 ; CHECK-FMA-NEXT: xsmuldp f1, f2, f1
70 ; CHECK-FMA-NEXT: lfd f0, .LCPI1_0@toc@l(r3)
71 ; CHECK-FMA-NEXT: addis r3, r2, .LCPI1_1@toc@ha
72 ; CHECK-FMA-NEXT: lfd f2, .LCPI1_1@toc@l(r3)
73 ; CHECK-FMA-NEXT: xsmaddadp f1, f4, f2
74 ; CHECK-FMA-NEXT: xsmaddadp f1, f3, f0
76 %5 = fmul contract reassoc nsz double %1, %0
77 %6 = fsub contract reassoc nsz double %2, %3
78 %7 = fmul contract reassoc nsz double %6, 0x3DB2533FE68CADDE
79 %8 = fadd contract reassoc nsz double %7, %5
83 define float @foo_float_reuse_const(float %0, float %1, float %2, float %3) {
84 ; CHECK-LABEL: foo_float_reuse_const:
86 ; CHECK-NEXT: addis r3, r2, .LCPI2_0@toc@ha
87 ; CHECK-NEXT: xsmulsp f1, f2, f1
88 ; CHECK-NEXT: xssubsp f0, f3, f4
89 ; CHECK-NEXT: lfs f3, .LCPI2_0@toc@l(r3)
90 ; CHECK-NEXT: addis r3, r2, .LCPI2_1@toc@ha
91 ; CHECK-NEXT: xsmaddasp f1, f0, f3
92 ; CHECK-NEXT: lfs f0, .LCPI2_1@toc@l(r3)
93 ; CHECK-NEXT: addis r3, r2, .LC0@toc@ha
94 ; CHECK-NEXT: ld r3, .LC0@toc@l(r3)
95 ; CHECK-NEXT: xsmulsp f0, f2, f0
96 ; CHECK-NEXT: stfs f0, 0(r3)
99 ; CHECK-P8-LABEL: foo_float_reuse_const:
101 ; CHECK-P8-NEXT: addis r3, r2, .LCPI2_0@toc@ha
102 ; CHECK-P8-NEXT: xsmulsp f1, f2, f1
103 ; CHECK-P8-NEXT: xssubsp f0, f3, f4
104 ; CHECK-P8-NEXT: lfs f3, .LCPI2_0@toc@l(r3)
105 ; CHECK-P8-NEXT: addis r3, r2, .LCPI2_1@toc@ha
106 ; CHECK-P8-NEXT: xsmaddasp f1, f0, f3
107 ; CHECK-P8-NEXT: lfs f0, .LCPI2_1@toc@l(r3)
108 ; CHECK-P8-NEXT: addis r3, r2, .LC0@toc@ha
109 ; CHECK-P8-NEXT: ld r3, .LC0@toc@l(r3)
110 ; CHECK-P8-NEXT: xsmulsp f0, f2, f0
111 ; CHECK-P8-NEXT: stfs f0, 0(r3)
114 ; CHECK-FMA-LABEL: foo_float_reuse_const:
115 ; CHECK-FMA: # %bb.0:
116 ; CHECK-FMA-NEXT: addis r3, r2, .LCPI2_0@toc@ha
117 ; CHECK-FMA-NEXT: xsmulsp f1, f2, f1
118 ; CHECK-FMA-NEXT: lfs f0, .LCPI2_0@toc@l(r3)
119 ; CHECK-FMA-NEXT: addis r3, r2, .LCPI2_1@toc@ha
120 ; CHECK-FMA-NEXT: lfs f5, .LCPI2_1@toc@l(r3)
121 ; CHECK-FMA-NEXT: addis r3, r2, .LC0@toc@ha
122 ; CHECK-FMA-NEXT: ld r3, .LC0@toc@l(r3)
123 ; CHECK-FMA-NEXT: xsmaddasp f1, f4, f5
124 ; CHECK-FMA-NEXT: xsmaddasp f1, f3, f0
125 ; CHECK-FMA-NEXT: xsmulsp f0, f2, f5
126 ; CHECK-FMA-NEXT: stfs f0, 0(r3)
127 ; CHECK-FMA-NEXT: blr
128 %5 = fmul contract reassoc nsz float %1, %0
129 %6 = fsub contract reassoc nsz float %2, %3
130 %7 = fmul contract reassoc nsz float %6, 0x3DB2533FE0000000
131 %8 = fadd contract reassoc nsz float %7, %5
132 %9 = fmul contract reassoc nsz float %1, 0xBDB2533FE0000000
133 store float %9, ptr @global_val, align 4