1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+bf16 | FileCheck %s -check-prefix=CHECK
4 define i1 @isnan_half(half %x) nounwind {
5 ; CHECK-LABEL: isnan_half:
6 ; CHECK: // %bb.0: // %entry
7 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $s0
8 ; CHECK-NEXT: fmov w8, s0
9 ; CHECK-NEXT: and w8, w8, #0x7fff
10 ; CHECK-NEXT: mov w9, #31744
11 ; CHECK-NEXT: cmp w8, w9
12 ; CHECK-NEXT: cset w0, gt
15 %0 = tail call i1 @llvm.isnan.f16(half %x)
19 define i1 @isnan_float(float %x) nounwind {
20 ; CHECK-LABEL: isnan_float:
21 ; CHECK: // %bb.0: // %entry
22 ; CHECK-NEXT: fcmp s0, s0
23 ; CHECK-NEXT: cset w0, vs
26 %0 = tail call i1 @llvm.isnan.f32(float %x)
30 define i1 @isnan_double(double %x) nounwind {
31 ; CHECK-LABEL: isnan_double:
32 ; CHECK: // %bb.0: // %entry
33 ; CHECK-NEXT: fcmp d0, d0
34 ; CHECK-NEXT: cset w0, vs
37 %0 = tail call i1 @llvm.isnan.f64(double %x)
41 define i1 @isnan_ldouble(fp128 %x) nounwind {
42 ; CHECK-LABEL: isnan_ldouble:
43 ; CHECK: // %bb.0: // %entry
44 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
45 ; CHECK-NEXT: mov v1.16b, v0.16b
46 ; CHECK-NEXT: bl __unordtf2
47 ; CHECK-NEXT: cmp w0, #0
48 ; CHECK-NEXT: cset w0, ne
49 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
52 %0 = tail call i1 @llvm.isnan.f128(fp128 %x)
57 define i1 @isnan_half_strictfp(half %x) strictfp nounwind {
58 ; CHECK-LABEL: isnan_half_strictfp:
59 ; CHECK: // %bb.0: // %entry
60 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $s0
61 ; CHECK-NEXT: fmov w8, s0
62 ; CHECK-NEXT: and w8, w8, #0x7fff
63 ; CHECK-NEXT: mov w9, #31744
64 ; CHECK-NEXT: cmp w8, w9
65 ; CHECK-NEXT: cset w0, gt
68 %0 = tail call i1 @llvm.isnan.f16(half %x)
72 define i1 @isnan_bfloat_strictfp(bfloat %x) strictfp nounwind {
73 ; CHECK-LABEL: isnan_bfloat_strictfp:
74 ; CHECK: // %bb.0: // %entry
75 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $s0
76 ; CHECK-NEXT: fmov w8, s0
77 ; CHECK-NEXT: and w8, w8, #0x7fff
78 ; CHECK-NEXT: mov w9, #32640
79 ; CHECK-NEXT: cmp w8, w9
80 ; CHECK-NEXT: cset w0, gt
83 %0 = tail call i1 @llvm.isnan.bf16(bfloat %x)
87 define i1 @isnan_float_strictfp(float %x) strictfp nounwind {
88 ; CHECK-LABEL: isnan_float_strictfp:
89 ; CHECK: // %bb.0: // %entry
90 ; CHECK-NEXT: fmov w8, s0
91 ; CHECK-NEXT: and w8, w8, #0x7fffffff
92 ; CHECK-NEXT: mov w9, #2139095040
93 ; CHECK-NEXT: cmp w8, w9
94 ; CHECK-NEXT: cset w0, gt
97 %0 = tail call i1 @llvm.isnan.f32(float %x)
101 define i1 @isnan_double_strictfp(double %x) strictfp nounwind {
102 ; CHECK-LABEL: isnan_double_strictfp:
103 ; CHECK: // %bb.0: // %entry
104 ; CHECK-NEXT: fmov x8, d0
105 ; CHECK-NEXT: and x8, x8, #0x7fffffffffffffff
106 ; CHECK-NEXT: mov x9, #9218868437227405312
107 ; CHECK-NEXT: cmp x8, x9
108 ; CHECK-NEXT: cset w0, gt
111 %0 = tail call i1 @llvm.isnan.f64(double %x)
115 define i1 @isnan_ldouble_strictfp(fp128 %x) strictfp nounwind {
116 ; CHECK-LABEL: isnan_ldouble_strictfp:
117 ; CHECK: // %bb.0: // %entry
118 ; CHECK-NEXT: str q0, [sp, #-16]!
119 ; CHECK-NEXT: ldp x8, x9, [sp], #16
120 ; CHECK-NEXT: mov x10, #9223090561878065152
121 ; CHECK-NEXT: cmp x8, #0
122 ; CHECK-NEXT: and x8, x9, #0x7fffffffffffffff
123 ; CHECK-NEXT: cset w9, ne
124 ; CHECK-NEXT: cmp x8, x10
125 ; CHECK-NEXT: cset w8, gt
126 ; CHECK-NEXT: csel w0, w9, w8, eq
129 %0 = tail call i1 @llvm.isnan.f128(fp128 %x)
134 define <1 x i1> @isnan_half_vec1(<1 x half> %x) nounwind {
135 ; CHECK-LABEL: isnan_half_vec1:
136 ; CHECK: // %bb.0: // %entry
137 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $q0
138 ; CHECK-NEXT: umov w8, v0.h[0]
139 ; CHECK-NEXT: and w8, w8, #0x7fff
140 ; CHECK-NEXT: mov w9, #31744
141 ; CHECK-NEXT: cmp w8, w9
142 ; CHECK-NEXT: cset w0, gt
145 %0 = tail call <1 x i1> @llvm.isnan.v1f16(<1 x half> %x)
149 define <1 x i1> @isnan_float_vec1(<1 x float> %x) nounwind {
150 ; CHECK-LABEL: isnan_float_vec1:
151 ; CHECK: // %bb.0: // %entry
152 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
153 ; CHECK-NEXT: fcmp s0, s0
154 ; CHECK-NEXT: cset w0, vs
157 %0 = tail call <1 x i1> @llvm.isnan.v1f32(<1 x float> %x)
161 define <1 x i1> @isnan_double_vec1(<1 x double> %x) nounwind {
162 ; CHECK-LABEL: isnan_double_vec1:
163 ; CHECK: // %bb.0: // %entry
164 ; CHECK-NEXT: fcmp d0, d0
165 ; CHECK-NEXT: cset w0, vs
168 %0 = tail call <1 x i1> @llvm.isnan.v1f64(<1 x double> %x)
172 define <1 x i1> @isnan_ldouble_vec1(<1 x fp128> %x) nounwind {
173 ; CHECK-LABEL: isnan_ldouble_vec1:
174 ; CHECK: // %bb.0: // %entry
175 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
176 ; CHECK-NEXT: mov v1.16b, v0.16b
177 ; CHECK-NEXT: bl __unordtf2
178 ; CHECK-NEXT: cmp w0, #0
179 ; CHECK-NEXT: cset w0, ne
180 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
183 %0 = tail call <1 x i1> @llvm.isnan.v1f128(<1 x fp128> %x)
188 define <2 x i1> @isnan_half_vec2(<2 x half> %x) nounwind {
189 ; CHECK-LABEL: isnan_half_vec2:
190 ; CHECK: // %bb.0: // %entry
191 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
192 ; CHECK-NEXT: umov w8, v0.h[0]
193 ; CHECK-NEXT: umov w9, v0.h[1]
194 ; CHECK-NEXT: fmov s1, w8
195 ; CHECK-NEXT: movi v0.2s, #127, msl #8
196 ; CHECK-NEXT: mov v1.s[1], w9
197 ; CHECK-NEXT: and v0.8b, v1.8b, v0.8b
198 ; CHECK-NEXT: movi v1.2s, #124, lsl #8
199 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v1.2s
202 %0 = tail call <2 x i1> @llvm.isnan.v2f16(<2 x half> %x)
206 define <2 x i1> @isnan_float_vec2(<2 x float> %x) nounwind {
207 ; CHECK-LABEL: isnan_float_vec2:
208 ; CHECK: // %bb.0: // %entry
209 ; CHECK-NEXT: fcmge v1.2s, v0.2s, #0.0
210 ; CHECK-NEXT: fcmlt v0.2s, v0.2s, #0.0
211 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
212 ; CHECK-NEXT: mvn v0.8b, v0.8b
215 %0 = tail call <2 x i1> @llvm.isnan.v2f32(<2 x float> %x)
219 define <2 x i1> @isnan_double_vec2(<2 x double> %x) nounwind {
220 ; CHECK-LABEL: isnan_double_vec2:
221 ; CHECK: // %bb.0: // %entry
222 ; CHECK-NEXT: fcmge v1.2d, v0.2d, #0.0
223 ; CHECK-NEXT: fcmlt v0.2d, v0.2d, #0.0
224 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
225 ; CHECK-NEXT: mvn v0.16b, v0.16b
226 ; CHECK-NEXT: xtn v0.2s, v0.2d
229 %0 = tail call <2 x i1> @llvm.isnan.v2f64(<2 x double> %x)
233 define <2 x i1> @isnan_ldouble_vec2(<2 x fp128> %x) nounwind {
234 ; CHECK-LABEL: isnan_ldouble_vec2:
235 ; CHECK: // %bb.0: // %entry
236 ; CHECK-NEXT: sub sp, sp, #48
237 ; CHECK-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
238 ; CHECK-NEXT: mov v0.16b, v1.16b
239 ; CHECK-NEXT: str x30, [sp, #32] // 8-byte Folded Spill
240 ; CHECK-NEXT: bl __unordtf2
241 ; CHECK-NEXT: cmp w0, #0
242 ; CHECK-NEXT: cset w8, ne
243 ; CHECK-NEXT: sbfx x8, x8, #0, #1
244 ; CHECK-NEXT: dup v0.2d, x8
245 ; CHECK-NEXT: str q0, [sp] // 16-byte Folded Spill
246 ; CHECK-NEXT: ldr q0, [sp, #16] // 16-byte Folded Reload
247 ; CHECK-NEXT: mov v1.16b, v0.16b
248 ; CHECK-NEXT: bl __unordtf2
249 ; CHECK-NEXT: cmp w0, #0
250 ; CHECK-NEXT: ldr q1, [sp] // 16-byte Folded Reload
251 ; CHECK-NEXT: cset w8, ne
252 ; CHECK-NEXT: sbfx x8, x8, #0, #1
253 ; CHECK-NEXT: ldr x30, [sp, #32] // 8-byte Folded Reload
254 ; CHECK-NEXT: dup v0.2d, x8
255 ; CHECK-NEXT: zip1 v0.4s, v0.4s, v1.4s
256 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
257 ; CHECK-NEXT: add sp, sp, #48
260 %0 = tail call <2 x i1> @llvm.isnan.v2f128(<2 x fp128> %x)
265 define <2 x i1> @isnan_half_vec2_strictfp(<2 x half> %x) strictfp nounwind {
266 ; CHECK-LABEL: isnan_half_vec2_strictfp:
267 ; CHECK: // %bb.0: // %entry
268 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
269 ; CHECK-NEXT: umov w8, v0.h[0]
270 ; CHECK-NEXT: umov w9, v0.h[1]
271 ; CHECK-NEXT: fmov s1, w8
272 ; CHECK-NEXT: movi v0.2s, #127, msl #8
273 ; CHECK-NEXT: mov v1.s[1], w9
274 ; CHECK-NEXT: and v0.8b, v1.8b, v0.8b
275 ; CHECK-NEXT: movi v1.2s, #124, lsl #8
276 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v1.2s
279 %0 = tail call <2 x i1> @llvm.isnan.v2f16(<2 x half> %x)
283 define <2 x i1> @isnan_bfloat_vec2_strictfp(<2 x bfloat> %x) strictfp nounwind {
284 ; CHECK-LABEL: isnan_bfloat_vec2_strictfp:
285 ; CHECK: // %bb.0: // %entry
286 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
287 ; CHECK-NEXT: umov w8, v0.h[0]
288 ; CHECK-NEXT: umov w9, v0.h[1]
289 ; CHECK-NEXT: fmov s1, w8
290 ; CHECK-NEXT: movi v0.2s, #127, msl #8
291 ; CHECK-NEXT: mov w10, #32640
292 ; CHECK-NEXT: mov v1.s[1], w9
293 ; CHECK-NEXT: and v0.8b, v1.8b, v0.8b
294 ; CHECK-NEXT: dup v1.2s, w10
295 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v1.2s
298 %0 = tail call <2 x i1> @llvm.isnan.v2bf16(<2 x bfloat> %x)
302 define <2 x i1> @isnan_float_vec2_strictfp(<2 x float> %x) strictfp nounwind {
303 ; CHECK-LABEL: isnan_float_vec2_strictfp:
304 ; CHECK: // %bb.0: // %entry
305 ; CHECK-NEXT: mov w8, #2139095040
306 ; CHECK-NEXT: dup v1.2s, w8
307 ; CHECK-NEXT: bic v0.2s, #128, lsl #24
308 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v1.2s
311 %0 = tail call <2 x i1> @llvm.isnan.v2f32(<2 x float> %x)
315 define <2 x i1> @isnan_double_vec2_strictfp(<2 x double> %x) strictfp nounwind {
316 ; CHECK-LABEL: isnan_double_vec2_strictfp:
317 ; CHECK: // %bb.0: // %entry
318 ; CHECK-NEXT: mov x8, #9223372036854775807
319 ; CHECK-NEXT: mov x9, #9218868437227405312
320 ; CHECK-NEXT: dup v1.2d, x8
321 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
322 ; CHECK-NEXT: dup v1.2d, x9
323 ; CHECK-NEXT: cmgt v0.2d, v0.2d, v1.2d
324 ; CHECK-NEXT: xtn v0.2s, v0.2d
327 %0 = tail call <2 x i1> @llvm.isnan.v2f64(<2 x double> %x)
331 define <2 x i1> @isnan_ldouble_vec2_strictfp(<2 x fp128> %x) strictfp nounwind {
332 ; CHECK-LABEL: isnan_ldouble_vec2_strictfp:
333 ; CHECK: // %bb.0: // %entry
334 ; CHECK-NEXT: stp q0, q1, [sp, #-32]!
335 ; CHECK-NEXT: ldp x11, x10, [sp, #16]
336 ; CHECK-NEXT: ldp x8, x9, [sp]
337 ; CHECK-NEXT: mov x12, #9223090561878065152
338 ; CHECK-NEXT: and x10, x10, #0x7fffffffffffffff
339 ; CHECK-NEXT: cmp x11, #0
340 ; CHECK-NEXT: cset w11, ne
341 ; CHECK-NEXT: cmp x10, x12
342 ; CHECK-NEXT: cset w10, gt
343 ; CHECK-NEXT: and x9, x9, #0x7fffffffffffffff
344 ; CHECK-NEXT: csel w10, w11, w10, eq
345 ; CHECK-NEXT: cmp x8, #0
346 ; CHECK-NEXT: sbfx x8, x10, #0, #1
347 ; CHECK-NEXT: cset w10, ne
348 ; CHECK-NEXT: cmp x9, x12
349 ; CHECK-NEXT: dup v0.2d, x8
350 ; CHECK-NEXT: cset w8, gt
351 ; CHECK-NEXT: csel w8, w10, w8, eq
352 ; CHECK-NEXT: sbfx x8, x8, #0, #1
353 ; CHECK-NEXT: dup v1.2d, x8
354 ; CHECK-NEXT: zip1 v0.4s, v1.4s, v0.4s
355 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
356 ; CHECK-NEXT: add sp, sp, #32
359 %0 = tail call <2 x i1> @llvm.isnan.v2f128(<2 x fp128> %x)
364 define <4 x i1> @isnan_half_vec4(<4 x half> %x) nounwind {
365 ; CHECK-LABEL: isnan_half_vec4:
366 ; CHECK: // %bb.0: // %entry
367 ; CHECK-NEXT: movi v1.4h, #124, lsl #8
368 ; CHECK-NEXT: bic v0.4h, #128, lsl #8
369 ; CHECK-NEXT: cmgt v0.4h, v0.4h, v1.4h
372 %0 = tail call <4 x i1> @llvm.isnan.v4f16(<4 x half> %x)
376 define <4 x i1> @isnan_float_vec4(<4 x float> %x) nounwind {
377 ; CHECK-LABEL: isnan_float_vec4:
378 ; CHECK: // %bb.0: // %entry
379 ; CHECK-NEXT: fcmge v1.4s, v0.4s, #0.0
380 ; CHECK-NEXT: fcmlt v0.4s, v0.4s, #0.0
381 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
382 ; CHECK-NEXT: mvn v0.16b, v0.16b
383 ; CHECK-NEXT: xtn v0.4h, v0.4s
386 %0 = tail call <4 x i1> @llvm.isnan.v4f32(<4 x float> %x)
390 define <4 x i1> @isnan_double_vec4(<4 x double> %x) nounwind {
391 ; CHECK-LABEL: isnan_double_vec4:
392 ; CHECK: // %bb.0: // %entry
393 ; CHECK-NEXT: fcmge v2.2d, v0.2d, #0.0
394 ; CHECK-NEXT: fcmlt v0.2d, v0.2d, #0.0
395 ; CHECK-NEXT: fcmge v3.2d, v1.2d, #0.0
396 ; CHECK-NEXT: fcmlt v1.2d, v1.2d, #0.0
397 ; CHECK-NEXT: orr v0.16b, v0.16b, v2.16b
398 ; CHECK-NEXT: orr v1.16b, v1.16b, v3.16b
399 ; CHECK-NEXT: mvn v0.16b, v0.16b
400 ; CHECK-NEXT: xtn v0.2s, v0.2d
401 ; CHECK-NEXT: mvn v1.16b, v1.16b
402 ; CHECK-NEXT: xtn2 v0.4s, v1.2d
403 ; CHECK-NEXT: xtn v0.4h, v0.4s
406 %0 = tail call <4 x i1> @llvm.isnan.v4f64(<4 x double> %x)
411 define <4 x i1> @isnan_half_vec4_strictfp(<4 x half> %x) strictfp nounwind {
412 ; CHECK-LABEL: isnan_half_vec4_strictfp:
413 ; CHECK: // %bb.0: // %entry
414 ; CHECK-NEXT: movi v1.4h, #124, lsl #8
415 ; CHECK-NEXT: bic v0.4h, #128, lsl #8
416 ; CHECK-NEXT: cmgt v0.4h, v0.4h, v1.4h
419 %0 = tail call <4 x i1> @llvm.isnan.v4f16(<4 x half> %x)
423 define <4 x i1> @isnan_bfloat_vec4_strictfp(<4 x bfloat> %x) strictfp nounwind {
424 ; CHECK-LABEL: isnan_bfloat_vec4_strictfp:
425 ; CHECK: // %bb.0: // %entry
426 ; CHECK-NEXT: mov w8, #32640
427 ; CHECK-NEXT: dup v1.4h, w8
428 ; CHECK-NEXT: bic v0.4h, #128, lsl #8
429 ; CHECK-NEXT: cmgt v0.4h, v0.4h, v1.4h
432 %0 = tail call <4 x i1> @llvm.isnan.v4bf16(<4 x bfloat> %x)
436 define <4 x i1> @isnan_float_vec4_strictfp(<4 x float> %x) strictfp nounwind {
437 ; CHECK-LABEL: isnan_float_vec4_strictfp:
438 ; CHECK: // %bb.0: // %entry
439 ; CHECK-NEXT: mov w8, #2139095040
440 ; CHECK-NEXT: dup v1.4s, w8
441 ; CHECK-NEXT: bic v0.4s, #128, lsl #24
442 ; CHECK-NEXT: cmgt v0.4s, v0.4s, v1.4s
443 ; CHECK-NEXT: xtn v0.4h, v0.4s
446 %0 = tail call <4 x i1> @llvm.isnan.v4f32(<4 x float> %x)
450 define <4 x i1> @isnan_double_vec4_strictfp(<4 x double> %x) strictfp nounwind {
451 ; CHECK-LABEL: isnan_double_vec4_strictfp:
452 ; CHECK: // %bb.0: // %entry
453 ; CHECK-NEXT: mov x8, #9223372036854775807
454 ; CHECK-NEXT: mov x9, #9218868437227405312
455 ; CHECK-NEXT: dup v2.2d, x8
456 ; CHECK-NEXT: dup v3.2d, x9
457 ; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
458 ; CHECK-NEXT: and v1.16b, v1.16b, v2.16b
459 ; CHECK-NEXT: cmgt v0.2d, v0.2d, v3.2d
460 ; CHECK-NEXT: cmgt v1.2d, v1.2d, v3.2d
461 ; CHECK-NEXT: xtn v0.2s, v0.2d
462 ; CHECK-NEXT: xtn2 v0.4s, v1.2d
463 ; CHECK-NEXT: xtn v0.4h, v0.4s
466 %0 = tail call <4 x i1> @llvm.isnan.v4f64(<4 x double> %x)
471 declare i1 @llvm.isnan.f16(half)
472 declare i1 @llvm.isnan.bf16(bfloat)
473 declare i1 @llvm.isnan.f32(float)
474 declare i1 @llvm.isnan.f64(double)
475 declare i1 @llvm.isnan.f128(fp128)
476 declare <1 x i1> @llvm.isnan.v1f16(<1 x half>)
477 declare <1 x i1> @llvm.isnan.v1bf16(<1 x bfloat>)
478 declare <1 x i1> @llvm.isnan.v1f32(<1 x float>)
479 declare <1 x i1> @llvm.isnan.v1f64(<1 x double>)
480 declare <1 x i1> @llvm.isnan.v1f128(<1 x fp128>)
481 declare <2 x i1> @llvm.isnan.v2f16(<2 x half>)
482 declare <2 x i1> @llvm.isnan.v2bf16(<2 x bfloat>)
483 declare <2 x i1> @llvm.isnan.v2f32(<2 x float>)
484 declare <2 x i1> @llvm.isnan.v2f64(<2 x double>)
485 declare <2 x i1> @llvm.isnan.v2f128(<2 x fp128>)
486 declare <4 x i1> @llvm.isnan.v4f16(<4 x half>)
487 declare <4 x i1> @llvm.isnan.v4bf16(<4 x bfloat>)
488 declare <4 x i1> @llvm.isnan.v4f32(<4 x float>)
489 declare <4 x i1> @llvm.isnan.v4f64(<4 x double>)
490 declare <4 x i1> @llvm.isnan.v4f128(<4 x fp128>)