1 ; RUN: llc < %s -mtriple=ve | FileCheck %s
3 ;;; Test ‘llvm.fabs.*’ Intrinsic
6 ;;; This is an overloaded intrinsic. You can use llvm.fabs on any
7 ;;; floating-point or vector of floating-point type. Not all targets
8 ;;; support all types however.
10 ;;; declare float @llvm.fabs.f32(float %Val)
11 ;;; declare double @llvm.fabs.f64(double %Val)
12 ;;; declare x86_fp80 @llvm.fabs.f80(x86_fp80 %Val)
13 ;;; declare fp128 @llvm.fabs.f128(fp128 %Val)
14 ;;; declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %Val)
17 ;;; The ‘llvm.fabs.*’ intrinsics return the absolute value of the operand.
20 ;;; The argument and return value are floating-point numbers of the same
24 ;;; This function returns the same values as the libm fabs functions would,
25 ;;; and handles error conditions in the same way.
28 ;;; We test only float/double/fp128.
30 ; Function Attrs: nounwind readnone
31 define float @fabs_float_var(float %0) {
32 ; CHECK-LABEL: fabs_float_var:
34 ; CHECK-NEXT: sra.l %s0, %s0, 32
35 ; CHECK-NEXT: and %s0, %s0, (33)0
36 ; CHECK-NEXT: sll %s0, %s0, 32
37 ; CHECK-NEXT: b.l.t (, %s10)
38 %2 = tail call fast float @llvm.fabs.f32(float %0)
42 ; Function Attrs: nounwind readnone speculatable willreturn
43 declare float @llvm.fabs.f32(float)
45 ; Function Attrs: nounwind readnone
46 define double @fabs_double_var(double %0) {
47 ; CHECK-LABEL: fabs_double_var:
49 ; CHECK-NEXT: and %s0, %s0, (1)0
50 ; CHECK-NEXT: b.l.t (, %s10)
51 %2 = tail call fast double @llvm.fabs.f64(double %0)
55 ; Function Attrs: nounwind readnone speculatable willreturn
56 declare double @llvm.fabs.f64(double)
58 ; Function Attrs: nounwind readnone
59 define fp128 @fabs_quad_var(fp128 %0) {
60 ; CHECK-LABEL: fabs_quad_var:
61 ; CHECK: .LBB{{[0-9]+}}_2:
62 ; CHECK-NEXT: st %s1, (, %s11)
63 ; CHECK-NEXT: st %s0, 8(, %s11)
64 ; CHECK-NEXT: ld1b.zx %s0, 15(, %s11)
65 ; CHECK-NEXT: and %s0, %s0, (57)0
66 ; CHECK-NEXT: st1b %s0, 15(, %s11)
67 ; CHECK-NEXT: ld %s1, (, %s11)
68 ; CHECK-NEXT: ld %s0, 8(, %s11)
69 ; CHECK-NEXT: adds.l %s11, 16, %s11
70 ; CHECK-NEXT: b.l.t (, %s10)
71 %2 = tail call fast fp128 @llvm.fabs.f128(fp128 %0)
75 ; Function Attrs: nounwind readnone speculatable willreturn
76 declare fp128 @llvm.fabs.f128(fp128)
78 ; Function Attrs: norecurse nounwind readnone
79 define float @fabs_float_zero() {
80 ; CHECK-LABEL: fabs_float_zero:
82 ; CHECK-NEXT: lea.sl %s0, 0
83 ; CHECK-NEXT: b.l.t (, %s10)
84 ret float 0.000000e+00
87 ; Function Attrs: norecurse nounwind readnone
88 define double @fabs_double_zero() {
89 ; CHECK-LABEL: fabs_double_zero:
91 ; CHECK-NEXT: lea.sl %s0, 0
92 ; CHECK-NEXT: b.l.t (, %s10)
93 ret double 0.000000e+00
96 ; Function Attrs: norecurse nounwind readnone
97 define fp128 @fabs_quad_zero() {
98 ; CHECK-LABEL: fabs_quad_zero:
100 ; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo
101 ; CHECK-NEXT: and %s0, %s0, (32)0
102 ; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)
103 ; CHECK-NEXT: ld %s0, 8(, %s2)
104 ; CHECK-NEXT: ld %s1, (, %s2)
105 ; CHECK-NEXT: b.l.t (, %s10)
106 ret fp128 0xL00000000000000000000000000000000
109 ; Function Attrs: norecurse nounwind readnone
110 define float @fabs_float_const() {
111 ; CHECK-LABEL: fabs_float_const:
113 ; CHECK-NEXT: lea.sl %s0, 1073741824
114 ; CHECK-NEXT: b.l.t (, %s10)
115 ret float 2.000000e+00
118 ; Function Attrs: norecurse nounwind readnone
119 define double @fabs_double_const() {
120 ; CHECK-LABEL: fabs_double_const:
122 ; CHECK-NEXT: lea.sl %s0, 1073741824
123 ; CHECK-NEXT: b.l.t (, %s10)
124 ret double 2.000000e+00
127 ; Function Attrs: nounwind readnone
128 define fp128 @fabs_quad_const() {
129 ; CHECK-LABEL: fabs_quad_const:
131 ; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo
132 ; CHECK-NEXT: and %s0, %s0, (32)0
133 ; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)
134 ; CHECK-NEXT: ld %s0, 8(, %s2)
135 ; CHECK-NEXT: ld %s1, (, %s2)
136 ; CHECK-NEXT: b.l.t (, %s10)
137 %1 = tail call fast fp128 @llvm.fabs.f128(fp128 0xL0000000000000000C000000000000000)