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(ptr %ptr) {
22 ; CHECK: sqeb %f0, 0(%r2)
24 %val = load float, ptr %ptr
25 %res = call float @llvm.sqrt.f32(float %val)
29 ; Check the high end of the aligned SQEB range.
30 define float @f3(ptr %base) {
32 ; CHECK: sqeb %f0, 4092(%r2)
34 %ptr = getelementptr float, ptr %base, i64 1023
35 %val = load float, ptr %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(ptr %base) {
44 ; CHECK: aghi %r2, 4096
45 ; CHECK: sqeb %f0, 0(%r2)
47 %ptr = getelementptr float, ptr %base, i64 1024
48 %val = load float, ptr %ptr
49 %res = call float @llvm.sqrt.f32(float %val)
53 ; Check negative displacements, which also need separate address logic.
54 define float @f5(ptr %base) {
57 ; CHECK: sqeb %f0, 0(%r2)
59 %ptr = getelementptr float, ptr %base, i64 -1
60 %val = load float, ptr %ptr
61 %res = call float @llvm.sqrt.f32(float %val)
65 ; Check that SQEB allows indices.
66 define float @f6(ptr %base, i64 %index) {
68 ; CHECK: sllg %r1, %r3, 2
69 ; CHECK: sqeb %f0, 400(%r1,%r2)
71 %ptr1 = getelementptr float, ptr %base, i64 %index
72 %ptr2 = getelementptr float, ptr %ptr1, i64 100
73 %val = load float, ptr %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(ptr %ptr) {
82 ; CHECK-SCALAR: sqeb {{%f[0-9]+}}, 16{{[04]}}(%r15)
84 %val0 = load volatile float, ptr %ptr
85 %val1 = load volatile float, ptr %ptr
86 %val2 = load volatile float, ptr %ptr
87 %val3 = load volatile float, ptr %ptr
88 %val4 = load volatile float, ptr %ptr
89 %val5 = load volatile float, ptr %ptr
90 %val6 = load volatile float, ptr %ptr
91 %val7 = load volatile float, ptr %ptr
92 %val8 = load volatile float, ptr %ptr
93 %val9 = load volatile float, ptr %ptr
94 %val10 = load volatile float, ptr %ptr
95 %val11 = load volatile float, ptr %ptr
96 %val12 = load volatile float, ptr %ptr
97 %val13 = load volatile float, ptr %ptr
98 %val14 = load volatile float, ptr %ptr
99 %val15 = load volatile float, ptr %ptr
100 %val16 = load volatile float, ptr %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, ptr %ptr
121 store volatile float %val1, ptr %ptr
122 store volatile float %val2, ptr %ptr
123 store volatile float %val3, ptr %ptr
124 store volatile float %val4, ptr %ptr
125 store volatile float %val5, ptr %ptr
126 store volatile float %val6, ptr %ptr
127 store volatile float %val7, ptr %ptr
128 store volatile float %val8, ptr %ptr
129 store volatile float %val9, ptr %ptr
130 store volatile float %val10, ptr %ptr
131 store volatile float %val11, ptr %ptr
132 store volatile float %val12, ptr %ptr
133 store volatile float %val13, ptr %ptr
134 store volatile float %val14, ptr %ptr
135 store volatile float %val15, ptr %ptr
136 store volatile float %val16, ptr %ptr
138 store volatile float %sqrt0, ptr %ptr
139 store volatile float %sqrt1, ptr %ptr
140 store volatile float %sqrt2, ptr %ptr
141 store volatile float %sqrt3, ptr %ptr
142 store volatile float %sqrt4, ptr %ptr
143 store volatile float %sqrt5, ptr %ptr
144 store volatile float %sqrt6, ptr %ptr
145 store volatile float %sqrt7, ptr %ptr
146 store volatile float %sqrt8, ptr %ptr
147 store volatile float %sqrt9, ptr %ptr
148 store volatile float %sqrt10, ptr %ptr
149 store volatile float %sqrt11, ptr %ptr
150 store volatile float %sqrt12, ptr %ptr
151 store volatile float %sqrt13, ptr %ptr
152 store volatile float %sqrt14, ptr %ptr
153 store volatile float %sqrt15, ptr %ptr
154 store volatile float %sqrt16, ptr %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)