recipest.ll
6.97 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
303
304
305
306
307
308
309
310
311
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -mattr=-vsx | FileCheck %s
target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
target triple = "powerpc64-unknown-linux-gnu"
declare double @llvm.sqrt.f64(double)
declare float @llvm.sqrt.f32(float)
declare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
define double @foo_fmf(double %a, double %b) nounwind {
; CHECK: @foo_fmf
; CHECK: frsqrte
; CHECK: fmul
; CHECK-NEXT: fmadd
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmadd
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK: blr
%x = call fast double @llvm.sqrt.f64(double %b)
%r = fdiv fast double %a, %x
ret double %r
}
define double @foo_safe(double %a, double %b) nounwind {
; CHECK: @foo_safe
; CHECK: fsqrt
; CHECK: fdiv
; CHECK: blr
%x = call double @llvm.sqrt.f64(double %b)
%r = fdiv double %a, %x
ret double %r
}
define double @no_estimate_refinement_f64(double %a, double %b) #0 {
; CHECK-LABEL: @no_estimate_refinement_f64
; CHECK: frsqrte
; CHECK-NOT: fmadd
; CHECK: fmul
; CHECK-NOT: fmadd
; CHECK: blr
%x = call fast double @llvm.sqrt.f64(double %b)
%r = fdiv fast double %a, %x
ret double %r
}
define double @foof_fmf(double %a, float %b) nounwind {
; CHECK: @foof_fmf
; CHECK-DAG: frsqrtes
; CHECK: fmuls
; CHECK-NEXT: fmadds
; CHECK-NEXT: fmuls
; CHECK-NEXT: fmuls
; CHECK-NEXT: fmul
; CHECK-NEXT: blr
%x = call fast float @llvm.sqrt.f32(float %b)
%y = fpext float %x to double
%r = fdiv fast double %a, %y
ret double %r
}
define double @foof_safe(double %a, float %b) nounwind {
; CHECK: @foof_safe
; CHECK: fsqrts
; CHECK: fdiv
; CHECK: blr
%x = call float @llvm.sqrt.f32(float %b)
%y = fpext float %x to double
%r = fdiv double %a, %y
ret double %r
}
define float @food_fmf(float %a, double %b) nounwind {
; CHECK: @food_fmf
; CHECK-DAG: frsqrte
; CHECK: fmul
; CHECK-NEXT: fmadd
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmadd
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: frsp
; CHECK-NEXT: fmuls
; CHECK-NEXT: blr
%x = call fast double @llvm.sqrt.f64(double %b)
%y = fptrunc double %x to float
%r = fdiv fast float %a, %y
ret float %r
}
define float @food_safe(float %a, double %b) nounwind {
; CHECK: @food_safe
; CHECK: fsqrt
; CHECK: fdivs
; CHECK: blr
%x = call double @llvm.sqrt.f64(double %b)
%y = fptrunc double %x to float
%r = fdiv float %a, %y
ret float %r
}
define float @goo_fmf(float %a, float %b) nounwind {
; CHECK: @goo_fmf
; CHECK-DAG: frsqrtes
; CHECK: fmuls
; CHECK-NEXT: fmadds
; CHECK-NEXT: fmuls
; CHECK-NEXT: fmuls
; CHECK-NEXT: fmuls
; CHECK-NEXT: blr
%x = call fast float @llvm.sqrt.f32(float %b)
%r = fdiv fast float %a, %x
ret float %r
}
define float @goo_safe(float %a, float %b) nounwind {
; CHECK: @goo_safe
; CHECK: fsqrts
; CHECK: fdivs
; CHECK: blr
%x = call float @llvm.sqrt.f32(float %b)
%r = fdiv float %a, %x
ret float %r
}
define float @no_estimate_refinement_f32(float %a, float %b) #0 {
; CHECK-LABEL: @no_estimate_refinement_f32
; CHECK: frsqrtes
; CHECK-NOT: fmadds
; CHECK: fmuls
; CHECK-NOT: fmadds
; CHECK: blr
%x = call fast float @llvm.sqrt.f32(float %b)
%r = fdiv fast float %a, %x
ret float %r
}
; Recognize that this is rsqrt(a) * rcp(b) * c,
; not 1 / ( 1 / sqrt(a)) * rcp(b) * c.
define float @rsqrt_fmul_fmf(float %a, float %b, float %c) {
; CHECK: @rsqrt_fmul_fmf
; CHECK-DAG: frsqrtes
; CHECK: fmuls
; CHECK-NEXT: fmadds
; CHECK-NEXT: fmuls
; CHECK-DAG: fres
; CHECK-COUNT-3: fmuls
; CHECK-NEXT: fmsubs
; CHECK-NEXT: fmadds
; CHECK-NEXT: fmuls
; CHECK-NEXT: blr
%x = call fast float @llvm.sqrt.f32(float %a)
%y = fmul fast float %x, %b
%z = fdiv fast float %c, %y
ret float %z
}
; Recognize that this is rsqrt(a) * rcp(b) * c,
; not 1 / ( 1 / sqrt(a)) * rcp(b) * c.
define float @rsqrt_fmul_safe(float %a, float %b, float %c) {
; CHECK: @rsqrt_fmul_safe
; CHECK: fsqrts
; CHECK: fmuls
; CHECK: fdivs
; CHECK: blr
%x = call float @llvm.sqrt.f32(float %a)
%y = fmul float %x, %b
%z = fdiv float %c, %y
ret float %z
}
define <4 x float> @hoo_fmf(<4 x float> %a, <4 x float> %b) nounwind {
; CHECK: @hoo_fmf
; CHECK: vrsqrtefp
%x = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
%r = fdiv fast <4 x float> %a, %x
ret <4 x float> %r
}
define <4 x float> @hoo_safe(<4 x float> %a, <4 x float> %b) nounwind {
; CHECK: @hoo_safe
; CHECK-NOT: vrsqrtefp
; CHECK: blr
%x = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
%r = fdiv <4 x float> %a, %x
ret <4 x float> %r
}
define double @foo2_fmf(double %a, double %b) nounwind {
; CHECK: @foo2_fmf
; CHECK-DAG: fre
; CHECK-DAG: fmadd
; CHECK: fnmsub
; CHECK-NEXT: fmul
; CHECK-NEXT: fnmsub
; CHECK-NEXT: fmadd
; CHECK-NEXT: blr
%r = fdiv fast double %a, %b
ret double %r
}
define double @foo2_safe(double %a, double %b) nounwind {
; CHECK: @foo2_safe
; CHECK: fdiv
; CHECK: blr
%r = fdiv double %a, %b
ret double %r
}
define float @goo2_fmf(float %a, float %b) nounwind {
; CHECK: @goo2_fmf
; CHECK-DAG: fres
; CHECK-NEXT: fmuls
; CHECK-DAG: fnmsubs
; CHECK: fmadds
; CHECK-NEXT: blr
%r = fdiv fast float %a, %b
ret float %r
}
define float @goo2_safe(float %a, float %b) nounwind {
; CHECK: @goo2_safe
; CHECK: fdivs
; CHECK: blr
%r = fdiv float %a, %b
ret float %r
}
define <4 x float> @hoo2_fmf(<4 x float> %a, <4 x float> %b) nounwind {
; CHECK: @hoo2_fmf
; CHECK: vrefp
%r = fdiv fast <4 x float> %a, %b
ret <4 x float> %r
}
define <4 x float> @hoo2_safe(<4 x float> %a, <4 x float> %b) nounwind {
; CHECK: @hoo2_safe
; CHECK-NOT: vrefp
; CHECK: blr
%r = fdiv <4 x float> %a, %b
ret <4 x float> %r
}
define double @foo3_fmf(double %a) nounwind {
; CHECK: @foo3_fmf
; CHECK: fcmpu
; CHECK-DAG: frsqrte
; CHECK: fmul
; CHECK-NEXT: fmadd
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK-NEXT: fmadd
; CHECK-NEXT: fmul
; CHECK-NEXT: fmul
; CHECK: blr
%r = call fast double @llvm.sqrt.f64(double %a)
ret double %r
}
define double @foo3_safe(double %a) nounwind {
; CHECK: @foo3_safe
; CHECK: fsqrt
; CHECK: blr
%r = call double @llvm.sqrt.f64(double %a)
ret double %r
}
define float @goo3_fmf(float %a) nounwind {
; CHECK: @goo3_fmf
; CHECK: fcmpu
; CHECK-DAG: frsqrtes
; CHECK: fmuls
; CHECK-NEXT: fmadds
; CHECK-NEXT: fmuls
; CHECK-NEXT: fmuls
; CHECK: blr
%r = call fast float @llvm.sqrt.f32(float %a)
ret float %r
}
define float @goo3_safe(float %a) nounwind {
; CHECK: @goo3_safe
; CHECK: fsqrts
; CHECK: blr
%r = call float @llvm.sqrt.f32(float %a)
ret float %r
}
define <4 x float> @hoo3_fmf(<4 x float> %a) nounwind {
; CHECK: @hoo3_fmf
; CHECK: vrsqrtefp
; CHECK-DAG: vcmpeqfp
%r = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
ret <4 x float> %r
}
define <4 x float> @hoo3_safe(<4 x float> %a) nounwind {
; CHECK: @hoo3_safe
; CHECK-NOT: vrsqrtefp
; CHECK: blr
%r = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
ret <4 x float> %r
}
attributes #0 = { nounwind "reciprocal-estimates"="sqrtf:0,sqrtd:0" }