[flang-commits] [flang] 8bd5440 - [flang] Use libm over pgmath for complex number intrinsics
David Truby via flang-commits
flang-commits at lists.llvm.org
Wed Sep 28 06:27:21 PDT 2022
Author: David Truby
Date: 2022-09-28T13:25:10Z
New Revision: 8bd54409b15f45a757fe82ce0872234234a35c9b
URL: https://github.com/llvm/llvm-project/commit/8bd54409b15f45a757fe82ce0872234234a35c9b
DIFF: https://github.com/llvm/llvm-project/commit/8bd54409b15f45a757fe82ce0872234234a35c9b.diff
LOG: [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
Added:
Modified:
flang/lib/Lower/IntrinsicCall.cpp
flang/test/Lower/Intrinsics/abs.f90
flang/test/Lower/Intrinsics/acos.f90
flang/test/Lower/Intrinsics/acosh.f90
flang/test/Lower/Intrinsics/asin.f90
flang/test/Lower/Intrinsics/asinh.f90
flang/test/Lower/Intrinsics/atanh.f90
flang/test/Lower/Intrinsics/exp.f90
flang/test/Lower/Intrinsics/log.f90
flang/test/Lower/Intrinsics/missing-math-runtime.f90
flang/test/Lower/math-lowering.f90
flang/test/Lower/power-operator.f90
flang/test/Lower/sqrt.f90
flang/test/Lower/trigonometric-intrinsics.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 10353d2184bc5..4bcb6069a02be 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 <int Kind>
+static mlir::FunctionType
+genComplexComplexFuncType(mlir::MLIRContext *context) {
+ auto ctype = fir::ComplexType::get(context, Kind);
+ return mlir::FunctionType::get(context, {ctype}, {ctype});
+}
+
+template <int Kind>
+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<mlir::math::AbsFOp>},
{"abs", "llvm.fabs.f128", genF128F128FuncType,
genMathOp<mlir::math::AbsFOp>},
+ {"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<mlir::LLVM::RoundOp>},
{"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<mlir::math::AtanOp>},
{"atan", "atan", genF64F64FuncType, genMathOp<mlir::math::AtanOp>},
+ {"atan", "catanf", genComplexComplexFuncType<4>, genLibCall},
+ {"atan", "catan", genComplexComplexFuncType<8>, genLibCall},
{"atan2", "atan2f", genF32F32F32FuncType, genMathOp<mlir::math::Atan2Op>},
{"atan2", "atan2", genF64F64F64FuncType, genMathOp<mlir::math::Atan2Op>},
{"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<mlir::math::CeilOp>},
{"cos", "cosf", genF32F32FuncType, genMathOp<mlir::math::CosOp>},
{"cos", "cos", genF64F64FuncType, genMathOp<mlir::math::CosOp>},
+ {"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<mlir::math::ErfOp>},
{"erf", "erf", genF64F64FuncType, genMathOp<mlir::math::ErfOp>},
{"erfc", "erfcf", genF32F32FuncType, genLibCall},
{"erfc", "erfc", genF64F64FuncType, genLibCall},
{"exp", "expf", genF32F32FuncType, genMathOp<mlir::math::ExpOp>},
{"exp", "exp", genF64F64FuncType, genMathOp<mlir::math::ExpOp>},
+ {"exp", "cexpf", genComplexComplexFuncType<4>, genLibCall},
+ {"exp", "cexp", genComplexComplexFuncType<8>, genLibCall},
// math::FloorOp returns a real, while Fortran FLOOR returns integer.
{"floor", "floorf", genF32F32FuncType, genMathOp<mlir::math::FloorOp>},
{"floor", "floor", genF64F64FuncType, genMathOp<mlir::math::FloorOp>},
@@ -1342,6 +1388,8 @@ static constexpr MathOperation mathOperations[] = {
{"hypot", "hypot", genF64F64F64FuncType, genLibCall},
{"log", "logf", genF32F32FuncType, genMathOp<mlir::math::LogOp>},
{"log", "log", genF64F64FuncType, genMathOp<mlir::math::LogOp>},
+ {"log", "clogf", genComplexComplexFuncType<4>, genLibCall},
+ {"log", "clog", genComplexComplexFuncType<8>, genLibCall},
{"log10", "log10f", genF32F32FuncType, genMathOp<mlir::math::Log10Op>},
{"log10", "log10", genF64F64FuncType, genMathOp<mlir::math::Log10Op>},
{"log_gamma", "lgammaf", genF32F32FuncType, genLibCall},
@@ -1357,6 +1405,8 @@ static constexpr MathOperation mathOperations[] = {
{"pow", {}, genIntIntIntFuncType<64>, genMathOp<mlir::math::IPowIOp>},
{"pow", "powf", genF32F32F32FuncType, genMathOp<mlir::math::PowFOp>},
{"pow", "pow", genF64F64F64FuncType, genMathOp<mlir::math::PowFOp>},
+ {"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<mlir::math::CopySignOp>},
{"sin", "sinf", genF32F32FuncType, genMathOp<mlir::math::SinOp>},
{"sin", "sin", genF64F64FuncType, genMathOp<mlir::math::SinOp>},
+ {"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<mlir::math::SqrtOp>},
{"sqrt", "sqrt", genF64F64FuncType, genMathOp<mlir::math::SqrtOp>},
+ {"sqrt", "csqrtf", genComplexComplexFuncType<4>, genLibCall},
+ {"sqrt", "csqrt", genComplexComplexFuncType<8>, genLibCall},
{"tan", "tanf", genF32F32FuncType, genMathOp<mlir::math::TanOp>},
{"tan", "tan", genF64F64FuncType, genMathOp<mlir::math::TanOp>},
+ {"tan", "ctanf", genComplexComplexFuncType<4>, genLibCall},
+ {"tan", "ctan", genComplexComplexFuncType<8>, genLibCall},
{"tanh", "tanhf", genF32F32FuncType, genMathOp<mlir::math::TanhOp>},
{"tanh", "tanh", genF64F64FuncType, genMathOp<mlir::math::TanhOp>},
+ {"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<mlir::arith::XOrIOp>(loc, arg, mask);
return builder.create<mlir::arith::SubIOp>(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<mlir::Value> 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 80960daecfb43..52b5ff4baf0a7 100644
--- a/flang/test/Lower/Intrinsics/abs.f90
+++ b/flang/test/Lower/Intrinsics/abs.f90
@@ -94,10 +94,8 @@ subroutine abs_testr16(a, b)
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.complex<4>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f32>{{.*}}) {
subroutine abs_testzr(a, b)
! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.complex<4>>
-! 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<f32>
+! CHECK: %[[VAL_3:.*]] = fir.call @cabsf(%[[VAL_2]]) : (!fir.complex<4>) -> f32
+! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f32>
! CHECK: return
complex :: a
real :: b
@@ -108,10 +106,8 @@ end subroutine abs_testzr
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.complex<8>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f64>{{.*}}) {
subroutine abs_testzd(a, b)
! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.complex<8>>
-! 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<f64>
+! CHECK: %[[VAL_3:.*]] = fir.call @cabs(%[[VAL_2]]) : (!fir.complex<8>) -> f64
+! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f64>
! 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 6dcf780330262..1518d43c10f68 100644
--- a/flang/test/Lower/Intrinsics/acos.f90
+++ b/flang/test/Lower/Intrinsics/acos.f90
@@ -20,3 +20,20 @@ function test_real8(x)
! 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 c23265d8506f7..2025906ae6212 100644
--- a/flang/test/Lower/Intrinsics/acosh.f90
+++ b/flang/test/Lower/Intrinsics/acosh.f90
@@ -20,3 +20,20 @@ function test_real8(x)
! 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 a7b44ffbdad4a..ca3b07e43b756 100644
--- a/flang/test/Lower/Intrinsics/asin.f90
+++ b/flang/test/Lower/Intrinsics/asin.f90
@@ -20,3 +20,20 @@ function test_real8(x)
! 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 b87ec8fe600df..afefb4f2379f6 100644
--- a/flang/test/Lower/Intrinsics/asinh.f90
+++ b/flang/test/Lower/Intrinsics/asinh.f90
@@ -20,3 +20,20 @@ function test_real8(x)
! 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 826b06c5abdbf..20df187908095 100644
--- a/flang/test/Lower/Intrinsics/atanh.f90
+++ b/flang/test/Lower/Intrinsics/atanh.f90
@@ -20,3 +20,19 @@ function test_real8(x)
! 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 a7dac0fbd3337..6ddd56ce15be9 100644
--- a/flang/test/Lower/Intrinsics/exp.f90
+++ b/flang/test/Lower/Intrinsics/exp.f90
@@ -53,10 +53,10 @@ subroutine exp_testcd(a, b)
! 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 cf3c1f02d5a28..3c35a3ac661a0 100644
--- a/flang/test/Lower/Intrinsics/log.f90
+++ b/flang/test/Lower/Intrinsics/log.f90
@@ -73,12 +73,12 @@ subroutine log10_testd(a, b)
! 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 a6777c77db3a0..89e383caaad6b 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 4fda7bd041f15..558c44c556e49 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 d99a46b71a811..5ad949c8d6a02 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 af48387e718f0..e4537c54d50ad 100644
--- a/flang/test/Lower/sqrt.f90
+++ b/flang/test/Lower/sqrt.f90
@@ -36,7 +36,7 @@ subroutine sqrt_testcd(z)
! 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 de8d88fd36f41..99b181281e205 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 @@ subroutine sinh_testcd(z)
! 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 @@ subroutine sinh_testcd(z)
! 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 @@ subroutine sinh_testcd(z)
! 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 @@ subroutine sinh_testcd(z)
! 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 @@ subroutine sinh_testcd(z)
! 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
More information about the flang-commits
mailing list