1 ; Test 64-bit square root.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 \
4 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-SCALAR %s
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
7 declare double @llvm.sqrt.f64(double %f)
8 declare double @sqrt(double)
10 ; Check register square root.
11 define double @f1(double %val) {
13 ; CHECK: sqdbr %f0, %f0
15 %res = call double @llvm.sqrt.f64(double %val)
19 ; Check the low end of the SQDB range.
20 define double @f2(double *%ptr) {
22 ; CHECK: sqdb %f0, 0(%r2)
24 %val = load double, double *%ptr
25 %res = call double @llvm.sqrt.f64(double %val)
29 ; Check the high end of the aligned SQDB range.
30 define double @f3(double *%base) {
32 ; CHECK: sqdb %f0, 4088(%r2)
34 %ptr = getelementptr double, double *%base, i64 511
35 %val = load double, double *%ptr
36 %res = call double @llvm.sqrt.f64(double %val)
40 ; Check the next doubleword up, which needs separate address logic.
41 ; Other sequences besides this one would be OK.
42 define double @f4(double *%base) {
44 ; CHECK: aghi %r2, 4096
45 ; CHECK: sqdb %f0, 0(%r2)
47 %ptr = getelementptr double, double *%base, i64 512
48 %val = load double, double *%ptr
49 %res = call double @llvm.sqrt.f64(double %val)
53 ; Check negative displacements, which also need separate address logic.
54 define double @f5(double *%base) {
57 ; CHECK: sqdb %f0, 0(%r2)
59 %ptr = getelementptr double, double *%base, i64 -1
60 %val = load double, double *%ptr
61 %res = call double @llvm.sqrt.f64(double %val)
65 ; Check that SQDB allows indices.
66 define double @f6(double *%base, i64 %index) {
68 ; CHECK: sllg %r1, %r3, 3
69 ; CHECK: sqdb %f0, 800(%r1,%r2)
71 %ptr1 = getelementptr double, double *%base, i64 %index
72 %ptr2 = getelementptr double, double *%ptr1, i64 100
73 %val = load double, double *%ptr2
74 %res = call double @llvm.sqrt.f64(double %val)
78 ; Test a case where we spill the source of at least one SQDBR. We want
79 ; to use SQDB if possible.
80 define void @f7(double *%ptr) {
82 ; CHECK-SCALAR: sqdb {{%f[0-9]+}}, 160(%r15)
84 %val0 = load volatile double, double *%ptr
85 %val1 = load volatile double, double *%ptr
86 %val2 = load volatile double, double *%ptr
87 %val3 = load volatile double, double *%ptr
88 %val4 = load volatile double, double *%ptr
89 %val5 = load volatile double, double *%ptr
90 %val6 = load volatile double, double *%ptr
91 %val7 = load volatile double, double *%ptr
92 %val8 = load volatile double, double *%ptr
93 %val9 = load volatile double, double *%ptr
94 %val10 = load volatile double, double *%ptr
95 %val11 = load volatile double, double *%ptr
96 %val12 = load volatile double, double *%ptr
97 %val13 = load volatile double, double *%ptr
98 %val14 = load volatile double, double *%ptr
99 %val15 = load volatile double, double *%ptr
100 %val16 = load volatile double, double *%ptr
102 %sqrt0 = call double @llvm.sqrt.f64(double %val0)
103 %sqrt1 = call double @llvm.sqrt.f64(double %val1)
104 %sqrt2 = call double @llvm.sqrt.f64(double %val2)
105 %sqrt3 = call double @llvm.sqrt.f64(double %val3)
106 %sqrt4 = call double @llvm.sqrt.f64(double %val4)
107 %sqrt5 = call double @llvm.sqrt.f64(double %val5)
108 %sqrt6 = call double @llvm.sqrt.f64(double %val6)
109 %sqrt7 = call double @llvm.sqrt.f64(double %val7)
110 %sqrt8 = call double @llvm.sqrt.f64(double %val8)
111 %sqrt9 = call double @llvm.sqrt.f64(double %val9)
112 %sqrt10 = call double @llvm.sqrt.f64(double %val10)
113 %sqrt11 = call double @llvm.sqrt.f64(double %val11)
114 %sqrt12 = call double @llvm.sqrt.f64(double %val12)
115 %sqrt13 = call double @llvm.sqrt.f64(double %val13)
116 %sqrt14 = call double @llvm.sqrt.f64(double %val14)
117 %sqrt15 = call double @llvm.sqrt.f64(double %val15)
118 %sqrt16 = call double @llvm.sqrt.f64(double %val16)
120 store volatile double %val0, double *%ptr
121 store volatile double %val1, double *%ptr
122 store volatile double %val2, double *%ptr
123 store volatile double %val3, double *%ptr
124 store volatile double %val4, double *%ptr
125 store volatile double %val5, double *%ptr
126 store volatile double %val6, double *%ptr
127 store volatile double %val7, double *%ptr
128 store volatile double %val8, double *%ptr
129 store volatile double %val9, double *%ptr
130 store volatile double %val10, double *%ptr
131 store volatile double %val11, double *%ptr
132 store volatile double %val12, double *%ptr
133 store volatile double %val13, double *%ptr
134 store volatile double %val14, double *%ptr
135 store volatile double %val15, double *%ptr
136 store volatile double %val16, double *%ptr
138 store volatile double %sqrt0, double *%ptr
139 store volatile double %sqrt1, double *%ptr
140 store volatile double %sqrt2, double *%ptr
141 store volatile double %sqrt3, double *%ptr
142 store volatile double %sqrt4, double *%ptr
143 store volatile double %sqrt5, double *%ptr
144 store volatile double %sqrt6, double *%ptr
145 store volatile double %sqrt7, double *%ptr
146 store volatile double %sqrt8, double *%ptr
147 store volatile double %sqrt9, double *%ptr
148 store volatile double %sqrt10, double *%ptr
149 store volatile double %sqrt11, double *%ptr
150 store volatile double %sqrt12, double *%ptr
151 store volatile double %sqrt13, double *%ptr
152 store volatile double %sqrt14, double *%ptr
153 store volatile double %sqrt15, double *%ptr
154 store volatile double %sqrt16, double *%ptr
159 ; Check that a call to the normal sqrt function is lowered.
160 define double @f8(double %dummy, double %val) {
162 ; CHECK: sqdbr %f0, %f2
163 ; CHECK: cdbr %f0, %f0
165 ; CHECK: ldr %f0, %f2
167 %res = tail call double @sqrt(double %val)