1 ; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+neon,+fullfp16 < %s -o -| FileCheck %s
3 declare half @llvm.fabs.f16(half)
4 declare float @llvm.fabs.f32(float)
5 declare double @llvm.fabs.f64(double)
6 declare fp128 @llvm.fabs.f128(fp128)
8 ; INFINITY requires loading the constant for _Float16
9 define i32 @replace_isinf_call_f16(half %x) {
10 ; CHECK-LABEL: replace_isinf_call_f16:
11 ; CHECK: adrp [[ADDR:x[0-9]+]], [[CSTLABEL:.LCP.*]]
12 ; CHECK: ldr [[INFINITY:h[0-9]+]], {{[[]}}[[ADDR]], :lo12:[[CSTLABEL]]{{[]]}}
13 ; CHECK-NEXT: fabs [[ABS:h[0-9]+]], h0
14 ; CHECK-NEXT: fcmp [[ABS]], [[INFINITY]]
15 ; CHECK-NEXT: cset w0, eq
16 %abs = tail call half @llvm.fabs.f16(half %x)
17 %cmpinf = fcmp oeq half %abs, 0xH7C00
18 %ret = zext i1 %cmpinf to i32
22 ; Check if INFINITY for float is materialized
23 define i32 @replace_isinf_call_f32(float %x) {
24 ; CHECK-LABEL: replace_isinf_call_f32:
25 ; CHECK: mov [[INFSCALARREG:w[0-9]+]], #2139095040
26 ; CHECK-NEXT: fabs [[ABS:s[0-9]+]], s0
27 ; CHECK-NEXT: fmov [[INFREG:s[0-9]+]], [[INFSCALARREG]]
28 ; CHECK-NEXT: fcmp [[ABS]], [[INFREG]]
29 ; CHECK-NEXT: cset w0, eq
30 %abs = tail call float @llvm.fabs.f32(float %x)
31 %cmpinf = fcmp oeq float %abs, 0x7FF0000000000000
32 %ret = zext i1 %cmpinf to i32
36 ; Check if INFINITY for double is materialized
37 define i32 @replace_isinf_call_f64(double %x) {
38 ; CHECK-LABEL: replace_isinf_call_f64:
39 ; CHECK: mov [[INFSCALARREG:x[0-9]+]], #9218868437227405312
40 ; CHECK-NEXT: fabs [[ABS:d[0-9]+]], d0
41 ; CHECK-NEXT: fmov [[INFREG:d[0-9]+]], [[INFSCALARREG]]
42 ; CHECK-NEXT: fcmp [[ABS]], [[INFREG]]
43 ; CHECK-NEXT: cset w0, eq
44 %abs = tail call double @llvm.fabs.f64(double %x)
45 %cmpinf = fcmp oeq double %abs, 0x7FF0000000000000
46 %ret = zext i1 %cmpinf to i32
50 ; For long double it still requires loading the constant.
51 define i32 @replace_isinf_call_f128(fp128 %x) {
52 ; CHECK-LABEL: replace_isinf_call_f128:
53 ; CHECK: adrp [[ADDR:x[0-9]+]], [[CSTLABEL:.LCP.*]]
54 ; CHECK: ldr q1, {{[[]}}[[ADDR]], :lo12:[[CSTLABEL]]{{[]]}}
58 %abs = tail call fp128 @llvm.fabs.f128(fp128 %x)
59 %cmpinf = fcmp oeq fp128 %abs, 0xL00000000000000007FFF000000000000
60 %ret = zext i1 %cmpinf to i32