1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+neon,+fullfp16 < %s -o -| FileCheck %s
4 declare half @llvm.fabs.f16(half)
5 declare float @llvm.fabs.f32(float)
6 declare double @llvm.fabs.f64(double)
7 declare fp128 @llvm.fabs.f128(fp128)
9 ; Check if INFINITY for _Float16 is materialized
10 define i32 @replace_isinf_call_f16(half %x) {
11 ; CHECK-LABEL: replace_isinf_call_f16:
13 ; CHECK-NEXT: mov w8, #31744 // =0x7c00
14 ; CHECK-NEXT: fabs h0, h0
15 ; CHECK-NEXT: fmov h1, w8
16 ; CHECK-NEXT: fcmp h0, h1
17 ; CHECK-NEXT: cset w0, eq
19 %abs = tail call half @llvm.fabs.f16(half %x)
20 %cmpinf = fcmp oeq half %abs, 0xH7C00
21 %ret = zext i1 %cmpinf to i32
25 ; Check if INFINITY for float is materialized
26 define i32 @replace_isinf_call_f32(float %x) {
27 ; CHECK-LABEL: replace_isinf_call_f32:
29 ; CHECK-NEXT: fabs s0, s0
30 ; CHECK-NEXT: mov w8, #2139095040 // =0x7f800000
31 ; CHECK-NEXT: fmov s1, w8
32 ; CHECK-NEXT: fcmp s0, s1
33 ; CHECK-NEXT: cset w0, eq
35 %abs = tail call float @llvm.fabs.f32(float %x)
36 %cmpinf = fcmp oeq float %abs, 0x7FF0000000000000
37 %ret = zext i1 %cmpinf to i32
41 ; Check if INFINITY for double is materialized
42 define i32 @replace_isinf_call_f64(double %x) {
43 ; CHECK-LABEL: replace_isinf_call_f64:
45 ; CHECK-NEXT: fabs d0, d0
46 ; CHECK-NEXT: mov x8, #9218868437227405312 // =0x7ff0000000000000
47 ; CHECK-NEXT: fmov d1, x8
48 ; CHECK-NEXT: fcmp d0, d1
49 ; CHECK-NEXT: cset w0, eq
51 %abs = tail call double @llvm.fabs.f64(double %x)
52 %cmpinf = fcmp oeq double %abs, 0x7FF0000000000000
53 %ret = zext i1 %cmpinf to i32
57 ; For long double it still requires loading the constant.
58 define i32 @replace_isinf_call_f128(fp128 %x) {
59 ; CHECK-LABEL: replace_isinf_call_f128:
61 ; CHECK-NEXT: sub sp, sp, #32
62 ; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
63 ; CHECK-NEXT: .cfi_def_cfa_offset 32
64 ; CHECK-NEXT: .cfi_offset w30, -16
65 ; CHECK-NEXT: str q0, [sp]
66 ; CHECK-NEXT: ldrb w8, [sp, #15]
67 ; CHECK-NEXT: and w8, w8, #0x7f
68 ; CHECK-NEXT: strb w8, [sp, #15]
69 ; CHECK-NEXT: adrp x8, .LCPI3_0
70 ; CHECK-NEXT: ldr q0, [sp]
71 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI3_0]
72 ; CHECK-NEXT: bl __eqtf2
73 ; CHECK-NEXT: cmp w0, #0
74 ; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
75 ; CHECK-NEXT: cset w0, eq
76 ; CHECK-NEXT: add sp, sp, #32
78 %abs = tail call fp128 @llvm.fabs.f128(fp128 %x)
79 %cmpinf = fcmp oeq fp128 %abs, 0xL00000000000000007FFF000000000000
80 %ret = zext i1 %cmpinf to i32