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