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: mov w8, #-2147483648
26 ; CHECK-NEXT: fmov s2, w8
27 ; CHECK-NEXT: fneg s1, s0
28 ; CHECK-NEXT: fcmp s0, s2
29 ; CHECK-NEXT: fcsel s0, s0, s1, ge
31 %cmp = fcmp nnan oge float %x, -0.0
32 %sub = fsub nnan float -0.0, %x
33 %cond = select i1 %cmp, float %x, float %sub
37 define float @nabsf(float %a) {
40 ; CHECK-NEXT: fabs s0, s0
41 ; CHECK-NEXT: fneg s0, s0
43 %conv = bitcast float %a to i32
44 %and = or i32 %conv, -2147483648
45 %conv1 = bitcast i32 %and to float
49 define double @nabsd(double %a) {
52 ; CHECK-NEXT: fabs d0, d0
53 ; CHECK-NEXT: fneg d0, d0
55 %conv = bitcast double %a to i64
56 %and = or i64 %conv, -9223372036854775808
57 %conv1 = bitcast i64 %and to double
61 define <4 x float> @nabsv4f32(<4 x float> %a) {
62 ; CHECK-LABEL: nabsv4f32:
64 ; CHECK-NEXT: orr v0.4s, #128, lsl #24
66 %conv = bitcast <4 x float> %a to <4 x i32>
67 %and = or <4 x i32> %conv, <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>
68 %conv1 = bitcast <4 x i32> %and to <4 x float>
69 ret <4 x float> %conv1
72 define <2 x double> @nabsv2d64(<2 x double> %a) {
73 ; CHECK-LABEL: nabsv2d64:
75 ; CHECK-NEXT: mov x8, #-9223372036854775808
76 ; CHECK-NEXT: dup v1.2d, x8
77 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
79 %conv = bitcast <2 x double> %a to <2 x i64>
80 %and = or <2 x i64> %conv, <i64 -9223372036854775808, i64 -9223372036854775808>
81 %conv1 = bitcast <2 x i64> %and to <2 x double>
82 ret <2 x double> %conv1
85 attributes #0 = { "no-nans-fp-math"="true" }