fp16-vminmaxnm-safe.ll
10.5 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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
; RUN: llc < %s -mtriple=armv8-eabi -mattr=+fullfp16 | FileCheck %s
; RUN: llc < %s -mtriple thumbv7a -mattr=+fullfp16 | FileCheck %s
; TODO: we can't pass half-precision arguments as "half" types yet. We do
; that for the time being by passing "float %f.coerce" and the necessary
; bitconverts/truncates. In these tests we pass i16 and use 1 bitconvert, which
; is the shortest way to get a half type. But when we can pass half types, we
; want to use that here.
define half @fp16_vminnm_o(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_o:
; CHECK-NOT: vminnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp olt half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vminnm_o_rev(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_o_rev:
; CHECK-NOT: vminnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ogt half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vminnm_u(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_u:
; CHECK-NOT: vminnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ult half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vminnm_ule(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_ule:
; CHECK-NOT: vminnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ule half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vminnm_u_rev(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_u_rev:
; CHECK-NOT: vminnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ugt half %0, %1
%cond = select i1 %cmp, half %1, half %0
ret half %cond
}
define half @fp16_vmaxnm_o(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_o:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ogt half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vmaxnm_oge(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_oge:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp oge half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vmaxnm_o_rev(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_o_rev:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp olt half %0, %1
%cond = select i1 %cmp, half %1, half %0
ret half %cond
}
define half @fp16_vmaxnm_ole_rev(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_ole_rev:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ole half %0, %1
%cond = select i1 %cmp, half %1, half %0
ret half %cond
}
define half @fp16_vmaxnm_u(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_u:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ugt half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vmaxnm_uge(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_uge:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp uge half %0, %1
%cond = select i1 %cmp, half %0, half %1
ret half %cond
}
define half @fp16_vmaxnm_u_rev(i16 signext %a, i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_u_rev:
; CHECK-NOT: vmaxnm.f16
entry:
%0 = bitcast i16 %a to half
%1 = bitcast i16 %b to half
%cmp = fcmp ult half %0, %1
%cond = select i1 %cmp, half %1, half %0
ret half %cond
}
; known non-NaNs
define half @fp16_vminnm_NNNo(i16 signext %a) {
; CHECK-LABEL: fp16_vminnm_NNNo:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], #1.200000e+01
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vminnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmin.f16 d0, d1, d0
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp olt half %0, 12.
%cond1 = select i1 %cmp1, half %0, half 12.
%cmp2 = fcmp olt half 34., %cond1
%cond2 = select i1 %cmp2, half 34., half %cond1
ret half %cond2
}
define half @fp16_vminnm_NNNo_rev(i16 signext %a) {
; CHECK-LABEL: fp16_vminnm_NNNo_rev:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], r{{.}}
; CHECK: vmin.f16 d0, d1, d0
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vminnm.f16 s0, [[S0]], [[S2]]
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp ogt half %0, 56.
%cond1 = select i1 %cmp1, half 56., half %0
%cmp2 = fcmp ogt half 78., %cond1
%cond2 = select i1 %cmp2, half %cond1, half 78.
ret half %cond2
}
define half @fp16_vminnm_NNNu(i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_NNNu:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], #1.200000e+01
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vminnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmin.f16 d0, d1, d0
entry:
%0 = bitcast i16 %b to half
%cmp1 = fcmp ult half 12., %0
%cond1 = select i1 %cmp1, half 12., half %0
%cmp2 = fcmp ult half %cond1, 34.
%cond2 = select i1 %cmp2, half %cond1, half 34.
ret half %cond2
}
define half @fp16_vminnm_NNNule(i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_NNNule:
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vminnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmin.f16 d0, d1, d0
entry:
%0 = bitcast i16 %b to half
%cmp1 = fcmp ule half 34., %0
%cond1 = select i1 %cmp1, half 34., half %0
%cmp2 = fcmp ule half %cond1, 56.
%cond2 = select i1 %cmp2, half %cond1, half 56.
ret half %cond2
}
define half @fp16_vminnm_NNNu_rev(i16 signext %b) {
; CHECK-LABEL: fp16_vminnm_NNNu_rev:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], r{{.}}
; CHECK: vmin.f16 d0, d1, d0
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vminnm.f16 s0, [[S0]], [[S2]]
entry:
%0 = bitcast i16 %b to half
%cmp1 = fcmp ugt half 56., %0
%cond1 = select i1 %cmp1, half %0, half 56.
%cmp2 = fcmp ugt half %cond1, 78.
%cond2 = select i1 %cmp2, half 78., half %cond1
ret half %cond2
}
define half @fp16_vmaxnm_NNNo(i16 signext %a) {
; CHECK-LABEL: fp16_vmaxnm_NNNo:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], #1.200000e+01
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vmaxnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmax.f16 d0, d1, d0
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp ogt half %0, 12.
%cond1 = select i1 %cmp1, half %0, half 12.
%cmp2 = fcmp ogt half 34., %cond1
%cond2 = select i1 %cmp2, half 34., half %cond1
ret half %cond2
}
define half @fp16_vmaxnm_NNNoge(i16 signext %a) {
; CHECK-LABEL: fp16_vmaxnm_NNNoge:
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmaxnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmax.f16 d0, d1, d0
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp oge half %0, 34.
%cond1 = select i1 %cmp1, half %0, half 34.
%cmp2 = fcmp oge half 56., %cond1
%cond2 = select i1 %cmp2, half 56., half %cond1
ret half %cond2
}
define half @fp16_vmaxnm_NNNo_rev(i16 signext %a) {
; CHECK-LABEL: fp16_vmaxnm_NNNo_rev:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], r{{.}}
; CHECK: vmax.f16 d0, d1, d0
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vmaxnm.f16 s0, [[S0]], [[S2]]
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp olt half %0, 56.
%cond1 = select i1 %cmp1, half 56., half %0
%cmp2 = fcmp olt half 78., %cond1
%cond2 = select i1 %cmp2, half %cond1, half 78.
ret half %cond2
}
define half @fp16_vmaxnm_NNNole_rev(i16 signext %a) {
; CHECK-LABEL: fp16_vmaxnm_NNNole_rev:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], r{{.}}
; CHECK: vmax.f16 d0, d1, d0
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vmaxnm.f16 s0, [[S0]], [[S2]]
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp ole half %0, 78.
%cond1 = select i1 %cmp1, half 78., half %0
%cmp2 = fcmp ole half 90., %cond1
%cond2 = select i1 %cmp2, half %cond1, half 90.
ret half %cond2
}
define half @fp16_vmaxnm_NNNu(i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_NNNu:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], #1.200000e+01
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vmaxnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmax.f16 d0, d1, d0
entry:
%0 = bitcast i16 %b to half
%cmp1 = fcmp ugt half 12., %0
%cond1 = select i1 %cmp1, half 12., half %0
%cmp2 = fcmp ugt half %cond1, 34.
%cond2 = select i1 %cmp2, half %cond1, half 34.
ret half %cond2
}
define half @fp16_vmaxnm_NNNuge(i16 signext %b) {
; CHECK-LABEL: fp16_vmaxnm_NNNuge:
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S4:s[0-9]]], r{{.}}
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmaxnm.f16 s2, [[S4]], [[S2]]
; CHECK: vmax.f16 d0, d1, d0
entry:
%0 = bitcast i16 %b to half
%cmp1 = fcmp uge half 34., %0
%cond1 = select i1 %cmp1, half 34., half %0
%cmp2 = fcmp uge half %cond1, 56.
%cond2 = select i1 %cmp2, half %cond1, half 56.
ret half %cond2
}
define half @fp16_vminmaxnm_neg0(i16 signext %a) {
; CHECK-LABEL: fp16_vminmaxnm_neg0:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], r{{.}}
; CHECK: vminnm.f16 s2, [[S2]], [[S0]]
; CHECK: vmax.f16 d0, d1, d0
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp olt half %0, -0.
%cond1 = select i1 %cmp1, half %0, half -0.
%cmp2 = fcmp ugt half %cond1, -0.
%cond2 = select i1 %cmp2, half %cond1, half -0.
ret half %cond2
}
define half @fp16_vminmaxnm_e_0(i16 signext %a) {
; CHECK-LABEL: fp16_vminmaxnm_e_0:
; CHECK: vldr.16 [[S2:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S0:s[0-9]]], r{{.}}
; CHECK: vmin.f16 d0, d0, d1
; CHECK: vmaxnm.f16 s0, [[S0]], [[S2]]
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp nsz ole half 0., %0
%cond1 = select i1 %cmp1, half 0., half %0
%cmp2 = fcmp nsz uge half 0., %cond1
%cond2 = select i1 %cmp2, half 0., half %cond1
ret half %cond2
}
define half @fp16_vminmaxnm_e_neg0(i16 signext %a) {
; CHECK-LABEL: fp16_vminmaxnm_e_neg0:
; CHECK: vldr.16 [[S0:s[0-9]]], .LCPI{{.*}}
; CHECK: vmov.f16 [[S2:s[0-9]]], r{{.}}
; CHECK: vminnm.f16 s2, [[S2]], [[S0]]
; CHECK: vmax.f16 d0, d1, d0
entry:
%0 = bitcast i16 %a to half
%cmp1 = fcmp nsz ule half -0., %0
%cond1 = select i1 %cmp1, half -0., half %0
%cmp2 = fcmp nsz oge half -0., %cond1
%cond2 = select i1 %cmp2, half -0., half %cond1
ret half %cond2
}