sqrt-fastmath-tune.ll
11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-- -mcpu=nehalem | FileCheck %s --check-prefixes=NHM
; RUN: llc < %s -mtriple=x86_64-- -mcpu=sandybridge | FileCheck %s --check-prefixes=FAST-SCALAR,SNB
; RUN: llc < %s -mtriple=x86_64-- -mcpu=broadwell | FileCheck %s --check-prefixes=FAST-SCALAR,BDW
; RUN: llc < %s -mtriple=x86_64-- -mcpu=skylake | FileCheck %s --check-prefixes=FAST-SCALAR,SKL
define float @f32_no_daz(float %f) #0 {
; NHM-LABEL: f32_no_daz:
; NHM: # %bb.0:
; NHM-NEXT: rsqrtss %xmm0, %xmm1
; NHM-NEXT: movaps %xmm0, %xmm2
; NHM-NEXT: mulss %xmm1, %xmm2
; NHM-NEXT: movss {{.*#+}} xmm3 = mem[0],zero,zero,zero
; NHM-NEXT: mulss %xmm2, %xmm3
; NHM-NEXT: mulss %xmm1, %xmm2
; NHM-NEXT: addss {{.*}}(%rip), %xmm2
; NHM-NEXT: andps {{.*}}(%rip), %xmm0
; NHM-NEXT: mulss %xmm3, %xmm2
; NHM-NEXT: cmpltss {{.*}}(%rip), %xmm0
; NHM-NEXT: andnps %xmm2, %xmm0
; NHM-NEXT: retq
;
; FAST-SCALAR-LABEL: f32_no_daz:
; FAST-SCALAR: # %bb.0:
; FAST-SCALAR-NEXT: vsqrtss %xmm0, %xmm0, %xmm0
; FAST-SCALAR-NEXT: retq
%call = tail call fast float @llvm.sqrt.f32(float %f) #2
ret float %call
}
define <4 x float> @v4f32_no_daz(<4 x float> %f) #0 {
; NHM-LABEL: v4f32_no_daz:
; NHM: # %bb.0:
; NHM-NEXT: rsqrtps %xmm0, %xmm2
; NHM-NEXT: movaps %xmm0, %xmm1
; NHM-NEXT: mulps %xmm2, %xmm1
; NHM-NEXT: movaps {{.*#+}} xmm3 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; NHM-NEXT: mulps %xmm1, %xmm3
; NHM-NEXT: mulps %xmm2, %xmm1
; NHM-NEXT: addps {{.*}}(%rip), %xmm1
; NHM-NEXT: andps {{.*}}(%rip), %xmm0
; NHM-NEXT: mulps %xmm3, %xmm1
; NHM-NEXT: movaps {{.*#+}} xmm2 = [1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
; NHM-NEXT: cmpleps %xmm0, %xmm2
; NHM-NEXT: andps %xmm2, %xmm1
; NHM-NEXT: movaps %xmm1, %xmm0
; NHM-NEXT: retq
;
; SNB-LABEL: v4f32_no_daz:
; SNB: # %bb.0:
; SNB-NEXT: vrsqrtps %xmm0, %xmm1
; SNB-NEXT: vmulps %xmm1, %xmm0, %xmm2
; SNB-NEXT: vmulps {{.*}}(%rip), %xmm2, %xmm3
; SNB-NEXT: vmulps %xmm1, %xmm2, %xmm1
; SNB-NEXT: vaddps {{.*}}(%rip), %xmm1, %xmm1
; SNB-NEXT: vandps {{.*}}(%rip), %xmm0, %xmm0
; SNB-NEXT: vmulps %xmm1, %xmm3, %xmm1
; SNB-NEXT: vmovaps {{.*#+}} xmm2 = [1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
; SNB-NEXT: vcmpleps %xmm0, %xmm2, %xmm0
; SNB-NEXT: vandps %xmm1, %xmm0, %xmm0
; SNB-NEXT: retq
;
; BDW-LABEL: v4f32_no_daz:
; BDW: # %bb.0:
; BDW-NEXT: vrsqrtps %xmm0, %xmm1
; BDW-NEXT: vmulps %xmm1, %xmm0, %xmm2
; BDW-NEXT: vbroadcastss {{.*#+}} xmm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
; BDW-NEXT: vfmadd231ps {{.*#+}} xmm3 = (xmm2 * xmm1) + xmm3
; BDW-NEXT: vbroadcastss {{.*#+}} xmm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; BDW-NEXT: vmulps %xmm1, %xmm2, %xmm1
; BDW-NEXT: vmulps %xmm3, %xmm1, %xmm1
; BDW-NEXT: vbroadcastss {{.*#+}} xmm2 = [NaN,NaN,NaN,NaN]
; BDW-NEXT: vandps %xmm2, %xmm0, %xmm0
; BDW-NEXT: vbroadcastss {{.*#+}} xmm2 = [1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
; BDW-NEXT: vcmpleps %xmm0, %xmm2, %xmm0
; BDW-NEXT: vandps %xmm1, %xmm0, %xmm0
; BDW-NEXT: retq
;
; SKL-LABEL: v4f32_no_daz:
; SKL: # %bb.0:
; SKL-NEXT: vsqrtps %xmm0, %xmm0
; SKL-NEXT: retq
%call = tail call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %f) #2
ret <4 x float> %call
}
define <8 x float> @v8f32_no_daz(<8 x float> %f) #0 {
; NHM-LABEL: v8f32_no_daz:
; NHM: # %bb.0:
; NHM-NEXT: movaps %xmm0, %xmm2
; NHM-NEXT: rsqrtps %xmm0, %xmm3
; NHM-NEXT: mulps %xmm3, %xmm0
; NHM-NEXT: movaps {{.*#+}} xmm4 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; NHM-NEXT: movaps %xmm0, %xmm5
; NHM-NEXT: mulps %xmm4, %xmm5
; NHM-NEXT: mulps %xmm3, %xmm0
; NHM-NEXT: movaps {{.*#+}} xmm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
; NHM-NEXT: addps %xmm3, %xmm0
; NHM-NEXT: mulps %xmm5, %xmm0
; NHM-NEXT: movaps {{.*#+}} xmm5 = [NaN,NaN,NaN,NaN]
; NHM-NEXT: andps %xmm5, %xmm2
; NHM-NEXT: movaps {{.*#+}} xmm6 = [1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
; NHM-NEXT: movaps %xmm6, %xmm7
; NHM-NEXT: cmpleps %xmm2, %xmm7
; NHM-NEXT: andps %xmm7, %xmm0
; NHM-NEXT: rsqrtps %xmm1, %xmm7
; NHM-NEXT: movaps %xmm1, %xmm2
; NHM-NEXT: mulps %xmm7, %xmm2
; NHM-NEXT: mulps %xmm2, %xmm4
; NHM-NEXT: mulps %xmm7, %xmm2
; NHM-NEXT: addps %xmm3, %xmm2
; NHM-NEXT: mulps %xmm4, %xmm2
; NHM-NEXT: andps %xmm5, %xmm1
; NHM-NEXT: cmpleps %xmm1, %xmm6
; NHM-NEXT: andps %xmm6, %xmm2
; NHM-NEXT: movaps %xmm2, %xmm1
; NHM-NEXT: retq
;
; SNB-LABEL: v8f32_no_daz:
; SNB: # %bb.0:
; SNB-NEXT: vrsqrtps %ymm0, %ymm1
; SNB-NEXT: vmulps %ymm1, %ymm0, %ymm2
; SNB-NEXT: vmulps {{.*}}(%rip), %ymm2, %ymm3
; SNB-NEXT: vmulps %ymm1, %ymm2, %ymm1
; SNB-NEXT: vaddps {{.*}}(%rip), %ymm1, %ymm1
; SNB-NEXT: vandps {{.*}}(%rip), %ymm0, %ymm0
; SNB-NEXT: vmulps %ymm1, %ymm3, %ymm1
; SNB-NEXT: vmovaps {{.*#+}} ymm2 = [1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
; SNB-NEXT: vcmpleps %ymm0, %ymm2, %ymm0
; SNB-NEXT: vandps %ymm1, %ymm0, %ymm0
; SNB-NEXT: retq
;
; BDW-LABEL: v8f32_no_daz:
; BDW: # %bb.0:
; BDW-NEXT: vrsqrtps %ymm0, %ymm1
; BDW-NEXT: vmulps %ymm1, %ymm0, %ymm2
; BDW-NEXT: vbroadcastss {{.*#+}} ymm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
; BDW-NEXT: vfmadd231ps {{.*#+}} ymm3 = (ymm2 * ymm1) + ymm3
; BDW-NEXT: vbroadcastss {{.*#+}} ymm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; BDW-NEXT: vmulps %ymm1, %ymm2, %ymm1
; BDW-NEXT: vmulps %ymm3, %ymm1, %ymm1
; BDW-NEXT: vbroadcastss {{.*#+}} ymm2 = [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN]
; BDW-NEXT: vandps %ymm2, %ymm0, %ymm0
; BDW-NEXT: vbroadcastss {{.*#+}} ymm2 = [1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
; BDW-NEXT: vcmpleps %ymm0, %ymm2, %ymm0
; BDW-NEXT: vandps %ymm1, %ymm0, %ymm0
; BDW-NEXT: retq
;
; SKL-LABEL: v8f32_no_daz:
; SKL: # %bb.0:
; SKL-NEXT: vsqrtps %ymm0, %ymm0
; SKL-NEXT: retq
%call = tail call fast <8 x float> @llvm.sqrt.v8f32(<8 x float> %f) #2
ret <8 x float> %call
}
; Repeat all tests with denorms-as-zero enabled.
define float @f32_daz(float %f) #1 {
; NHM-LABEL: f32_daz:
; NHM: # %bb.0:
; NHM-NEXT: rsqrtss %xmm0, %xmm1
; NHM-NEXT: movaps %xmm0, %xmm2
; NHM-NEXT: mulss %xmm1, %xmm2
; NHM-NEXT: movss {{.*#+}} xmm3 = mem[0],zero,zero,zero
; NHM-NEXT: mulss %xmm2, %xmm3
; NHM-NEXT: mulss %xmm1, %xmm2
; NHM-NEXT: addss {{.*}}(%rip), %xmm2
; NHM-NEXT: mulss %xmm3, %xmm2
; NHM-NEXT: xorps %xmm1, %xmm1
; NHM-NEXT: cmpeqss %xmm1, %xmm0
; NHM-NEXT: andnps %xmm2, %xmm0
; NHM-NEXT: retq
;
; FAST-SCALAR-LABEL: f32_daz:
; FAST-SCALAR: # %bb.0:
; FAST-SCALAR-NEXT: vsqrtss %xmm0, %xmm0, %xmm0
; FAST-SCALAR-NEXT: retq
%call = tail call fast float @llvm.sqrt.f32(float %f) #2
ret float %call
}
define <4 x float> @v4f32_daz(<4 x float> %f) #1 {
; NHM-LABEL: v4f32_daz:
; NHM: # %bb.0:
; NHM-NEXT: rsqrtps %xmm0, %xmm1
; NHM-NEXT: movaps %xmm0, %xmm2
; NHM-NEXT: mulps %xmm1, %xmm2
; NHM-NEXT: movaps {{.*#+}} xmm3 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; NHM-NEXT: mulps %xmm2, %xmm3
; NHM-NEXT: mulps %xmm1, %xmm2
; NHM-NEXT: addps {{.*}}(%rip), %xmm2
; NHM-NEXT: mulps %xmm3, %xmm2
; NHM-NEXT: xorps %xmm1, %xmm1
; NHM-NEXT: cmpneqps %xmm1, %xmm0
; NHM-NEXT: andps %xmm2, %xmm0
; NHM-NEXT: retq
;
; SNB-LABEL: v4f32_daz:
; SNB: # %bb.0:
; SNB-NEXT: vrsqrtps %xmm0, %xmm1
; SNB-NEXT: vmulps %xmm1, %xmm0, %xmm2
; SNB-NEXT: vmulps {{.*}}(%rip), %xmm2, %xmm3
; SNB-NEXT: vmulps %xmm1, %xmm2, %xmm1
; SNB-NEXT: vaddps {{.*}}(%rip), %xmm1, %xmm1
; SNB-NEXT: vmulps %xmm1, %xmm3, %xmm1
; SNB-NEXT: vxorps %xmm2, %xmm2, %xmm2
; SNB-NEXT: vcmpneqps %xmm2, %xmm0, %xmm0
; SNB-NEXT: vandps %xmm1, %xmm0, %xmm0
; SNB-NEXT: retq
;
; BDW-LABEL: v4f32_daz:
; BDW: # %bb.0:
; BDW-NEXT: vrsqrtps %xmm0, %xmm1
; BDW-NEXT: vmulps %xmm1, %xmm0, %xmm2
; BDW-NEXT: vbroadcastss {{.*#+}} xmm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
; BDW-NEXT: vfmadd231ps {{.*#+}} xmm3 = (xmm2 * xmm1) + xmm3
; BDW-NEXT: vbroadcastss {{.*#+}} xmm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; BDW-NEXT: vmulps %xmm1, %xmm2, %xmm1
; BDW-NEXT: vmulps %xmm3, %xmm1, %xmm1
; BDW-NEXT: vxorps %xmm2, %xmm2, %xmm2
; BDW-NEXT: vcmpneqps %xmm2, %xmm0, %xmm0
; BDW-NEXT: vandps %xmm1, %xmm0, %xmm0
; BDW-NEXT: retq
;
; SKL-LABEL: v4f32_daz:
; SKL: # %bb.0:
; SKL-NEXT: vsqrtps %xmm0, %xmm0
; SKL-NEXT: retq
%call = tail call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %f) #2
ret <4 x float> %call
}
define <8 x float> @v8f32_daz(<8 x float> %f) #1 {
; NHM-LABEL: v8f32_daz:
; NHM: # %bb.0:
; NHM-NEXT: rsqrtps %xmm0, %xmm2
; NHM-NEXT: movaps %xmm0, %xmm3
; NHM-NEXT: mulps %xmm2, %xmm3
; NHM-NEXT: movaps {{.*#+}} xmm4 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; NHM-NEXT: movaps %xmm3, %xmm5
; NHM-NEXT: mulps %xmm4, %xmm5
; NHM-NEXT: mulps %xmm2, %xmm3
; NHM-NEXT: movaps {{.*#+}} xmm2 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
; NHM-NEXT: addps %xmm2, %xmm3
; NHM-NEXT: mulps %xmm5, %xmm3
; NHM-NEXT: xorps %xmm5, %xmm5
; NHM-NEXT: cmpneqps %xmm5, %xmm0
; NHM-NEXT: andps %xmm3, %xmm0
; NHM-NEXT: rsqrtps %xmm1, %xmm3
; NHM-NEXT: movaps %xmm1, %xmm6
; NHM-NEXT: mulps %xmm3, %xmm6
; NHM-NEXT: mulps %xmm6, %xmm4
; NHM-NEXT: mulps %xmm3, %xmm6
; NHM-NEXT: addps %xmm2, %xmm6
; NHM-NEXT: mulps %xmm4, %xmm6
; NHM-NEXT: cmpneqps %xmm5, %xmm1
; NHM-NEXT: andps %xmm6, %xmm1
; NHM-NEXT: retq
;
; SNB-LABEL: v8f32_daz:
; SNB: # %bb.0:
; SNB-NEXT: vrsqrtps %ymm0, %ymm1
; SNB-NEXT: vmulps %ymm1, %ymm0, %ymm2
; SNB-NEXT: vmulps {{.*}}(%rip), %ymm2, %ymm3
; SNB-NEXT: vmulps %ymm1, %ymm2, %ymm1
; SNB-NEXT: vaddps {{.*}}(%rip), %ymm1, %ymm1
; SNB-NEXT: vmulps %ymm1, %ymm3, %ymm1
; SNB-NEXT: vxorps %xmm2, %xmm2, %xmm2
; SNB-NEXT: vcmpneqps %ymm2, %ymm0, %ymm0
; SNB-NEXT: vandps %ymm1, %ymm0, %ymm0
; SNB-NEXT: retq
;
; BDW-LABEL: v8f32_daz:
; BDW: # %bb.0:
; BDW-NEXT: vrsqrtps %ymm0, %ymm1
; BDW-NEXT: vmulps %ymm1, %ymm0, %ymm2
; BDW-NEXT: vbroadcastss {{.*#+}} ymm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
; BDW-NEXT: vfmadd231ps {{.*#+}} ymm3 = (ymm2 * ymm1) + ymm3
; BDW-NEXT: vbroadcastss {{.*#+}} ymm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
; BDW-NEXT: vmulps %ymm1, %ymm2, %ymm1
; BDW-NEXT: vmulps %ymm3, %ymm1, %ymm1
; BDW-NEXT: vxorps %xmm2, %xmm2, %xmm2
; BDW-NEXT: vcmpneqps %ymm2, %ymm0, %ymm0
; BDW-NEXT: vandps %ymm1, %ymm0, %ymm0
; BDW-NEXT: retq
;
; SKL-LABEL: v8f32_daz:
; SKL: # %bb.0:
; SKL-NEXT: vsqrtps %ymm0, %ymm0
; SKL-NEXT: retq
%call = tail call fast <8 x float> @llvm.sqrt.v8f32(<8 x float> %f) #2
ret <8 x float> %call
}
declare float @llvm.sqrt.f32(float) #2
declare <4 x float> @llvm.sqrt.v4f32(<4 x float>) #2
declare <8 x float> @llvm.sqrt.v8f32(<8 x float>) #2
attributes #0 = { "denormal-fp-math"="ieee,ieee" }
attributes #1 = { "denormal-fp-math"="ieee,preserve-sign" }
attributes #2 = { nounwind readnone }