From: David Truby Date: Mon, 26 Sep 2022 13:30:20 +0000 (+0000) Subject: [flang] Use libm over pgmath for complex number intrinsics X-Git-Tag: upstream/17.0.6~32270 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8bd54409b15f45a757fe82ce0872234234a35c9b;p=platform%2Fupstream%2Fllvm.git [flang] Use libm over pgmath for complex number intrinsics This patch changes the handling of complex number intrinsics that have C libm equivalents to call into those instead of calling the external pgmath library. Currently complex numbers to integer powers are excluded as libm has no powi equivalent function. Differential Revision: https://reviews.llvm.org/D134655 --- diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp index 10353d2..4bcb606 100644 --- a/flang/lib/Lower/IntrinsicCall.cpp +++ b/flang/lib/Lower/IntrinsicCall.cpp @@ -1189,6 +1189,32 @@ static mlir::FunctionType genIntIntIntFuncType(mlir::MLIRContext *context) { return mlir::FunctionType::get(context, {itype, itype}, {itype}); } +template +static mlir::FunctionType +genComplexComplexFuncType(mlir::MLIRContext *context) { + auto ctype = fir::ComplexType::get(context, Kind); + return mlir::FunctionType::get(context, {ctype}, {ctype}); +} + +template +static mlir::FunctionType +genComplexComplexComplexFuncType(mlir::MLIRContext *context) { + auto ctype = fir::ComplexType::get(context, Kind); + return mlir::FunctionType::get(context, {ctype, ctype}, {ctype}); +} + +static mlir::FunctionType genF32ComplexFuncType(mlir::MLIRContext *context) { + auto ctype = fir::ComplexType::get(context, 4); + auto ftype = mlir::FloatType::getF32(context); + return mlir::FunctionType::get(context, {ctype}, {ftype}); +} + +static mlir::FunctionType genF64ComplexFuncType(mlir::MLIRContext *context) { + auto ctype = fir::ComplexType::get(context, 8); + auto ftype = mlir::FloatType::getF64(context); + return mlir::FunctionType::get(context, {ctype}, {ftype}); +} + /// Callback type for generating lowering for a math operation. using MathGeneratorTy = mlir::Value (*)(fir::FirOpBuilder &, mlir::Location, llvm::StringRef, mlir::FunctionType, @@ -1283,10 +1309,16 @@ static constexpr MathOperation mathOperations[] = { {"abs", "fabs", genF64F64FuncType, genMathOp}, {"abs", "llvm.fabs.f128", genF128F128FuncType, genMathOp}, + {"abs", "cabsf", genF32ComplexFuncType, genLibCall}, + {"abs", "cabs", genF64ComplexFuncType, genLibCall}, {"acos", "acosf", genF32F32FuncType, genLibCall}, {"acos", "acos", genF64F64FuncType, genLibCall}, + {"acos", "cacosf", genComplexComplexFuncType<4>, genLibCall}, + {"acos", "cacos", genComplexComplexFuncType<8>, genLibCall}, {"acosh", "acoshf", genF32F32FuncType, genLibCall}, {"acosh", "acosh", genF64F64FuncType, genLibCall}, + {"acosh", "cacoshf", genComplexComplexFuncType<4>, genLibCall}, + {"acosh", "cacosh", genComplexComplexFuncType<8>, genLibCall}, // llvm.trunc behaves the same way as libm's trunc. {"aint", "llvm.trunc.f32", genF32F32FuncType, genLibCall}, {"aint", "llvm.trunc.f64", genF64F64FuncType, genLibCall}, @@ -1300,14 +1332,22 @@ static constexpr MathOperation mathOperations[] = { genMathOp}, {"asin", "asinf", genF32F32FuncType, genLibCall}, {"asin", "asin", genF64F64FuncType, genLibCall}, + {"asin", "casinf", genComplexComplexFuncType<4>, genLibCall}, + {"asin", "casin", genComplexComplexFuncType<8>, genLibCall}, {"asinh", "asinhf", genF32F32FuncType, genLibCall}, {"asinh", "asinh", genF64F64FuncType, genLibCall}, + {"asinh", "casinhf", genComplexComplexFuncType<4>, genLibCall}, + {"asinh", "casinh", genComplexComplexFuncType<8>, genLibCall}, {"atan", "atanf", genF32F32FuncType, genMathOp}, {"atan", "atan", genF64F64FuncType, genMathOp}, + {"atan", "catanf", genComplexComplexFuncType<4>, genLibCall}, + {"atan", "catan", genComplexComplexFuncType<8>, genLibCall}, {"atan2", "atan2f", genF32F32F32FuncType, genMathOp}, {"atan2", "atan2", genF64F64F64FuncType, genMathOp}, {"atanh", "atanhf", genF32F32FuncType, genLibCall}, {"atanh", "atanh", genF64F64FuncType, genLibCall}, + {"atanh", "catanhf", genComplexComplexFuncType<4>, genLibCall}, + {"atanh", "catanh", genComplexComplexFuncType<8>, genLibCall}, {"bessel_j0", "j0f", genF32F32FuncType, genLibCall}, {"bessel_j0", "j0", genF64F64FuncType, genLibCall}, {"bessel_j1", "j1f", genF32F32FuncType, genLibCall}, @@ -1325,14 +1365,20 @@ static constexpr MathOperation mathOperations[] = { {"ceil", "ceil", genF64F64FuncType, genMathOp}, {"cos", "cosf", genF32F32FuncType, genMathOp}, {"cos", "cos", genF64F64FuncType, genMathOp}, + {"cos", "ccosf", genComplexComplexFuncType<4>, genLibCall}, + {"cos", "ccos", genComplexComplexFuncType<8>, genLibCall}, {"cosh", "coshf", genF32F32FuncType, genLibCall}, {"cosh", "cosh", genF64F64FuncType, genLibCall}, + {"cosh", "ccoshf", genComplexComplexFuncType<4>, genLibCall}, + {"cosh", "ccosh", genComplexComplexFuncType<8>, genLibCall}, {"erf", "erff", genF32F32FuncType, genMathOp}, {"erf", "erf", genF64F64FuncType, genMathOp}, {"erfc", "erfcf", genF32F32FuncType, genLibCall}, {"erfc", "erfc", genF64F64FuncType, genLibCall}, {"exp", "expf", genF32F32FuncType, genMathOp}, {"exp", "exp", genF64F64FuncType, genMathOp}, + {"exp", "cexpf", genComplexComplexFuncType<4>, genLibCall}, + {"exp", "cexp", genComplexComplexFuncType<8>, genLibCall}, // math::FloorOp returns a real, while Fortran FLOOR returns integer. {"floor", "floorf", genF32F32FuncType, genMathOp}, {"floor", "floor", genF64F64FuncType, genMathOp}, @@ -1342,6 +1388,8 @@ static constexpr MathOperation mathOperations[] = { {"hypot", "hypot", genF64F64F64FuncType, genLibCall}, {"log", "logf", genF32F32FuncType, genMathOp}, {"log", "log", genF64F64FuncType, genMathOp}, + {"log", "clogf", genComplexComplexFuncType<4>, genLibCall}, + {"log", "clog", genComplexComplexFuncType<8>, genLibCall}, {"log10", "log10f", genF32F32FuncType, genMathOp}, {"log10", "log10", genF64F64FuncType, genMathOp}, {"log_gamma", "lgammaf", genF32F32FuncType, genLibCall}, @@ -1357,6 +1405,8 @@ static constexpr MathOperation mathOperations[] = { {"pow", {}, genIntIntIntFuncType<64>, genMathOp}, {"pow", "powf", genF32F32F32FuncType, genMathOp}, {"pow", "pow", genF64F64F64FuncType, genMathOp}, + {"pow", "cpowf", genComplexComplexComplexFuncType<4>, genLibCall}, + {"pow", "cpow", genComplexComplexComplexFuncType<8>, genLibCall}, // TODO: add PowIOp in math and complex dialects. {"pow", "llvm.powi.f32.i32", genF32F32IntFuncType<32>, genLibCall}, {"pow", "llvm.powi.f64.i32", genF64F64IntFuncType<32>, genLibCall}, @@ -1370,14 +1420,24 @@ static constexpr MathOperation mathOperations[] = { genMathOp}, {"sin", "sinf", genF32F32FuncType, genMathOp}, {"sin", "sin", genF64F64FuncType, genMathOp}, + {"sin", "csinf", genComplexComplexFuncType<4>, genLibCall}, + {"sin", "csin", genComplexComplexFuncType<8>, genLibCall}, {"sinh", "sinhf", genF32F32FuncType, genLibCall}, {"sinh", "sinh", genF64F64FuncType, genLibCall}, + {"sinh", "csinhf", genComplexComplexFuncType<4>, genLibCall}, + {"sinh", "csinh", genComplexComplexFuncType<8>, genLibCall}, {"sqrt", "sqrtf", genF32F32FuncType, genMathOp}, {"sqrt", "sqrt", genF64F64FuncType, genMathOp}, + {"sqrt", "csqrtf", genComplexComplexFuncType<4>, genLibCall}, + {"sqrt", "csqrt", genComplexComplexFuncType<8>, genLibCall}, {"tan", "tanf", genF32F32FuncType, genMathOp}, {"tan", "tan", genF64F64FuncType, genMathOp}, + {"tan", "ctanf", genComplexComplexFuncType<4>, genLibCall}, + {"tan", "ctan", genComplexComplexFuncType<8>, genLibCall}, {"tanh", "tanhf", genF32F32FuncType, genMathOp}, {"tanh", "tanh", genF64F64FuncType, genMathOp}, + {"tanh", "ctanhf", genComplexComplexFuncType<4>, genLibCall}, + {"tanh", "ctanh", genComplexComplexFuncType<8>, genLibCall}, }; // This helper class computes a "distance" between two function types. @@ -2224,7 +2284,7 @@ mlir::Value IntrinsicLibrary::genAbs(mlir::Type resultType, assert(args.size() == 1); mlir::Value arg = args[0]; mlir::Type type = arg.getType(); - if (fir::isa_real(type)) { + if (fir::isa_real(type) || fir::isa_complex(type)) { // Runtime call to fp abs. An alternative would be to use mlir // math::AbsFOp but it does not support all fir floating point types. return genRuntimeCall("abs", resultType, args); @@ -2238,12 +2298,6 @@ mlir::Value IntrinsicLibrary::genAbs(mlir::Type resultType, auto xored = builder.create(loc, arg, mask); return builder.create(loc, xored, mask); } - if (fir::isa_complex(type)) { - // Use HYPOT to fulfill the no underflow/overflow requirement. - auto parts = fir::factory::Complex{builder, loc}.extractParts(arg); - llvm::SmallVector args = {parts.first, parts.second}; - return genRuntimeCall("hypot", resultType, args); - } llvm_unreachable("unexpected type in ABS argument"); } diff --git a/flang/test/Lower/Intrinsics/abs.f90 b/flang/test/Lower/Intrinsics/abs.f90 index 80960da..52b5ff4 100644 --- a/flang/test/Lower/Intrinsics/abs.f90 +++ b/flang/test/Lower/Intrinsics/abs.f90 @@ -94,10 +94,8 @@ end subroutine ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>{{.*}}, %[[VAL_1:.*]]: !fir.ref{{.*}}) { subroutine abs_testzr(a, b) ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.extract_value %[[VAL_2]], [0 : index] : (!fir.complex<4>) -> f32 -! CHECK: %[[VAL_4:.*]] = fir.extract_value %[[VAL_2]], [1 : index] : (!fir.complex<4>) -> f32 -! CHECK: %[[VAL_5:.*]] = fir.call @hypotf(%[[VAL_3]], %[[VAL_4]]) : (f32, f32) -> f32 -! CHECK: fir.store %[[VAL_5]] to %[[VAL_1]] : !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.call @cabsf(%[[VAL_2]]) : (!fir.complex<4>) -> f32 +! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref ! CHECK: return complex :: a real :: b @@ -108,10 +106,8 @@ end subroutine abs_testzr ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>{{.*}}, %[[VAL_1:.*]]: !fir.ref{{.*}}) { subroutine abs_testzd(a, b) ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref> -! CHECK: %[[VAL_3:.*]] = fir.extract_value %[[VAL_2]], [0 : index] : (!fir.complex<8>) -> f64 -! CHECK: %[[VAL_4:.*]] = fir.extract_value %[[VAL_2]], [1 : index] : (!fir.complex<8>) -> f64 -! CHECK: %[[VAL_5:.*]] = fir.call @hypot(%[[VAL_3]], %[[VAL_4]]) : (f64, f64) -> f64 -! CHECK: fir.store %[[VAL_5]] to %[[VAL_1]] : !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.call @cabs(%[[VAL_2]]) : (!fir.complex<8>) -> f64 +! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref ! CHECK: return complex(kind=8) :: a real(kind=8) :: b diff --git a/flang/test/Lower/Intrinsics/acos.f90 b/flang/test/Lower/Intrinsics/acos.f90 index 6dcf780..1518d43 100644 --- a/flang/test/Lower/Intrinsics/acos.f90 +++ b/flang/test/Lower/Intrinsics/acos.f90 @@ -20,3 +20,20 @@ end function ! ALL-LABEL: @_QPtest_real8 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @acos({{%[A-Za-z0-9._]+}}) : (f64) -> f64 + +function test_complex4(x) + complex :: x, test_complex4 + test_complex4 = acos(x) +end function + +! ALL-LABEL: @_QPtest_complex4 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cacosf({{%[A-Za-z0-9._]+}}) : (!fir.complex<4>) -> !fir.complex<4> + +function test_complex8(x) + complex(kind=8) :: x, test_complex8 + test_complex8 = acos(x) +end function + +! ALL-LABEL: @_QPtest_complex8 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cacos({{%[A-Za-z0-9._]+}}) : (!fir.complex<8>) -> !fir.complex<8> + diff --git a/flang/test/Lower/Intrinsics/acosh.f90 b/flang/test/Lower/Intrinsics/acosh.f90 index c23265d..2025906 100644 --- a/flang/test/Lower/Intrinsics/acosh.f90 +++ b/flang/test/Lower/Intrinsics/acosh.f90 @@ -20,3 +20,20 @@ end function ! ALL-LABEL: @_QPtest_real8 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @acosh({{%[A-Za-z0-9._]+}}) : (f64) -> f64 + +function test_complex4(x) + complex :: x, test_complex4 + test_complex4 = acosh(x) +end function + +! ALL-LABEL: @_QPtest_complex4 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cacoshf({{%[A-Za-z0-9._]+}}) : (!fir.complex<4>) -> !fir.complex<4> + +function test_complex8(x) + complex(kind=8) :: x, test_complex8 + test_complex8 = acosh(x) +end function + +! ALL-LABEL: @_QPtest_complex8 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cacosh({{%[A-Za-z0-9._]+}}) : (!fir.complex<8>) -> !fir.complex<8> + diff --git a/flang/test/Lower/Intrinsics/asin.f90 b/flang/test/Lower/Intrinsics/asin.f90 index a7b44ff..ca3b07e 100644 --- a/flang/test/Lower/Intrinsics/asin.f90 +++ b/flang/test/Lower/Intrinsics/asin.f90 @@ -20,3 +20,20 @@ end function ! ALL-LABEL: @_QPtest_real8 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @asin({{%[A-Za-z0-9._]+}}) : (f64) -> f64 + +function test_complex4(x) + complex :: x, test_complex4 + test_complex4 = asin(x) +end function + +! ALL-LABEL: @_QPtest_complex4 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @casinf({{%[A-Za-z0-9._]+}}) : (!fir.complex<4>) -> !fir.complex<4> + +function test_complex8(x) + complex(kind=8) :: x, test_complex8 + test_complex8 = asin(x) +end function + +! ALL-LABEL: @_QPtest_complex8 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @casin({{%[A-Za-z0-9._]+}}) : (!fir.complex<8>) -> !fir.complex<8> + diff --git a/flang/test/Lower/Intrinsics/asinh.f90 b/flang/test/Lower/Intrinsics/asinh.f90 index b87ec8f..afefb4f 100644 --- a/flang/test/Lower/Intrinsics/asinh.f90 +++ b/flang/test/Lower/Intrinsics/asinh.f90 @@ -20,3 +20,20 @@ end function ! ALL-LABEL: @_QPtest_real8 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @asinh({{%[A-Za-z0-9._]+}}) : (f64) -> f64 + +function test_complex4(x) + complex :: x, test_complex4 + test_complex4 = asinh(x) +end function + +! ALL-LABEL: @_QPtest_complex4 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @casinhf({{%[A-Za-z0-9._]+}}) : (!fir.complex<4>) -> !fir.complex<4> + +function test_complex8(x) + complex(kind=8) :: x, test_complex8 + test_complex8 = asinh(x) +end function + +! ALL-LABEL: @_QPtest_complex8 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @casinh({{%[A-Za-z0-9._]+}}) : (!fir.complex<8>) -> !fir.complex<8> + diff --git a/flang/test/Lower/Intrinsics/atanh.f90 b/flang/test/Lower/Intrinsics/atanh.f90 index 826b06c..20df187 100644 --- a/flang/test/Lower/Intrinsics/atanh.f90 +++ b/flang/test/Lower/Intrinsics/atanh.f90 @@ -20,3 +20,19 @@ end function ! ALL-LABEL: @_QPtest_real8 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @atanh({{%[A-Za-z0-9._]+}}) : (f64) -> f64 + +function test_complex4(x) + complex :: x, test_complex4 + test_complex4 = atanh(x) +end function + +! ALL-LABEL: @_QPtest_complex4 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @catanhf({{%[A-Za-z0-9._]+}}) : (!fir.complex<4>) -> !fir.complex<4> + +function test_complex8(x) + complex(kind=8) :: x, test_real8 + test_complex8 = atanh(x) +end function + +! ALL-LABEL: @_QPtest_complex8 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @catanh({{%[A-Za-z0-9._]+}}) : (!fir.complex<8>) -> !fir.complex<8> diff --git a/flang/test/Lower/Intrinsics/exp.f90 b/flang/test/Lower/Intrinsics/exp.f90 index a7dac0f..6ddd56c 100644 --- a/flang/test/Lower/Intrinsics/exp.f90 +++ b/flang/test/Lower/Intrinsics/exp.f90 @@ -53,10 +53,10 @@ end subroutine ! CHECK-LABEL: private @fir.exp.z4.z4 ! CHECK-SAME: (%[[ARG32_OUTLINE]]: !fir.complex<4>) -> !fir.complex<4> -! CHECK: %[[RESULT32_OUTLINE]] = fir.call @__fc_exp_1(%[[ARG32_OUTLINE]]) : (!fir.complex<4>) -> !fir.complex<4> +! CHECK: %[[RESULT32_OUTLINE]] = fir.call @cexpf(%[[ARG32_OUTLINE]]) : (!fir.complex<4>) -> !fir.complex<4> ! CHECK: return %[[RESULT32_OUTLINE]] : !fir.complex<4> ! CHECK-LABEL: private @fir.exp.z8.z8 ! CHECK-SAME: (%[[ARG64_OUTLINE]]: !fir.complex<8>) -> !fir.complex<8> -! CHECK: %[[RESULT64_OUTLINE]] = fir.call @__fz_exp_1(%[[ARG64_OUTLINE]]) : (!fir.complex<8>) -> !fir.complex<8> +! CHECK: %[[RESULT64_OUTLINE]] = fir.call @cexp(%[[ARG64_OUTLINE]]) : (!fir.complex<8>) -> !fir.complex<8> ! CHECK: return %[[RESULT64_OUTLINE]] : !fir.complex<8> diff --git a/flang/test/Lower/Intrinsics/log.f90 b/flang/test/Lower/Intrinsics/log.f90 index cf3c1f0..3c35a3a 100644 --- a/flang/test/Lower/Intrinsics/log.f90 +++ b/flang/test/Lower/Intrinsics/log.f90 @@ -73,12 +73,12 @@ end subroutine ! CHECK-LABEL: private @fir.log.z4.z4 ! CHECK-SAME: (%[[ARG32_OUTLINE]]: !fir.complex<4>) -> !fir.complex<4> -! CHECK: %[[RESULT32_OUTLINE]] = fir.call @__fc_log_1(%[[ARG32_OUTLINE]]) : (!fir.complex<4>) -> !fir.complex<4> +! CHECK: %[[RESULT32_OUTLINE]] = fir.call @clogf(%[[ARG32_OUTLINE]]) : (!fir.complex<4>) -> !fir.complex<4> ! CHECK: return %[[RESULT32_OUTLINE]] : !fir.complex<4> ! CHECK-LABEL: private @fir.log.z8.z8 ! CHECK-SAME: (%[[ARG64_OUTLINE]]: !fir.complex<8>) -> !fir.complex<8> -! CHECK: %[[RESULT64_OUTLINE]] = fir.call @__fz_log_1(%[[ARG64_OUTLINE]]) : (!fir.complex<8>) -> !fir.complex<8> +! CHECK: %[[RESULT64_OUTLINE]] = fir.call @clog(%[[ARG64_OUTLINE]]) : (!fir.complex<8>) -> !fir.complex<8> ! CHECK: return %[[RESULT64_OUTLINE]] : !fir.complex<8> ! CHECK-LABEL: private @fir.log10.f32.f32 diff --git a/flang/test/Lower/Intrinsics/missing-math-runtime.f90 b/flang/test/Lower/Intrinsics/missing-math-runtime.f90 index a6777c7..89e383c 100644 --- a/flang/test/Lower/Intrinsics/missing-math-runtime.f90 +++ b/flang/test/Lower/Intrinsics/missing-math-runtime.f90 @@ -4,7 +4,7 @@ complex(16) :: a real(16) :: b -! CHECK: not yet implemented: no math runtime available for 'hypot(f128, f128)' +! CHECK: not yet implemented: no math runtime available for 'abs(!fir.complex<16>)' b = abs(a) end diff --git a/flang/test/Lower/math-lowering.f90 b/flang/test/Lower/math-lowering.f90 index 4fda7bd..558c44c 100644 --- a/flang/test/Lower/math-lowering.f90 +++ b/flang/test/Lower/math-lowering.f90 @@ -43,7 +43,7 @@ function test_complex4(c) end function ! ALL-LABEL: @_QPtest_complex4 -! ALL: {{%[A-Za-z0-9._]+}} = fir.call @hypotf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f32, f32) -> f32 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cabsf({{%[A-Za-z0-9._]+}}) : (!fir.complex<4>) -> f32 function test_complex8(c) complex(8) :: c, test_complex8 @@ -51,7 +51,7 @@ function test_complex8(c) end function ! ALL-LABEL: @_QPtest_complex8 -! ALL: {{%[A-Za-z0-9._]+}} = fir.call @hypot({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) : (f64, f64) -> f64 +! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cabs({{%[A-Za-z0-9._]+}}) : (!fir.complex<8>) -> f64 //--- aint.f90 ! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/aint.f90 diff --git a/flang/test/Lower/power-operator.f90 b/flang/test/Lower/power-operator.f90 index d99a46b..5ad949c 100644 --- a/flang/test/Lower/power-operator.f90 +++ b/flang/test/Lower/power-operator.f90 @@ -116,3 +116,18 @@ subroutine pow_c8_i8(x, y, z) z = x ** y ! CHECK: call @__fz_powk_1 end subroutine + +! CHECK-LABEL: pow_c4_c4 +subroutine pow_c4_c4(x, y, z) + complex :: x, y, z + z = x ** y + ! CHECK: call @cpowf +end subroutine + +! CHECK-LABEL: pow_c8_c8 +subroutine pow_c8_c8(x, y, z) + complex(8) :: x, y, z + z = x ** y + ! CHECK: call @cpow +end subroutine + diff --git a/flang/test/Lower/sqrt.f90 b/flang/test/Lower/sqrt.f90 index af48387..e4537c5 100644 --- a/flang/test/Lower/sqrt.f90 +++ b/flang/test/Lower/sqrt.f90 @@ -36,7 +36,7 @@ end subroutine ! CHECK: math.sqrt %{{.*}} : f64 ! CHECK-LABEL: func private @fir.sqrt.z4.z4 -! CHECK: fir.call {{.*}}fc_sqrt +! CHECK: fir.call @csqrtf ! CHECK-LABEL: @fir.sqrt.z8.z8 -! CHECK: fir.call {{.*}}fz_sqrt +! CHECK: fir.call @csqrt diff --git a/flang/test/Lower/trigonometric-intrinsics.f90 b/flang/test/Lower/trigonometric-intrinsics.f90 index de8d88f..99b1812 100644 --- a/flang/test/Lower/trigonometric-intrinsics.f90 +++ b/flang/test/Lower/trigonometric-intrinsics.f90 @@ -1,6 +1,34 @@ ! RUN: bbc -emit-fir -outline-intrinsics %s -o - | FileCheck %s ! RUN: %flang_fc1 -emit-fir -mllvm -outline-intrinsics %s -o - | FileCheck %s +! CHECK-LABEL: tan_testr +subroutine tan_testr(a, b) + real :: a, b +! CHECK: fir.call @fir.tan.f32.f32 + b = tan(a) +end subroutine + +! CHECK-LABEL: tan_testd +subroutine tan_testd(a, b) + real(kind=8) :: a, b +! CHECK: fir.call @fir.tan.f64.f64 + b = tan(a) +end subroutine + +! CHECK-LABEL: tan_testc +subroutine tan_testc(z) + complex :: z +! CHECK: fir.call @fir.tan.z4.z4 + z = tan(z) +end subroutine + +! CHECK-LABEL: tan_testcd +subroutine tan_testcd(z) + complex(kind=8) :: z +! CHECK: fir.call @fir.tan.z8.z8 + z = tan(z) +end subroutine + ! CHECK-LABEL: atan_testr subroutine atan_testr(a, b) real :: a, b @@ -141,6 +169,18 @@ subroutine sinh_testcd(z) z = sinh(z) end subroutine +! CHECK-LABEL: @fir.tan.f32.f32 +! CHECK: math.tan %{{.*}} : f32 + +! CHECK-LABEL: @fir.tan.f64.f64 +! CHECK: math.tan %{{.*}} : f64 + +! CHECK-LABEL: @fir.tan.z4.z4 +! CHECK: fir.call @ctanf + +! CHECK-LABEL: @fir.tan.z8.z8 +! CHECK: fir.call @ctan + ! CHECK-LABEL: @fir.atan.f32.f32 ! CHECK: math.atan %{{.*}} : f32 @@ -148,10 +188,10 @@ end subroutine ! CHECK: math.atan %{{.*}} : f64 ! CHECK-LABEL: @fir.atan.z4.z4 -! CHECK: fir.call {{.*}}atan +! CHECK: fir.call @catanf ! CHECK-LABEL: @fir.atan.z8.z8 -! CHECK: fir.call {{.*}}atan +! CHECK: fir.call @catan ! CHECK-LABEL: @fir.cos.f32.f32 ! CHECK: math.cos %{{.*}} : f32 @@ -160,10 +200,10 @@ end subroutine ! CHECK: math.cos %{{.*}} : f64 ! CHECK-LABEL: @fir.cos.z4.z4 -! CHECK: fir.call {{.*}}cos +! CHECK: fir.call @ccosf ! CHECK-LABEL: @fir.cos.z8.z8 -! CHECK: fir.call {{.*}}cos +! CHECK: fir.call @ccos ! CHECK-LABEL: @fir.cosh.f32.f32 ! CHECK: fir.call {{.*}}cosh @@ -172,10 +212,10 @@ end subroutine ! CHECK: fir.call {{.*}}cosh ! CHECK-LABEL: @fir.cosh.z4.z4 -! CHECK: fir.call {{.*}}cosh +! CHECK: fir.call @ccoshf ! CHECK-LABEL: @fir.cosh.z8.z8 -! CHECK: fir.call {{.*}}cosh +! CHECK: fir.call @ccosh ! CHECK-LABEL: @fir.sin.f32.f32 ! CHECK: math.sin %{{.*}} : f32 @@ -184,10 +224,10 @@ end subroutine ! CHECK: math.sin %{{.*}} : f64 ! CHECK-LABEL: @fir.sin.z4.z4 -! CHECK: fir.call {{.*}}sin +! CHECK: fir.call @csinf ! CHECK-LABEL: @fir.sin.z8.z8 -! CHECK: fir.call {{.*}}sin +! CHECK: fir.call @csin ! CHECK-LABEL: @fir.sinh.f32.f32 ! CHECK: fir.call {{.*}}sinh @@ -196,7 +236,7 @@ end subroutine ! CHECK: fir.call {{.*}}sinh ! CHECK-LABEL: @fir.sinh.z4.z4 -! CHECK: fir.call {{.*}}sinh +! CHECK: fir.call @csinhf ! CHECK-LABEL: @fir.sinh.z8.z8 -! CHECK: fir.call {{.*}}sinh +! CHECK: fir.call @csinh