diff --git a/llvm/lib/Target/VE/VEISelLowering.cpp b/llvm/lib/Target/VE/VEISelLowering.cpp --- a/llvm/lib/Target/VE/VEISelLowering.cpp +++ b/llvm/lib/Target/VE/VEISelLowering.cpp @@ -808,7 +808,11 @@ // VE doesn't have following floating point math functions. for (MVT VT : MVT::fp_valuetypes()) { + setOperationAction(ISD::FABS, VT, Expand); setOperationAction(ISD::FCOPYSIGN, VT, Expand); + setOperationAction(ISD::FCOS, VT, Expand); + setOperationAction(ISD::FSIN, VT, Expand); + setOperationAction(ISD::FSQRT, VT, Expand); } /// } Floating-point math functions diff --git a/llvm/test/CodeGen/VE/fabs.ll b/llvm/test/CodeGen/VE/fabs.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/VE/fabs.ll @@ -0,0 +1,138 @@ +; RUN: llc < %s -mtriple=ve | FileCheck %s + +;;; Test ‘llvm.fabs.*’ Intrinsic +;;; +;;; Syntax: +;;; This is an overloaded intrinsic. You can use llvm.fabs on any +;;; floating-point or vector of floating-point type. Not all targets +;;; support all types however. +;;; +;;; declare float @llvm.fabs.f32(float %Val) +;;; declare double @llvm.fabs.f64(double %Val) +;;; declare x86_fp80 @llvm.fabs.f80(x86_fp80 %Val) +;;; declare fp128 @llvm.fabs.f128(fp128 %Val) +;;; declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %Val) +;;; +;;; Overview: +;;; The ‘llvm.fabs.*’ intrinsics return the absolute value of the operand. +;;; +;;; Arguments: +;;; The argument and return value are floating-point numbers of the same +;;; type. +;;; +;;; Semantics: +;;; This function returns the same values as the libm fabs functions would, +;;; and handles error conditions in the same way. +;;; +;;; Note: +;;; We test only float/double/fp128. + +; Function Attrs: nounwind readnone +define float @fabs_float_var(float %0) { +; CHECK-LABEL: fabs_float_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: sra.l %s0, %s0, 32 +; CHECK-NEXT: and %s0, %s0, (33)0 +; CHECK-NEXT: sll %s0, %s0, 32 +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast float @llvm.fabs.f32(float %0) + ret float %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare float @llvm.fabs.f32(float) + +; Function Attrs: nounwind readnone +define double @fabs_double_var(double %0) { +; CHECK-LABEL: fabs_double_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: and %s0, %s0, (1)0 +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast double @llvm.fabs.f64(double %0) + ret double %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare double @llvm.fabs.f64(double) + +; Function Attrs: nounwind readnone +define fp128 @fabs_quad_var(fp128 %0) { +; CHECK-LABEL: fabs_quad_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: st %s1, 176(, %s11) +; CHECK-NEXT: st %s0, 184(, %s11) +; CHECK-NEXT: ld1b.zx %s0, 191(, %s11) +; CHECK-NEXT: and %s0, %s0, (57)0 +; CHECK-NEXT: st1b %s0, 191(, %s11) +; CHECK-NEXT: ld %s1, 176(, %s11) +; CHECK-NEXT: ld %s0, 184(, %s11) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast fp128 @llvm.fabs.f128(fp128 %0) + ret fp128 %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare fp128 @llvm.fabs.f128(fp128) + +; Function Attrs: norecurse nounwind readnone +define float @fabs_float_zero() { +; CHECK-LABEL: fabs_float_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 0 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 0.000000e+00 +} + +; Function Attrs: norecurse nounwind readnone +define double @fabs_double_zero() { +; CHECK-LABEL: fabs_double_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 0 +; CHECK-NEXT: or %s11, 0, %s9 + ret double 0.000000e+00 +} + +; Function Attrs: norecurse nounwind readnone +define fp128 @fabs_quad_zero() { +; CHECK-LABEL: fabs_quad_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: or %s11, 0, %s9 + ret fp128 0xL00000000000000000000000000000000 +} + +; Function Attrs: norecurse nounwind readnone +define float @fabs_float_const() { +; CHECK-LABEL: fabs_float_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 1073741824 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 2.000000e+00 +} + +; Function Attrs: norecurse nounwind readnone +define double @fabs_double_const() { +; CHECK-LABEL: fabs_double_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 1073741824 +; CHECK-NEXT: or %s11, 0, %s9 + ret double 2.000000e+00 +} + +; Function Attrs: nounwind readnone +define fp128 @fabs_quad_const() { +; CHECK-LABEL: fabs_quad_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.fabs.f128(fp128 0xL0000000000000000C000000000000000) + ret fp128 %1 +} diff --git a/llvm/test/CodeGen/VE/fp_copysign.ll b/llvm/test/CodeGen/VE/fcopysign.ll rename from llvm/test/CodeGen/VE/fp_copysign.ll rename to llvm/test/CodeGen/VE/fcopysign.ll --- a/llvm/test/CodeGen/VE/fp_copysign.ll +++ b/llvm/test/CodeGen/VE/fcopysign.ll @@ -41,7 +41,7 @@ ; CHECK-NEXT: or %s0, %s0, %s1 ; CHECK-NEXT: sll %s0, %s0, 32 ; CHECK-NEXT: or %s11, 0, %s9 - %3 = tail call float @llvm.copysign.f32(float %0, float %1) + %3 = tail call fast float @llvm.copysign.f32(float %0, float %1) ret float %3 } @@ -56,7 +56,7 @@ ; CHECK-NEXT: and %s0, %s0, (1)0 ; CHECK-NEXT: or %s0, %s0, %s1 ; CHECK-NEXT: or %s11, 0, %s9 - %3 = tail call double @llvm.copysign.f64(double %0, double %1) + %3 = tail call fast double @llvm.copysign.f64(double %0, double %1) ret double %3 } @@ -81,7 +81,7 @@ ; CHECK-NEXT: ld %s1, 176(, %s11) ; CHECK-NEXT: ld %s0, 184(, %s11) ; CHECK-NEXT: or %s11, 0, %s9 - %3 = tail call fp128 @llvm.copysign.f128(fp128 %0, fp128 %1) + %3 = tail call fast fp128 @llvm.copysign.f128(fp128 %0, fp128 %1) ret fp128 %3 } @@ -98,7 +98,7 @@ ; CHECK-NEXT: and %s0, %s0, %s1 ; CHECK-NEXT: sll %s0, %s0, 32 ; CHECK-NEXT: or %s11, 0, %s9 - %2 = tail call float @llvm.copysign.f32(float 0.000000e+00, float %0) + %2 = tail call fast float @llvm.copysign.f32(float 0.000000e+00, float %0) ret float %2 } @@ -108,7 +108,7 @@ ; CHECK: .LBB{{[0-9]+}}_2: ; CHECK-NEXT: and %s0, %s0, (1)1 ; CHECK-NEXT: or %s11, 0, %s9 - %2 = tail call double @llvm.copysign.f64(double 0.000000e+00, double %0) + %2 = tail call fast double @llvm.copysign.f64(double 0.000000e+00, double %0) ret double %2 } @@ -135,7 +135,7 @@ ; CHECK-NEXT: ld %s1, 176(, %s11) ; CHECK-NEXT: ld %s0, 184(, %s11) ; CHECK-NEXT: or %s11, 0, %s9 - %2 = tail call fp128 @llvm.copysign.f128(fp128 0xL00000000000000000000000000000000, fp128 %0) + %2 = tail call fast fp128 @llvm.copysign.f128(fp128 0xL00000000000000000000000000000000, fp128 %0) ret fp128 %2 } @@ -151,7 +151,7 @@ ; CHECK-NEXT: or %s0, %s0, %s1 ; CHECK-NEXT: sll %s0, %s0, 32 ; CHECK-NEXT: or %s11, 0, %s9 - %2 = tail call float @llvm.copysign.f32(float -2.000000e+00, float %0) + %2 = tail call fast float @llvm.copysign.f32(float -2.000000e+00, float %0) ret float %2 } @@ -163,7 +163,7 @@ ; CHECK-NEXT: lea.sl %s1, 1073741824 ; CHECK-NEXT: or %s0, %s0, %s1 ; CHECK-NEXT: or %s11, 0, %s9 - %2 = tail call double @llvm.copysign.f64(double -2.000000e+00, double %0) + %2 = tail call fast double @llvm.copysign.f64(double -2.000000e+00, double %0) ret double %2 } @@ -190,6 +190,6 @@ ; CHECK-NEXT: ld %s1, 176(, %s11) ; CHECK-NEXT: ld %s0, 184(, %s11) ; CHECK-NEXT: or %s11, 0, %s9 - %2 = tail call fp128 @llvm.copysign.f128(fp128 0xL0000000000000000C000000000000000, fp128 %0) + %2 = tail call fast fp128 @llvm.copysign.f128(fp128 0xL0000000000000000C000000000000000, fp128 %0) ret fp128 %2 } diff --git a/llvm/test/CodeGen/VE/fcos.ll b/llvm/test/CodeGen/VE/fcos.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/VE/fcos.ll @@ -0,0 +1,151 @@ +; RUN: llc < %s -mtriple=ve | FileCheck %s + +;;; Test ‘llvm.cos.*’ intrinsic +;;; +;;; Syntax: +;;; This is an overloaded intrinsic. You can use llvm.cos on any +;;; floating-point or vector of floating-point type. Not all targets +;;; support all types however. +;;; +;;; declare float @llvm.cos.f32(float %Val) +;;; declare double @llvm.cos.f64(double %Val) +;;; declare x86_fp80 @llvm.cos.f80(x86_fp80 %Val) +;;; declare fp128 @llvm.cos.f128(fp128 %Val) +;;; declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128 %Val) +;;; +;;; Overview: +;;; The ‘llvm.cos.*’ intrinsics return the cosine of the operand. +;;; +;;; Arguments: +;;; The argument and return value are floating-point numbers of the same type. +;;; +;;; Semantics: +;;; Return the same value as a corresponding libm ‘cos’ function but without +;;; trapping or setting errno. +;;; +;;; When specified with the fast-math-flag ‘afn’, the result may be +;;; approximated using a less accurate calculation. +;;; +;;; Note: +;;; We test only float/double/fp128. + +; Function Attrs: nounwind readnone +define float @fcos_float_var(float %0) { +; CHECK-LABEL: fcos_float_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s1, cosf@lo +; CHECK-NEXT: and %s1, %s1, (32)0 +; CHECK-NEXT: lea.sl %s12, cosf@hi(, %s1) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast float @llvm.cos.f32(float %0) + ret float %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare float @llvm.cos.f32(float) + +; Function Attrs: nounwind readnone +define double @fcos_double_var(double %0) { +; CHECK-LABEL: fcos_double_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s1, cos@lo +; CHECK-NEXT: and %s1, %s1, (32)0 +; CHECK-NEXT: lea.sl %s12, cos@hi(, %s1) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast double @llvm.cos.f64(double %0) + ret double %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare double @llvm.cos.f64(double) + +; Function Attrs: nounwind readnone +define fp128 @fcos_quad_var(fp128 %0) { +; CHECK-LABEL: fcos_quad_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s2, cosl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast fp128 @llvm.cos.f128(fp128 %0) + ret fp128 %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare fp128 @llvm.cos.f128(fp128) + +; Function Attrs: norecurse nounwind readnone +define float @fcos_float_zero() { +; CHECK-LABEL: fcos_float_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 1065353216 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 1.000000e+00 +} + +; Function Attrs: norecurse nounwind readnone +define double @fcos_double_zero() { +; CHECK-LABEL: fcos_double_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 1072693248 +; CHECK-NEXT: or %s11, 0, %s9 + ret double 1.000000e+00 +} + +; Function Attrs: nounwind readnone +define fp128 @fcos_quad_zero() { +; CHECK-LABEL: fcos_quad_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: lea %s2, cosl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.cos.f128(fp128 0xL00000000000000000000000000000000) + ret fp128 %1 +} + +; Function Attrs: norecurse nounwind readnone +define float @fcos_float_const() { +; CHECK-LABEL: fcos_float_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, -1093332685 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 0xBFDAA22660000000 +} + +; Function Attrs: norecurse nounwind readnone +define double @fcos_double_const() { +; CHECK-LABEL: fcos_double_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, 1465086469 +; CHECK-NEXT: lea.sl %s0, -1076190682(, %s0) +; CHECK-NEXT: or %s11, 0, %s9 + ret double 0xBFDAA22657537205 +} + +; Function Attrs: nounwind readnone +define fp128 @fcos_quad_const() { +; CHECK-LABEL: fcos_quad_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: lea %s2, cosl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.cos.f128(fp128 0xL0000000000000000C000000000000000) + ret fp128 %1 +} diff --git a/llvm/test/CodeGen/VE/fsin.ll b/llvm/test/CodeGen/VE/fsin.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/VE/fsin.ll @@ -0,0 +1,152 @@ +; RUN: llc < %s -mtriple=ve | FileCheck %s + +;;; Test ‘llvm.sin.*’ intrinsic +;;; +;;; Syntax: +;;; This is an overloaded intrinsic. You can use llvm.sin on any +;;; floating-point or vector of floating-point type. Not all targets +;;; support all types however. +;;; +;;; declare float @llvm.sin.f32(float %Val) +;;; declare double @llvm.sin.f64(double %Val) +;;; declare x86_fp80 @llvm.sin.f80(x86_fp80 %Val) +;;; declare fp128 @llvm.sin.f128(fp128 %Val) +;;; declare ppc_fp128 @llvm.sin.ppcf128(ppc_fp128 %Val) +;;; +;;; Overview: +;;; The ‘llvm.sin.*’ intrinsics return the sine of the operand. +;;; +;;; Arguments: +;;; The argument and return value are floating-point numbers of the same type. +;;; +;;; Semantics: +;;; Return the same value as a corresponding libm ‘sin’ function but without +;;; trapping or setting errno. +;;; +;;; When specified with the fast-math-flag ‘afn’, the result may be +;;; approximated using a less accurate calculation. +;;; +;;; Note: +;;; We test only float/double/fp128. + +; Function Attrs: nounwind readnone +define float @fsin_float_var(float %0) { +; CHECK-LABEL: fsin_float_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s1, sinf@lo +; CHECK-NEXT: and %s1, %s1, (32)0 +; CHECK-NEXT: lea.sl %s12, sinf@hi(, %s1) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast float @llvm.sin.f32(float %0) + ret float %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare float @llvm.sin.f32(float) + +; Function Attrs: nounwind readnone +define double @fsin_double_var(double %0) { +; CHECK-LABEL: fsin_double_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s1, sin@lo +; CHECK-NEXT: and %s1, %s1, (32)0 +; CHECK-NEXT: lea.sl %s12, sin@hi(, %s1) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast double @llvm.sin.f64(double %0) + ret double %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare double @llvm.sin.f64(double) + +; Function Attrs: nounwind readnone +define fp128 @fsin_quad_var(fp128 %0) { +; CHECK-LABEL: fsin_quad_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s2, sinl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, sinl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast fp128 @llvm.sin.f128(fp128 %0) + ret fp128 %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare fp128 @llvm.sin.f128(fp128) + +; Function Attrs: norecurse nounwind readnone +define float @fsin_float_zero() { +; CHECK-LABEL: fsin_float_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 0 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 0.000000e+00 +} + +; Function Attrs: norecurse nounwind readnone +define double @fsin_double_zero() { +; CHECK-LABEL: fsin_double_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 0 +; CHECK-NEXT: or %s11, 0, %s9 + ret double 0.000000e+00 +} + +; Function Attrs: nounwind readnone +define fp128 @fsin_quad_zero() { +; CHECK-LABEL: fsin_quad_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: lea %s2, sinl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, sinl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.sin.f128(fp128 0xL00000000000000000000000000000000) + ret fp128 %1 +} + +; Function Attrs: norecurse nounwind readnone +define float @fsin_float_const() { +; CHECK-LABEL: fsin_float_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, -1083652169 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 0xBFED18F6E0000000 +} + +; Function Attrs: norecurse nounwind readnone +define double @fsin_double_const() { +; CHECK-LABEL: fsin_double_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, -355355578 +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s0, -1074980618(, %s0) +; CHECK-NEXT: or %s11, 0, %s9 + ret double 0xBFED18F6EAD1B446 +} + +; Function Attrs: nounwind readnone +define fp128 @fsin_quad_const() { +; CHECK-LABEL: fsin_quad_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: lea %s2, sinl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, sinl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.sin.f128(fp128 0xL0000000000000000C000000000000000) + ret fp128 %1 +} diff --git a/llvm/test/CodeGen/VE/fsqrt.ll b/llvm/test/CodeGen/VE/fsqrt.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/VE/fsqrt.ll @@ -0,0 +1,151 @@ +; RUN: llc < %s -mtriple=ve | FileCheck %s + +;;; Test ‘llvm.sqrt.*’ intrinsic +;;; +;;; Syntax: +;;; This is an overloaded intrinsic. You can use llvm.sqrt on any +;;; floating-point or vector of floating-point type. Not all targets +;;; support all types however. +;;; +;;; declare float @llvm.sqrt.f32(float %Val) +;;; declare double @llvm.sqrt.f64(double %Val) +;;; declare x86_fp80 @llvm.sqrt.f80(x86_fp80 %Val) +;;; declare fp128 @llvm.sqrt.f128(fp128 %Val) +;;; declare ppc_fp128 @llvm.sqrt.ppcf128(ppc_fp128 %Val) +;;; +;;; Overview: +;;; The ‘llvm.sqrt’ intrinsics return the square root of the specified value. +;;; +;;; Arguments: +;;; The argument and return value are floating-point numbers of the same type. +;;; +;;; Semantics: +;;; Return the same value as a corresponding libm ‘sqrt’ function but without +;;; trapping or setting errno. For types specified by IEEE-754, the result +;;; matches a conforming libm implementation. +;;; +;;; When specified with the fast-math-flag ‘afn’, the result may be +;;; approximated using a less accurate calculation. +;;; +;;; Note: +;;; We test only float/double/fp128. + +; Function Attrs: nounwind readnone +define float @fsqrt_float_var(float %0) { +; CHECK-LABEL: fsqrt_float_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s1, sqrtf@lo +; CHECK-NEXT: and %s1, %s1, (32)0 +; CHECK-NEXT: lea.sl %s12, sqrtf@hi(, %s1) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast float @llvm.sqrt.f32(float %0) + ret float %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare float @llvm.sqrt.f32(float) + +; Function Attrs: nounwind readnone +define double @fsqrt_double_var(double %0) { +; CHECK-LABEL: fsqrt_double_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s1, sqrt@lo +; CHECK-NEXT: and %s1, %s1, (32)0 +; CHECK-NEXT: lea.sl %s12, sqrt@hi(, %s1) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast double @llvm.sqrt.f64(double %0) + ret double %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare double @llvm.sqrt.f64(double) + +; Function Attrs: nounwind readnone +define fp128 @fsqrt_quad_var(fp128 %0) { +; CHECK-LABEL: fsqrt_quad_var: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s2, sqrtl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, sqrtl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %2 = tail call fast fp128 @llvm.sqrt.f128(fp128 %0) + ret fp128 %2 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare fp128 @llvm.sqrt.f128(fp128) + +; Function Attrs: norecurse nounwind readnone +define float @fsqrt_float_zero() { +; CHECK-LABEL: fsqrt_float_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 0 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 0.000000e+00 +} + +; Function Attrs: norecurse nounwind readnone +define double @fsqrt_double_zero() { +; CHECK-LABEL: fsqrt_double_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, 0 +; CHECK-NEXT: or %s11, 0, %s9 + ret double 0.000000e+00 +} + +; Function Attrs: nounwind readnone +define fp128 @fsqrt_quad_zero() { +; CHECK-LABEL: fsqrt_quad_zero: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: lea %s2, sqrtl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, sqrtl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.sqrt.f128(fp128 0xL00000000000000000000000000000000) + ret fp128 %1 +} + +; Function Attrs: norecurse nounwind readnone +define float @fsqrt_float_const() { +; CHECK-LABEL: fsqrt_float_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, -4194304 +; CHECK-NEXT: or %s11, 0, %s9 + ret float 0xFFF8000000000000 +} + +; Function Attrs: norecurse nounwind readnone +define double @fsqrt_double_const() { +; CHECK-LABEL: fsqrt_double_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea.sl %s0, -524288 +; CHECK-NEXT: or %s11, 0, %s9 + ret double 0xFFF8000000000000 +} + +; Function Attrs: nounwind readnone +define fp128 @fsqrt_quad_const() { +; CHECK-LABEL: fsqrt_quad_const: +; CHECK: .LBB{{[0-9]+}}_2: +; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo +; CHECK-NEXT: and %s0, %s0, (32)0 +; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0) +; CHECK-NEXT: ld %s0, 8(, %s2) +; CHECK-NEXT: ld %s1, (, %s2) +; CHECK-NEXT: lea %s2, sqrtl@lo +; CHECK-NEXT: and %s2, %s2, (32)0 +; CHECK-NEXT: lea.sl %s12, sqrtl@hi(, %s2) +; CHECK-NEXT: bsic %s10, (, %s12) +; CHECK-NEXT: or %s11, 0, %s9 + %1 = tail call fast fp128 @llvm.sqrt.f128(fp128 0xL0000000000000000C000000000000000) + ret fp128 %1 +}