• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test 64-bit square root.
2;
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
6
7declare double @llvm.sqrt.f64(double %f)
8declare double @sqrt(double)
9
10; Check register square root.
11define double @f1(double %val) {
12; CHECK-LABEL: f1:
13; CHECK: sqdbr %f0, %f0
14; CHECK: br %r14
15  %res = call double @llvm.sqrt.f64(double %val)
16  ret double %res
17}
18
19; Check the low end of the SQDB range.
20define double @f2(double *%ptr) {
21; CHECK-LABEL: f2:
22; CHECK: sqdb %f0, 0(%r2)
23; CHECK: br %r14
24  %val = load double , double *%ptr
25  %res = call double @llvm.sqrt.f64(double %val)
26  ret double %res
27}
28
29; Check the high end of the aligned SQDB range.
30define double @f3(double *%base) {
31; CHECK-LABEL: f3:
32; CHECK: sqdb %f0, 4088(%r2)
33; CHECK: br %r14
34  %ptr = getelementptr double, double *%base, i64 511
35  %val = load double , double *%ptr
36  %res = call double @llvm.sqrt.f64(double %val)
37  ret double %res
38}
39
40; Check the next doubleword up, which needs separate address logic.
41; Other sequences besides this one would be OK.
42define double @f4(double *%base) {
43; CHECK-LABEL: f4:
44; CHECK: aghi %r2, 4096
45; CHECK: sqdb %f0, 0(%r2)
46; CHECK: br %r14
47  %ptr = getelementptr double, double *%base, i64 512
48  %val = load double , double *%ptr
49  %res = call double @llvm.sqrt.f64(double %val)
50  ret double %res
51}
52
53; Check negative displacements, which also need separate address logic.
54define double @f5(double *%base) {
55; CHECK-LABEL: f5:
56; CHECK: aghi %r2, -8
57; CHECK: sqdb %f0, 0(%r2)
58; CHECK: br %r14
59  %ptr = getelementptr double, double *%base, i64 -1
60  %val = load double , double *%ptr
61  %res = call double @llvm.sqrt.f64(double %val)
62  ret double %res
63}
64
65; Check that SQDB allows indices.
66define double @f6(double *%base, i64 %index) {
67; CHECK-LABEL: f6:
68; CHECK: sllg %r1, %r3, 3
69; CHECK: sqdb %f0, 800(%r1,%r2)
70; CHECK: br %r14
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)
75  ret double %res
76}
77
78; Test a case where we spill the source of at least one SQDBR.  We want
79; to use SQDB if possible.
80define void @f7(double *%ptr) {
81; CHECK-LABEL: f7:
82; CHECK-SCALAR: sqdb {{%f[0-9]+}}, 160(%r15)
83; CHECK: br %r14
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
101
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)
119
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
137
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
155
156  ret void
157}
158
159; Check that a call to the normal sqrt function is lowered.
160define double @f8(double %dummy, double %val) {
161; CHECK-LABEL: f8:
162; CHECK: sqdbr %f0, %f2
163; CHECK: cdbr %f0, %f0
164; CHECK: jo [[LABEL:\.L.*]]
165; CHECK: br %r14
166; CHECK: [[LABEL]]:
167; CHECK: ldr %f0, %f2
168; CHECK: jg sqrt@PLT
169  %res = tail call double @sqrt(double %val)
170  ret double %res
171}
172