return mlir::FunctionType::get(context, {t}, {t});
}
+static mlir::FunctionType genF128F128FuncType(mlir::MLIRContext *context) {
+ mlir::Type t = mlir::FloatType::getF128(context);
+ return mlir::FunctionType::get(context, {t}, {t});
+}
+
static mlir::FunctionType genF32F32F32FuncType(mlir::MLIRContext *context) {
auto t = mlir::FloatType::getF32(context);
return mlir::FunctionType::get(context, {t, t}, {t});
static constexpr MathOperation mathOperations[] = {
{"abs", "fabsf", genF32F32FuncType, genMathOp<mlir::math::AbsOp>},
{"abs", "fabs", genF64F64FuncType, genMathOp<mlir::math::AbsOp>},
+ {"abs", "llvm.fabs.f128", genF128F128FuncType,
+ genMathOp<mlir::math::AbsOp>},
// llvm.trunc behaves the same way as libm's trunc.
{"aint", "llvm.trunc.f32", genF32F32FuncType, genLibCall},
{"aint", "llvm.trunc.f64", genF64F64FuncType, genLibCall},
{"ceil", "ceil", genF64F64FuncType, genMathOp<mlir::math::CeilOp>},
{"cos", "cosf", genF32F32FuncType, genMathOp<mlir::math::CosOp>},
{"cos", "cos", genF64F64FuncType, genMathOp<mlir::math::CosOp>},
+ {"cosh", "coshf", genF32F32FuncType, genLibCall},
+ {"cosh", "cosh", genF64F64FuncType, genLibCall},
{"erf", "erff", genF32F32FuncType, genMathOp<mlir::math::ErfOp>},
{"erf", "erf", genF64F64FuncType, genMathOp<mlir::math::ErfOp>},
{"exp", "expf", genF32F32FuncType, genMathOp<mlir::math::ExpOp>},
genMathOp<mlir::math::CopySignOp>},
{"sign", "copysign", genF64F64F64FuncType,
genMathOp<mlir::math::CopySignOp>},
+ {"sign", "copysignl", genF80F80F80FuncType,
+ genMathOp<mlir::math::CopySignOp>},
+ {"sign", "llvm.copysign.f128", genF128F128F128FuncType,
+ genMathOp<mlir::math::CopySignOp>},
{"sin", "sinf", genF32F32FuncType, genMathOp<mlir::math::SinOp>},
{"sin", "sin", genF64F64FuncType, genMathOp<mlir::math::SinOp>},
+ {"sinh", "sinhf", genF32F32FuncType, genLibCall},
+ {"sinh", "sinh", genF64F64FuncType, genLibCall},
{"sqrt", "sqrtf", genF32F32FuncType, genMathOp<mlir::math::SqrtOp>},
{"sqrt", "sqrt", genF64F64FuncType, genMathOp<mlir::math::SqrtOp>},
+ {"tan", "tanf", genF32F32FuncType, genMathOp<mlir::math::TanOp>},
+ {"tan", "tan", genF64F64FuncType, genMathOp<mlir::math::TanOp>},
{"tanh", "tanhf", genF32F32FuncType, genMathOp<mlir::math::TanhOp>},
{"tanh", "tanh", genF64F64FuncType, genMathOp<mlir::math::TanhOp>},
};
static constexpr RuntimeFunction llvmIntrinsics[] = {
{"abs", "llvm.fabs.f32", genF32F32FuncType},
{"abs", "llvm.fabs.f64", genF64F64FuncType},
+ {"abs", "llvm.fabs.f128", genF128F128FuncType},
{"aint", "llvm.trunc.f32", genF32F32FuncType},
{"aint", "llvm.trunc.f64", genF64F64FuncType},
{"anint", "llvm.round.f32", genF32F32FuncType},
// CHECK: @_QPtest_real8
// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.fabs"({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+// CHECK: @_QPtest_real16
+// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.fabs"({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+
// CHECK: @_QPtest_complex4
// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @hypotf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
%3 = fir.load %0 : !fir.ref<f64>
return %3 : f64
}
+func.func @_QPtest_real16(%arg0: !fir.ref<f128> {fir.bindc_name = "x"}) -> f128 {
+ %0 = fir.alloca f128 {bindc_name = "test_real16", uniq_name = "_QFtest_real16Etest_real16"}
+ %1 = fir.load %arg0 : !fir.ref<f128>
+ %2 = math.abs %1 : f128
+ fir.store %2 to %0 : !fir.ref<f128>
+ %3 = fir.load %0 : !fir.ref<f128>
+ return %3 : f128
+}
func.func @_QPtest_complex4(%arg0: !fir.ref<!fir.complex<4>> {fir.bindc_name = "c"}) -> !fir.complex<4> {
%0 = fir.alloca !fir.complex<4> {bindc_name = "test_complex4", uniq_name = "_QFtest_complex4Etest_complex4"}
%1 = fir.load %arg0 : !fir.ref<!fir.complex<4>>
// CHECK: @_QPtest_real8
// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.fabs"({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+// CHECK: @_QPtest_real16
+// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.fabs"({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+
// CHECK: @_QPtest_complex4
// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @hypotf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
%3 = fir.load %0 : !fir.ref<f64>
return %3 : f64
}
+func.func @_QPtest_real16(%arg0: !fir.ref<f128> {fir.bindc_name = "x"}) -> f128 {
+ %0 = fir.alloca f128 {bindc_name = "test_real16", uniq_name = "_QFtest_real16Etest_real16"}
+ %1 = fir.load %arg0 : !fir.ref<f128>
+ %2 = math.abs %1 : f128
+ fir.store %2 to %0 : !fir.ref<f128>
+ %3 = fir.load %0 : !fir.ref<f128>
+ return %3 : f128
+}
func.func @_QPtest_complex4(%arg0: !fir.ref<!fir.complex<4>> {fir.bindc_name = "c"}) -> !fir.complex<4> {
%0 = fir.alloca !fir.complex<4> {bindc_name = "test_complex4", uniq_name = "_QFtest_complex4Etest_complex4"}
%1 = fir.load %arg0 : !fir.ref<!fir.complex<4>>
// CHECK: @_QPtest_real8
// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @fabs({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+// CHECK: @_QPtest_real16
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @llvm.fabs.f128({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+
// CHECK: @_QPtest_complex4
// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @hypotf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32
%3 = fir.load %0 : !fir.ref<f64>
return %3 : f64
}
+func.func @_QPtest_real16(%arg0: !fir.ref<f128> {fir.bindc_name = "x"}) -> f128 {
+ %0 = fir.alloca f128 {bindc_name = "test_real16", uniq_name = "_QFtest_real16Etest_real16"}
+ %1 = fir.load %arg0 : !fir.ref<f128>
+ %2 = fir.call @llvm.fabs.f128(%1) : (f128) -> f128
+ fir.store %2 to %0 : !fir.ref<f128>
+ %3 = fir.load %0 : !fir.ref<f128>
+ return %3 : f128
+}
func.func @_QPtest_complex4(%arg0: !fir.ref<!fir.complex<4>> {fir.bindc_name = "c"}) -> !fir.complex<4> {
%0 = fir.alloca !fir.complex<4> {bindc_name = "test_complex4", uniq_name = "_QFtest_complex4Etest_complex4"}
%1 = fir.load %arg0 : !fir.ref<!fir.complex<4>>
}
func.func private @fabsf(f32) -> f32
func.func private @fabs(f64) -> f64
+func.func private @llvm.fabs.f128(f128) -> f128
func.func private @hypotf(f32, f32) -> f32
func.func private @hypot(f64, f64) -> f64
func.func private @cosf(f32) -> f32
func.func private @cos(f64) -> f64
+//--- cosh_fast.fir
+// RUN: fir-opt %t/cosh_fast.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/cosh_fast.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @coshf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @cosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @coshf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @cosh(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @coshf(f32) -> f32
+func.func private @cosh(f64) -> f64
+
+//--- cosh_relaxed.fir
+// RUN: fir-opt %t/cosh_relaxed.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/cosh_relaxed.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @coshf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @cosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @coshf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @cosh(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @coshf(f32) -> f32
+func.func private @cosh(f64) -> f64
+
+//--- cosh_precise.fir
+// RUN: fir-opt %t/cosh_precise.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/cosh_precise.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @coshf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @cosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @coshf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @cosh(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @coshf(f32) -> f32
+func.func private @cosh(f64) -> f64
+
//--- erf_fast.fir
// RUN: fir-opt %t/erf_fast.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/erf_fast.fir
// CHECK: @_QPtest_real4
// CHECK: @_QPtest_real8
// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.copysign"({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+// CHECK: @_QPtest_real10
+// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.copysign"({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f80, f80) -> f80
+
+// CHECK: @_QPtest_real16
+// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.copysign"({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f128, f128) -> f128
+
func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}, %arg1: !fir.ref<f32> {fir.bindc_name = "y"}) -> f32 {
%0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
%1 = fir.load %arg0 : !fir.ref<f32>
%4 = fir.load %0 : !fir.ref<f64>
return %4 : f64
}
+func.func @_QPtest_real10(%arg0: !fir.ref<f80> {fir.bindc_name = "x"}, %arg1: !fir.ref<f80> {fir.bindc_name = "y"}) -> f80 {
+ %0 = fir.alloca f80 {bindc_name = "test_real10", uniq_name = "_QFtest_real10Etest_real10"}
+ %1 = fir.load %arg0 : !fir.ref<f80>
+ %2 = fir.load %arg1 : !fir.ref<f80>
+ %3 = math.copysign %1, %2 : f80
+ fir.store %3 to %0 : !fir.ref<f80>
+ %4 = fir.load %0 : !fir.ref<f80>
+ return %4 : f80
+}
+func.func @_QPtest_real16(%arg0: !fir.ref<f128> {fir.bindc_name = "x"}, %arg1: !fir.ref<f128> {fir.bindc_name = "y"}) -> f128 {
+ %0 = fir.alloca f128 {bindc_name = "test_real16", uniq_name = "_QFtest_real16Etest_real16"}
+ %1 = fir.load %arg0 : !fir.ref<f128>
+ %2 = fir.load %arg1 : !fir.ref<f128>
+ %3 = math.copysign %1, %2 : f128
+ fir.store %3 to %0 : !fir.ref<f128>
+ %4 = fir.load %0 : !fir.ref<f128>
+ return %4 : f128
+}
//--- sign_relaxed.fir
// RUN: fir-opt %t/sign_relaxed.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/sign_relaxed.fir
// CHECK: @_QPtest_real8
// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.copysign"({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+// CHECK: @_QPtest_real10
+// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.copysign"({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f80, f80) -> f80
+
+// CHECK: @_QPtest_real16
+// CHECK: {{%[A-Za-z0-9._]+}} = "llvm.intr.copysign"({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f128, f128) -> f128
+
func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}, %arg1: !fir.ref<f32> {fir.bindc_name = "y"}) -> f32 {
%0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
%1 = fir.load %arg0 : !fir.ref<f32>
%4 = fir.load %0 : !fir.ref<f64>
return %4 : f64
}
+func.func @_QPtest_real10(%arg0: !fir.ref<f80> {fir.bindc_name = "x"}, %arg1: !fir.ref<f80> {fir.bindc_name = "y"}) -> f80 {
+ %0 = fir.alloca f80 {bindc_name = "test_real10", uniq_name = "_QFtest_real10Etest_real10"}
+ %1 = fir.load %arg0 : !fir.ref<f80>
+ %2 = fir.load %arg1 : !fir.ref<f80>
+ %3 = math.copysign %1, %2 : f80
+ fir.store %3 to %0 : !fir.ref<f80>
+ %4 = fir.load %0 : !fir.ref<f80>
+ return %4 : f80
+}
+func.func @_QPtest_real16(%arg0: !fir.ref<f128> {fir.bindc_name = "x"}, %arg1: !fir.ref<f128> {fir.bindc_name = "y"}) -> f128 {
+ %0 = fir.alloca f128 {bindc_name = "test_real16", uniq_name = "_QFtest_real16Etest_real16"}
+ %1 = fir.load %arg0 : !fir.ref<f128>
+ %2 = fir.load %arg1 : !fir.ref<f128>
+ %3 = math.copysign %1, %2 : f128
+ fir.store %3 to %0 : !fir.ref<f128>
+ %4 = fir.load %0 : !fir.ref<f128>
+ return %4 : f128
+}
//--- sign_precise.fir
// RUN: fir-opt %t/sign_precise.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/sign_precise.fir
// CHECK: @_QPtest_real8
// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @copysign({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+// CHECK: @_QPtest_real10
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @copysignl({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f80, f80) -> f80
+
+// CHECK: @_QPtest_real16
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @llvm.copysign.f128({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f128, f128) -> f128
+
func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}, %arg1: !fir.ref<f32> {fir.bindc_name = "y"}) -> f32 {
%0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
%1 = fir.load %arg0 : !fir.ref<f32>
%4 = fir.load %0 : !fir.ref<f64>
return %4 : f64
}
+func.func @_QPtest_real10(%arg0: !fir.ref<f80> {fir.bindc_name = "x"}, %arg1: !fir.ref<f80> {fir.bindc_name = "y"}) -> f80 {
+ %0 = fir.alloca f80 {bindc_name = "test_real10", uniq_name = "_QFtest_real10Etest_real10"}
+ %1 = fir.load %arg0 : !fir.ref<f80>
+ %2 = fir.load %arg1 : !fir.ref<f80>
+ %3 = fir.call @copysignl(%1, %2) : (f80, f80) -> f80
+ fir.store %3 to %0 : !fir.ref<f80>
+ %4 = fir.load %0 : !fir.ref<f80>
+ return %4 : f80
+}
+func.func @_QPtest_real16(%arg0: !fir.ref<f128> {fir.bindc_name = "x"}, %arg1: !fir.ref<f128> {fir.bindc_name = "y"}) -> f128 {
+ %0 = fir.alloca f128 {bindc_name = "test_real16", uniq_name = "_QFtest_real16Etest_real16"}
+ %1 = fir.load %arg0 : !fir.ref<f128>
+ %2 = fir.load %arg1 : !fir.ref<f128>
+ %3 = fir.call @llvm.copysign.f128(%1, %2) : (f128, f128) -> f128
+ fir.store %3 to %0 : !fir.ref<f128>
+ %4 = fir.load %0 : !fir.ref<f128>
+ return %4 : f128
+}
func.func private @copysignf(f32, f32) -> f32
func.func private @copysign(f64, f64) -> f64
+func.func private @copysignl(f80, f80) -> f80
+func.func private @llvm.copysign.f128(f128, f128) -> f128
//--- sin_fast.fir
// RUN: fir-opt %t/sin_fast.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/sin_fast.fir
func.func private @sinf(f32) -> f32
func.func private @sin(f64) -> f64
+//--- sinh_fast.fir
+// RUN: fir-opt %t/sinh_fast.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/sinh_fast.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @sinhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @sinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @sinhf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @sinh(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @sinhf(f32) -> f32
+func.func private @sinh(f64) -> f64
+
+//--- sinh_relaxed.fir
+// RUN: fir-opt %t/sinh_relaxed.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/sinh_relaxed.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @sinhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @sinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @sinhf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @sinh(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @sinhf(f32) -> f32
+func.func private @sinh(f64) -> f64
+
+//--- sinh_precise.fir
+// RUN: fir-opt %t/sinh_precise.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/sinh_precise.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @sinhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @sinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @sinhf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @sinh(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @sinhf(f32) -> f32
+func.func private @sinh(f64) -> f64
+
//--- tanh_fast.fir
// RUN: fir-opt %t/tanh_fast.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/tanh_fast.fir
// CHECK: @_QPtest_real4
func.func private @tanhf(f32) -> f32
func.func private @tanh(f64) -> f64
+//--- tan_fast.fir
+// RUN: fir-opt %t/tan_fast.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/tan_fast.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @tanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @tan({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = math.tan %1 : f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = math.tan %1 : f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+
+//--- tan_relaxed.fir
+// RUN: fir-opt %t/tan_relaxed.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/tan_relaxed.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @tanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @tan({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = math.tan %1 : f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = math.tan %1 : f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+
+//--- tan_precise.fir
+// RUN: fir-opt %t/tan_precise.fir --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" | FileCheck %t/tan_precise.fir
+// CHECK: @_QPtest_real4
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @tanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+// CHECK: @_QPtest_real8
+// CHECK: {{%[A-Za-z0-9._]+}} = llvm.call @tan({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+func.func @_QPtest_real4(%arg0: !fir.ref<f32> {fir.bindc_name = "x"}) -> f32 {
+ %0 = fir.alloca f32 {bindc_name = "test_real4", uniq_name = "_QFtest_real4Etest_real4"}
+ %1 = fir.load %arg0 : !fir.ref<f32>
+ %2 = fir.call @tanf(%1) : (f32) -> f32
+ fir.store %2 to %0 : !fir.ref<f32>
+ %3 = fir.load %0 : !fir.ref<f32>
+ return %3 : f32
+}
+func.func @_QPtest_real8(%arg0: !fir.ref<f64> {fir.bindc_name = "x"}) -> f64 {
+ %0 = fir.alloca f64 {bindc_name = "test_real8", uniq_name = "_QFtest_real8Etest_real8"}
+ %1 = fir.load %arg0 : !fir.ref<f64>
+ %2 = fir.call @tan(%1) : (f64) -> f64
+ fir.store %2 to %0 : !fir.ref<f64>
+ %3 = fir.load %0 : !fir.ref<f64>
+ return %3 : f64
+}
+func.func private @tanf(f32) -> f32
+func.func private @tan(f64) -> f64
+
! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f64
! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabs({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+function test_real16(x)
+ real(16) :: x, test_real16
+ test_real16 = abs(x)
+end function
+! ALL-LABEL: @_QPtest_real16
+! FAST: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f128
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.abs {{%[A-Za-z0-9._]+}} : f128
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.fabs.f128({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+
function test_complex4(c)
complex(4) :: c, test_complex4
test_complex4 = abs(c)
! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} : f64
! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cos({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+//--- cosh.f90
+! RUN: bbc -emit-fir %t/cosh.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: bbc -emit-fir %t/cosh.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: bbc -emit-fir %t/cosh.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL %t/cosh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
+
+function test_real4(x)
+ real :: x, test_real4
+ test_real4 = cosh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @coshf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+ real(8) :: x, test_real8
+ test_real8 = cosh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
//--- erf.f90
! RUN: bbc -emit-fir %t/erf.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f64
! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysign({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64
+function test_real10(x, y)
+ real(10) :: x, y, test_real10
+ test_real10 = sign(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real10
+! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f80
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f80
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignl({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f80, f80) -> f80
+
+function test_real16(x, y)
+ real(16) :: x, y, test_real16
+ test_real16 = sign(x, y)
+end function
+
+! ALL-LABEL: @_QPtest_real16
+! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f128
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} : f128
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.copysign.f128({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f128, f128) -> f128
+
//--- sin.f90
! RUN: bbc -emit-fir %t/sin.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} : f64
! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sin({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+//--- sinh.f90
+! RUN: bbc -emit-fir %t/sinh.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: bbc -emit-fir %t/sinh.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: bbc -emit-fir %t/sinh.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL %t/sinh.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
+
+function test_real4(x)
+ real :: x, test_real4
+ test_real4 = sinh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinhf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+ real(8) :: x, test_real8
+ test_real8 = sinh(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
//--- tanh.f90
! RUN: bbc -emit-fir %t/tanh.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f64
! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} : f64
! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanh({{%[A-Za-z0-9._]+}}) : (f64) -> f64
+
+//--- tan.f90
+! RUN: bbc -emit-fir %t/tan.f90 -o - --lower-math-early=false --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=fast %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
+! RUN: bbc -emit-fir %t/tan.f90 -o - --lower-math-early=false --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=relaxed %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
+! RUN: bbc -emit-fir %t/tan.f90 -o - --lower-math-early=false --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
+! RUN: %flang_fc1 -emit-fir -mllvm -lower-math-early=false -mllvm -math-runtime=precise %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
+
+function test_real4(x)
+ real :: x, test_real4
+ test_real4 = tan(x)
+end function
+
+! ALL-LABEL: @_QPtest_real4
+! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f32
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f32
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanf({{%[A-Za-z0-9._]+}}) : (f32) -> f32
+
+function test_real8(x)
+ real(8) :: x, test_real8
+ test_real8 = tan(x)
+end function
+
+! ALL-LABEL: @_QPtest_real8
+! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f64
+! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} : f64
+! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tan({{%[A-Za-z0-9._]+}}) : (f64) -> f64