1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-unknown-unknown | FileCheck %s
4 ; Test against PR36600: https://bugs.llvm.org/show_bug.cgi?id=36600
5 ; This is not fabs. If X = -0.0, it should return -0.0 not 0.0.
7 define double @not_fabs(double %x) #0 {
8 ; CHECK-LABEL: not_fabs:
10 ; CHECK-NEXT: fneg d1, d0
11 ; CHECK-NEXT: fcmp d0, #0.0
12 ; CHECK-NEXT: fcsel d0, d1, d0, le
14 %cmp = fcmp nnan ole double %x, 0.0
15 %sub = fsub nnan double -0.0, %x
16 %cond = select i1 %cmp, double %sub, double %x
20 ; Try again with different type, predicate, and compare constant.
22 define float @still_not_fabs(float %x) #0 {
23 ; CHECK-LABEL: still_not_fabs:
25 ; CHECK-NEXT: movi v1.2s, #128, lsl #24
26 ; CHECK-NEXT: fneg s2, s0
27 ; CHECK-NEXT: fcmp s0, s1
28 ; CHECK-NEXT: fcsel s0, s0, s2, ge
30 %cmp = fcmp nnan oge float %x, -0.0
31 %sub = fsub nnan float -0.0, %x
32 %cond = select i1 %cmp, float %x, float %sub
36 define float @nabsf(float %a) {
39 ; CHECK-NEXT: fabs s0, s0
40 ; CHECK-NEXT: fneg s0, s0
42 %conv = bitcast float %a to i32
43 %and = or i32 %conv, -2147483648
44 %conv1 = bitcast i32 %and to float
48 define double @nabsd(double %a) {
51 ; CHECK-NEXT: fabs d0, d0
52 ; CHECK-NEXT: fneg d0, d0
54 %conv = bitcast double %a to i64
55 %and = or i64 %conv, -9223372036854775808
56 %conv1 = bitcast i64 %and to double
60 define <4 x float> @nabsv4f32(<4 x float> %a) {
61 ; CHECK-LABEL: nabsv4f32:
63 ; CHECK-NEXT: orr v0.4s, #128, lsl #24
65 %conv = bitcast <4 x float> %a to <4 x i32>
66 %and = or <4 x i32> %conv, <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>
67 %conv1 = bitcast <4 x i32> %and to <4 x float>
68 ret <4 x float> %conv1
71 define <2 x double> @nabsv2d64(<2 x double> %a) {
72 ; CHECK-LABEL: nabsv2d64:
74 ; CHECK-NEXT: movi v1.2d, #0000000000000000
75 ; CHECK-NEXT: fneg v1.2d, v1.2d
76 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
78 %conv = bitcast <2 x double> %a to <2 x i64>
79 %and = or <2 x i64> %conv, <i64 -9223372036854775808, i64 -9223372036854775808>
80 %conv1 = bitcast <2 x i64> %and to <2 x double>
81 ret <2 x double> %conv1
84 attributes #0 = { "no-nans-fp-math"="true" }