[flang-commits] [flang] f52c64b - [flang] Add fastmath flags to localBuilder in IntrinsicCall
David Truby via flang-commits
flang-commits at lists.llvm.org
Tue Jul 11 11:03:52 PDT 2023
Author: David Truby
Date: 2023-07-11T18:53:31+01:00
New Revision: f52c64b115a872cd059549613c06e90e9954dc79
URL: https://github.com/llvm/llvm-project/commit/f52c64b115a872cd059549613c06e90e9954dc79
DIFF: https://github.com/llvm/llvm-project/commit/f52c64b115a872cd059549613c06e90e9954dc79.diff
LOG: [flang] Add fastmath flags to localBuilder in IntrinsicCall
Currently the local builder used in IntrinsicCall doesn't have the
fastmath flags passed to it. This results in the fastmath attribute
not being added to certain runtime calls. This patch simply forwards
the fastmath flags from the parent builder.
Differential Revision: https://reviews.llvm.org/D154611
Added:
Modified:
flang/include/flang/Optimizer/Builder/FIRBuilder.h
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
flang/test/Lower/Intrinsics/exp.f90
flang/test/Lower/Intrinsics/log.f90
flang/test/Lower/Intrinsics/math-runtime-options.f90
flang/test/Lower/array-expression-slice-1.f90
flang/test/Lower/dummy-procedure.f90
flang/test/Lower/intrinsic-procedure-wrappers.f90
flang/test/Lower/sqrt.f90
flang/test/Lower/trigonometric-intrinsics.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 92e9d490456282..606e79ca3f8393 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -456,6 +456,20 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
/// Get current FastMathFlags value.
mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
+ /// Stringify FastMathFlags set in a way
+ /// that the string may be used for mangling a function name.
+ /// If FastMathFlags are set to 'none', then the result is an empty
+ /// string.
+ std::string getFastMathFlagsString() {
+ mlir::arith::FastMathFlags flags = getFastMathFlags();
+ if (flags == mlir::arith::FastMathFlags::none)
+ return {};
+
+ std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
+ std::replace(fmfString.begin(), fmfString.end(), ',', '_');
+ return fmfString;
+ }
+
/// Dump the current function. (debug)
LLVM_DUMP_METHOD void dumpFunc();
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index f5df115431a5fa..74a6e1cec4f54c 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -47,6 +47,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
#include <optional>
#define DEBUG_TYPE "flang-lower-intrinsic"
@@ -1624,6 +1625,7 @@ mlir::func::FuncOp IntrinsicLibrary::getWrapper(GeneratorType generator,
// its calls will be.
auto localBuilder =
std::make_unique<fir::FirOpBuilder>(function, builder.getKindMap());
+ localBuilder->setFastMathFlags(builder.getFastMathFlags());
localBuilder->setInsertionPointToStart(&function.front());
// Location of code inside wrapper of the wrapper is independent from
// the location of the intrinsic call.
@@ -1689,7 +1691,13 @@ IntrinsicLibrary::outlineInWrapper(GeneratorType generator,
}
mlir::FunctionType funcType = getFunctionType(resultType, args, builder);
- mlir::func::FuncOp wrapper = getWrapper(generator, name, funcType);
+ std::string funcName{name};
+ llvm::raw_string_ostream nameOS{funcName};
+ if (std::string fmfString{builder.getFastMathFlagsString()};
+ !fmfString.empty()) {
+ nameOS << '.' << fmfString;
+ }
+ mlir::func::FuncOp wrapper = getWrapper(generator, funcName, funcType);
return builder.create<fir::CallOp>(loc, wrapper, args).getResult(0);
}
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index 4896ca0f668a88..3731f7b15b103d 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -125,20 +125,6 @@ getSimplificationBuilder(mlir::Operation *op, const fir::KindMapping &kindMap) {
return builder;
}
-/// Stringify FastMathFlags set for the given \p builder in a way
-/// that the string may be used for mangling a function name.
-/// If FastMathFlags are set to 'none', then the result is an empty
-/// string.
-static std::string getFastMathFlagsString(const fir::FirOpBuilder &builder) {
- mlir::arith::FastMathFlags flags = builder.getFastMathFlags();
- if (flags == mlir::arith::FastMathFlags::none)
- return {};
-
- std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
- std::replace(fmfString.begin(), fmfString.end(), ',', '_');
- return fmfString;
-}
-
/// Generate function type for the simplified version of RTNAME(Sum) and
/// similar functions with a fir.box<none> type returning \p elementType.
static mlir::FunctionType genNoneBoxType(fir::FirOpBuilder &builder,
@@ -1071,7 +1057,7 @@ void SimplifyIntrinsicsPass::simplifyIntOrFloatReduction(
mlir::SymbolRefAttr callee = call.getCalleeAttr();
fir::FirOpBuilder builder{getSimplificationBuilder(call, kindMap)};
- std::string fmfString{getFastMathFlagsString(builder)};
+ std::string fmfString{builder.getFastMathFlagsString()};
std::string funcName =
(mlir::Twine{callee.getLeafReference().getValue(), "x"} +
mlir::Twine{rank} +
@@ -1204,7 +1190,7 @@ void SimplifyIntrinsicsPass::simplifyMinlocReduction(
mlir::Value outputAlloc = outputDef->getOperand(0);
mlir::Type outType = hlfir::getFortranElementType(outputAlloc.getType());
- std::string fmfString{getFastMathFlagsString(builder)};
+ std::string fmfString{builder.getFastMathFlagsString()};
std::string funcName =
(mlir::Twine{callee.getLeafReference().getValue(), "x"} +
mlir::Twine{rank} +
@@ -1298,7 +1284,7 @@ void SimplifyIntrinsicsPass::runOnOperation() {
fir::FirOpBuilder builder{getSimplificationBuilder(op, kindMap)};
// Stringize the builder's FastMathFlags flags for mangling
// the generated function name.
- std::string fmfString{getFastMathFlagsString(builder)};
+ std::string fmfString{builder.getFastMathFlagsString()};
mlir::Type type = call.getResult(0).getType();
if (!type.isa<mlir::FloatType>() && !type.isa<mlir::IntegerType>())
diff --git a/flang/test/Lower/Intrinsics/exp.f90 b/flang/test/Lower/Intrinsics/exp.f90
index 539ed6468b770b..eb42235140f0cb 100644
--- a/flang/test/Lower/Intrinsics/exp.f90
+++ b/flang/test/Lower/Intrinsics/exp.f90
@@ -10,7 +10,7 @@
subroutine exp_testr(a, b)
real :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f32>
-! CHECK: %[[RES:.*]] = fir.call @fir.exp.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
+! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f32>
b = exp(a)
end subroutine
@@ -20,7 +20,7 @@ subroutine exp_testr(a, b)
subroutine exp_testd(a, b)
real(kind=8) :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f64>
-! CHECK: %[[RES:.*]] = fir.call @fir.exp.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
+! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f64>
b = exp(a)
end subroutine
@@ -30,7 +30,7 @@ subroutine exp_testd(a, b)
subroutine exp_testc(a, b)
complex :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<!fir.complex<4>>
-! CHECK: %[[RES:.*]] = fir.call @fir.exp.z4.z4(%[[A]]) {{.*}}: (!fir.complex<4>) -> !fir.complex<4>
+! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.z4.z4(%[[A]]) {{.*}}: (!fir.complex<4>) -> !fir.complex<4>
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<!fir.complex<4>>
b = exp(a)
end subroutine
@@ -40,33 +40,33 @@ subroutine exp_testc(a, b)
subroutine exp_testcd(a, b)
complex(kind=8) :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<!fir.complex<8>>
-! CHECK: %[[RES:.*]] = fir.call @fir.exp.z8.z8(%[[A]]) {{.*}}: (!fir.complex<8>) -> !fir.complex<8>
+! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.z8.z8(%[[A]]) {{.*}}: (!fir.complex<8>) -> !fir.complex<8>
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<!fir.complex<8>>
b = exp(a)
end subroutine
-! CHECK-LABEL: private @fir.exp.f32.f32
+! CHECK-LABEL: private @fir.exp.contract.f32.f32
! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
-! CHECK: %[[RESULT32_OUTLINE:.*]] = math.exp %[[ARG32_OUTLINE]] : f32
+! CHECK: %[[RESULT32_OUTLINE:.*]] = math.exp %[[ARG32_OUTLINE]] fastmath<contract> : f32
! CHECK: return %[[RESULT32_OUTLINE]] : f32
-! CHECK-LABEL: private @fir.exp.f64.f64
+! CHECK-LABEL: private @fir.exp.contract.f64.f64
! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
-! CHECK: %[[RESULT64_OUTLINE:.*]] = math.exp %[[ARG64_OUTLINE]] : f64
+! CHECK: %[[RESULT64_OUTLINE:.*]] = math.exp %[[ARG64_OUTLINE]] fastmath<contract> : f64
! CHECK: return %[[RESULT64_OUTLINE]] : f64
-! CMPLX-LABEL: private @fir.exp.z4.z4
+! CMPLX-LABEL: private @fir.exp.contract.z4.z4
! CMPLX-SAME: (%[[ARG32_OUTLINE:.*]]: !fir.complex<4>) -> !fir.complex<4>
! CMPLX-FAST: %[[C:.*]] = fir.convert %[[ARG32_OUTLINE]] : (!fir.complex<4>) -> complex<f32>
! CMPLX-FAST: %[[E:.*]] = complex.exp %[[C]] : complex<f32>
! CMPLX-FAST: %[[RESULT32_OUTLINE:.*]] = fir.convert %[[E]] : (complex<f32>) -> !fir.complex<4>
-! CMPLX-PRECISE: %[[RESULT32_OUTLINE:.*]] = fir.call @cexpf(%[[ARG32_OUTLINE]]) : (!fir.complex<4>) -> !fir.complex<4>
+! CMPLX-PRECISE: %[[RESULT32_OUTLINE:.*]] = fir.call @cexpf(%[[ARG32_OUTLINE]]) fastmath<contract> : (!fir.complex<4>) -> !fir.complex<4>
! CMPLX: return %[[RESULT32_OUTLINE]] : !fir.complex<4>
-! CMPLX-LABEL: private @fir.exp.z8.z8
+! CMPLX-LABEL: private @fir.exp.contract.z8.z8
! CMPLX-SAME: (%[[ARG64_OUTLINE:.*]]: !fir.complex<8>) -> !fir.complex<8>
! CMPLX-FAST: %[[C:.*]] = fir.convert %[[ARG64_OUTLINE]] : (!fir.complex<8>) -> complex<f64>
! CMPLX-FAST: %[[E:.*]] = complex.exp %[[C]] : complex<f64>
! CMPLX-FAST: %[[RESULT64_OUTLINE:.*]] = fir.convert %[[E]] : (complex<f64>) -> !fir.complex<8>
-! CMPLX-PRECISE: %[[RESULT64_OUTLINE:.*]] = fir.call @cexp(%[[ARG64_OUTLINE]]) : (!fir.complex<8>) -> !fir.complex<8>
+! CMPLX-PRECISE: %[[RESULT64_OUTLINE:.*]] = fir.call @cexp(%[[ARG64_OUTLINE]]) fastmath<contract> : (!fir.complex<8>) -> !fir.complex<8>
! CMPLX: return %[[RESULT64_OUTLINE]] : !fir.complex<8>
diff --git a/flang/test/Lower/Intrinsics/log.f90 b/flang/test/Lower/Intrinsics/log.f90
index 0a28d7a944bc24..e3b9ba8a8436ac 100644
--- a/flang/test/Lower/Intrinsics/log.f90
+++ b/flang/test/Lower/Intrinsics/log.f90
@@ -10,7 +10,7 @@
subroutine log_testr(a, b)
real :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f32>
-! CHECK: %[[RES:.*]] = fir.call @fir.log.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
+! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f32>
b = log(a)
end subroutine
@@ -20,7 +20,7 @@ subroutine log_testr(a, b)
subroutine log_testd(a, b)
real(kind=8) :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f64>
-! CHECK: %[[RES:.*]] = fir.call @fir.log.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
+! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f64>
b = log(a)
end subroutine
@@ -30,7 +30,7 @@ subroutine log_testd(a, b)
subroutine log_testc(a, b)
complex :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<!fir.complex<4>>
-! CHECK: %[[RES:.*]] = fir.call @fir.log.z4.z4(%[[A]]) {{.*}}: (!fir.complex<4>) -> !fir.complex<4>
+! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.z4.z4(%[[A]]) {{.*}}: (!fir.complex<4>) -> !fir.complex<4>
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<!fir.complex<4>>
b = log(a)
end subroutine
@@ -40,7 +40,7 @@ subroutine log_testc(a, b)
subroutine log_testcd(a, b)
complex(kind=8) :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<!fir.complex<8>>
-! CHECK: %[[RES:.*]] = fir.call @fir.log.z8.z8(%[[A]]) {{.*}}: (!fir.complex<8>) -> !fir.complex<8>
+! CHECK: %[[RES:.*]] = fir.call @fir.log.contract.z8.z8(%[[A]]) {{.*}}: (!fir.complex<8>) -> !fir.complex<8>
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<!fir.complex<8>>
b = log(a)
end subroutine
@@ -50,7 +50,7 @@ subroutine log_testcd(a, b)
subroutine log10_testr(a, b)
real :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f32>
-! CHECK: %[[RES:.*]] = fir.call @fir.log10.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
+! CHECK: %[[RES:.*]] = fir.call @fir.log10.contract.f32.f32(%[[A]]) {{.*}}: (f32) -> f32
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f32>
b = log10(a)
end subroutine
@@ -60,43 +60,43 @@ subroutine log10_testr(a, b)
subroutine log10_testd(a, b)
real(kind=8) :: a, b
! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref<f64>
-! CHECK: %[[RES:.*]] = fir.call @fir.log10.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
+! CHECK: %[[RES:.*]] = fir.call @fir.log10.contract.f64.f64(%[[A]]) {{.*}}: (f64) -> f64
! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref<f64>
b = log10(a)
end subroutine
-! CHECK-LABEL: private @fir.log.f32.f32
+! CHECK-LABEL: private @fir.log.contract.f32.f32
! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
-! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log %[[ARG32_OUTLINE]] : f32
+! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log %[[ARG32_OUTLINE]] fastmath<contract> : f32
! CHECK: return %[[RESULT32_OUTLINE]] : f32
-! CHECK-LABEL: private @fir.log.f64.f64
+! CHECK-LABEL: private @fir.log.contract.f64.f64
! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
-! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log %[[ARG64_OUTLINE]] : f64
+! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log %[[ARG64_OUTLINE]] fastmath<contract> : f64
! CHECK: return %[[RESULT64_OUTLINE]] : f64
-! CMPLX-LABEL: private @fir.log.z4.z4
+! CMPLX-LABEL: private @fir.log.contract.z4.z4
! CMPLX-SAME: (%[[ARG32_OUTLINE:.*]]: !fir.complex<4>) -> !fir.complex<4>
! CMPLX-FAST: %[[C:.*]] = fir.convert %[[ARG32_OUTLINE]] : (!fir.complex<4>) -> complex<f32>
! CMPLX-FAST: %[[E:.*]] = complex.log %[[C]] : complex<f32>
! CMPLX-FAST: %[[RESULT32_OUTLINE:.*]] = fir.convert %[[E]] : (complex<f32>) -> !fir.complex<4>
-! CMPLX-PRECISE: %[[RESULT32_OUTLINE:.*]] = fir.call @clogf(%[[ARG32_OUTLINE]]) : (!fir.complex<4>) -> !fir.complex<4>
+! CMPLX-PRECISE: %[[RESULT32_OUTLINE:.*]] = fir.call @clogf(%[[ARG32_OUTLINE]]) fastmath<contract> : (!fir.complex<4>) -> !fir.complex<4>
! CMPLX: return %[[RESULT32_OUTLINE]] : !fir.complex<4>
-! CMPLX-LABEL: private @fir.log.z8.z8
+! CMPLX-LABEL: private @fir.log.contract.z8.z8
! CMPLX-SAME: (%[[ARG64_OUTLINE:.*]]: !fir.complex<8>) -> !fir.complex<8>
! CMPLX-FAST: %[[C:.*]] = fir.convert %[[ARG64_OUTLINE]] : (!fir.complex<8>) -> complex<f64>
! CMPLX-FAST: %[[E:.*]] = complex.log %[[C]] : complex<f64>
! CMPLX-FAST: %[[RESULT64_OUTLINE:.*]] = fir.convert %[[E]] : (complex<f64>) -> !fir.complex<8>
-! CMPLX-PRECISE: %[[RESULT64_OUTLINE:.*]] = fir.call @clog(%[[ARG64_OUTLINE]]) : (!fir.complex<8>) -> !fir.complex<8>
+! CMPLX-PRECISE: %[[RESULT64_OUTLINE:.*]] = fir.call @clog(%[[ARG64_OUTLINE]]) fastmath<contract> : (!fir.complex<8>) -> !fir.complex<8>
! CMPLX: return %[[RESULT64_OUTLINE]] : !fir.complex<8>
-! CHECK-LABEL: private @fir.log10.f32.f32
+! CHECK-LABEL: private @fir.log10.contract.f32.f32
! CHECK-SAME: (%[[ARG32_OUTLINE:.*]]: f32) -> f32
-! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log10 %[[ARG32_OUTLINE]] : f32
+! CHECK: %[[RESULT32_OUTLINE:.*]] = math.log10 %[[ARG32_OUTLINE]] fastmath<contract> : f32
! CHECK: return %[[RESULT32_OUTLINE]] : f32
-! CHECK-LABEL: private @fir.log10.f64.f64
+! CHECK-LABEL: private @fir.log10.contract.f64.f64
! CHECK-SAME: (%[[ARG64_OUTLINE:.*]]: f64) -> f64
-! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log10 %[[ARG64_OUTLINE]] : f64
+! CHECK: %[[RESULT64_OUTLINE:.*]] = math.log10 %[[ARG64_OUTLINE]] fastmath<contract> : f64
! CHECK: return %[[RESULT64_OUTLINE]] : f64
diff --git a/flang/test/Lower/Intrinsics/math-runtime-options.f90 b/flang/test/Lower/Intrinsics/math-runtime-options.f90
index 4b48c9bc5719b9..7cc1e7fe2e98d3 100644
--- a/flang/test/Lower/Intrinsics/math-runtime-options.f90
+++ b/flang/test/Lower/Intrinsics/math-runtime-options.f90
@@ -8,22 +8,22 @@
! CHECK-LABEL: cos_testr
subroutine cos_testr(a, b)
real :: a, b
-! FIR: fir.call @fir.cos.f32.f32
+! FIR: fir.call @fir.cos.contract.f32.f32
b = cos(a)
end subroutine
! CHECK-LABEL: cos_testd
subroutine cos_testd(a, b)
real(kind=8) :: a, b
-! FIR: fir.call @fir.cos.f64.f64
+! FIR: fir.call @fir.cos.contract.f64.f64
b = cos(a)
end subroutine
-! FIR: @fir.cos.f32.f32(%arg0: f32) -> f32 attributes
-! FAST: math.cos %arg0 : f32
-! RELAXED: math.cos %arg0 : f32
-! PRECISE: fir.call @cosf(%arg0) : (f32) -> f32
-! FIR: @fir.cos.f64.f64(%arg0: f64) -> f64
-! FAST: math.cos %arg0 : f64
-! RELAXED: math.cos %arg0 : f64
-! PRECISE: fir.call @cos(%arg0) : (f64) -> f64
+! FIR: @fir.cos.contract.f32.f32(%arg0: f32) -> f32 attributes
+! FAST: math.cos %arg0 fastmath<contract> : f32
+! RELAXED: math.cos %arg0 fastmath<contract> : f32
+! PRECISE: fir.call @cosf(%arg0) fastmath<contract> : (f32) -> f32
+! FIR: @fir.cos.contract.f64.f64(%arg0: f64) -> f64
+! FAST: math.cos %arg0 fastmath<contract> : f64
+! RELAXED: math.cos %arg0 fastmath<contract> : f64
+! PRECISE: fir.call @cos(%arg0) fastmath<contract> : (f64) -> f64
diff --git a/flang/test/Lower/array-expression-slice-1.f90 b/flang/test/Lower/array-expression-slice-1.f90
index 0f8b3c12041bea..dd6a8e7284cb4b 100644
--- a/flang/test/Lower/array-expression-slice-1.f90
+++ b/flang/test/Lower/array-expression-slice-1.f90
@@ -43,7 +43,7 @@
! CHECK: fir.store %[[VAL_41]] to %[[VAL_31]] : !fir.ref<i32>
! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_31]] : !fir.ref<i32>
! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_42]] : (i32) -> f32
-! CHECK: %[[VAL_44:.*]] = fir.call @fir.cos.f32.f32(%[[VAL_43]]) {{.*}}: (f32) -> f32
+! CHECK: %[[VAL_44:.*]] = fir.call @fir.cos.contract.f32.f32(%[[VAL_43]]) {{.*}}: (f32) -> f32
! CHECK: %[[VAL_45:.*]] = fir.load %[[VAL_28]] : !fir.ref<i32>
! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_45]] : (i32) -> i64
! CHECK: %[[VAL_47:.*]] = arith.subi %[[VAL_46]], %[[VAL_20]] : i64
@@ -60,7 +60,7 @@
! CHECK: fir.store %[[VAL_36]] to %[[VAL_28]] : !fir.ref<i32>
! CHECK: %[[VAL_55:.*]] = fir.load %[[VAL_31]] : !fir.ref<i32>
! CHECK: %[[VAL_56:.*]] = fir.convert %[[VAL_55]] : (i32) -> f32
-! CHECK: %[[VAL_57:.*]] = fir.call @fir.sin.f32.f32(%[[VAL_56]]) {{.*}}: (f32) -> f32
+! CHECK: %[[VAL_57:.*]] = fir.call @fir.sin.contract.f32.f32(%[[VAL_56]]) {{.*}}: (f32) -> f32
! CHECK: %[[VAL_58:.*]] = fir.load %[[VAL_30]] : !fir.ref<i32>
! CHECK: %[[VAL_59:.*]] = fir.convert %[[VAL_58]] : (i32) -> i64
! CHECK: %[[VAL_60:.*]] = arith.subi %[[VAL_59]], %[[VAL_20]] : i64
diff --git a/flang/test/Lower/dummy-procedure.f90 b/flang/test/Lower/dummy-procedure.f90
index bbabebd44d1a7b..4d6b44c0792094 100644
--- a/flang/test/Lower/dummy-procedure.f90
+++ b/flang/test/Lower/dummy-procedure.f90
@@ -154,14 +154,14 @@ subroutine todo3(dummy_proc)
! CHECK-LABEL: func private @fir.acos.f32.ref_f32(%arg0: !fir.ref<f32>) -> f32
!CHECK: %[[load:.*]] = fir.load %arg0
- !CHECK: %[[res:.*]] = fir.call @acosf(%[[load]]) : (f32) -> f32
+ !CHECK: %[[res:.*]] = fir.call @acosf(%[[load]]) fastmath<contract> : (f32) -> f32
!CHECK: return %[[res]] : f32
! CHECK-LABEL: func private @fir.atan2.f32.ref_f32.ref_f32(
! CHECK-SAME: %[[x:.*]]: !fir.ref<f32>, %[[y:.*]]: !fir.ref<f32>) -> f32
! CHECK-DAG: %[[xload:.*]] = fir.load %[[x]] : !fir.ref<f32>
! CHECK-DAG: %[[yload:.*]] = fir.load %[[y]] : !fir.ref<f32>
- ! CHECK: %[[atan2:.*]] = math.atan2 %[[xload]], %[[yload]] : f32
+ ! CHECK: %[[atan2:.*]] = math.atan2 %[[xload]], %[[yload]] fastmath<contract> : f32
! CHECK: return %[[atan2]] : f32
!CHECK-LABEL: func private @fir.aimag.f32.ref_z4(%arg0: !fir.ref<!fir.complex<4>>)
diff --git a/flang/test/Lower/intrinsic-procedure-wrappers.f90 b/flang/test/Lower/intrinsic-procedure-wrappers.f90
index 08f77a0efa8423..210cfb41343016 100644
--- a/flang/test/Lower/intrinsic-procedure-wrappers.f90
+++ b/flang/test/Lower/intrinsic-procedure-wrappers.f90
@@ -7,4 +7,4 @@ function foo(x)
foo = acos(x)
end function
-! CHECK: llvm.func internal @fir.acos.f32.f32
+! CHECK: llvm.func internal @fir.acos.contract.f32.f32
diff --git a/flang/test/Lower/sqrt.f90 b/flang/test/Lower/sqrt.f90
index 4b4bc9e3ff52a0..e55911a49312ce 100644
--- a/flang/test/Lower/sqrt.f90
+++ b/flang/test/Lower/sqrt.f90
@@ -8,41 +8,41 @@
! CHECK-LABEL: sqrt_testr
subroutine sqrt_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.sqrt.f32.f32
+! CHECK: fir.call @fir.sqrt.contract.f32.f32
b = sqrt(a)
end subroutine
! CHECK-LABEL: sqrt_testd
subroutine sqrt_testd(a, b)
real(kind=8) :: a, b
-! CHECK: fir.call @fir.sqrt.f64.f64
+! CHECK: fir.call @fir.sqrt.contract.f64.f64
b = sqrt(a)
end subroutine
! CHECK-LABEL: sqrt_testc
subroutine sqrt_testc(z)
complex :: z
-! CHECK: fir.call @fir.sqrt.z4.z4
+! CHECK: fir.call @fir.sqrt.contract.z4.z4
z = sqrt(z)
end subroutine
! CHECK-LABEL: sqrt_testcd
subroutine sqrt_testcd(z)
complex(kind=8) :: z
-! CHECK: fir.call @fir.sqrt.z8.z8
+! CHECK: fir.call @fir.sqrt.contract.z8.z8
z = sqrt(z)
end subroutine
-! CHECK-LABEL: @fir.sqrt.f32.f32
+! CHECK-LABEL: @fir.sqrt.contract.f32.f32
! CHECK: math.sqrt %{{.*}} : f32
-! CHECK-LABEL: @fir.sqrt.f64.f64
+! CHECK-LABEL: @fir.sqrt.contract.f64.f64
! CHECK: math.sqrt %{{.*}} : f64
-! CHECK-LABEL: func private @fir.sqrt.z4.z4
+! CHECK-LABEL: func private @fir.sqrt.contract.z4.z4
! CMPLX-FAST: complex.sqrt %{{.*}} : complex<f32>
! CMPLX-PRECISE: fir.call @csqrtf
-! CHECK-LABEL: @fir.sqrt.z8.z8
+! CHECK-LABEL: @fir.sqrt.contract.z8.z8
! CMPLX-FAST: complex.sqrt %{{.*}} : complex<f64>
! CMPLX-PRECISE: fir.call @csqrt
diff --git a/flang/test/Lower/trigonometric-intrinsics.f90 b/flang/test/Lower/trigonometric-intrinsics.f90
index e1e690c9ffd580..139bf10873c5fe 100644
--- a/flang/test/Lower/trigonometric-intrinsics.f90
+++ b/flang/test/Lower/trigonometric-intrinsics.f90
@@ -5,245 +5,245 @@
! CHECK-LABEL: tan_testr
subroutine tan_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.tan.f32.f32
+! CHECK: fir.call @fir.tan.contract.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
+! CHECK: fir.call @fir.tan.contract.f64.f64
b = tan(a)
end subroutine
! CHECK-LABEL: tan_testc
subroutine tan_testc(z)
complex :: z
-! CHECK: fir.call @fir.tan.z4.z4
+! CHECK: fir.call @fir.tan.contract.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
+! CHECK: fir.call @fir.tan.contract.z8.z8
z = tan(z)
end subroutine
! CHECK-LABEL: atan_testr
subroutine atan_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.atan.f32.f32
+! CHECK: fir.call @fir.atan.contract.f32.f32
b = atan(a)
end subroutine
! CHECK-LABEL: atan_testd
subroutine atan_testd(a, b)
real(kind=8) :: a, b
-! CHECK: fir.call @fir.atan.f64.f64
+! CHECK: fir.call @fir.atan.contract.f64.f64
b = atan(a)
end subroutine
! CHECK-LABEL: atan_testc
subroutine atan_testc(z)
complex :: z
-! CHECK: fir.call @fir.atan.z4.z4
+! CHECK: fir.call @fir.atan.contract.z4.z4
z = atan(z)
end subroutine
! CHECK-LABEL: atan_testcd
subroutine atan_testcd(z)
complex(kind=8) :: z
-! CHECK: fir.call @fir.atan.z8.z8
+! CHECK: fir.call @fir.atan.contract.z8.z8
z = atan(z)
end subroutine
! CHECK-LABEL: cos_testr
subroutine cos_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.cos.f32.f32
+! CHECK: fir.call @fir.cos.contract.f32.f32
b = cos(a)
end subroutine
! CHECK-LABEL: cos_testd
subroutine cos_testd(a, b)
real(kind=8) :: a, b
-! CHECK: fir.call @fir.cos.f64.f64
+! CHECK: fir.call @fir.cos.contract.f64.f64
b = cos(a)
end subroutine
! CHECK-LABEL: cos_testc
subroutine cos_testc(z)
complex :: z
-! CHECK: fir.call @fir.cos.z4.z4
+! CHECK: fir.call @fir.cos.contract.z4.z4
z = cos(z)
end subroutine
! CHECK-LABEL: cos_testcd
subroutine cos_testcd(z)
complex(kind=8) :: z
-! CHECK: fir.call @fir.cos.z8.z8
+! CHECK: fir.call @fir.cos.contract.z8.z8
z = cos(z)
end subroutine
! CHECK-LABEL: cosh_testr
subroutine cosh_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.cosh.f32.f32
+! CHECK: fir.call @fir.cosh.contract.f32.f32
b = cosh(a)
end subroutine
! CHECK-LABEL: cosh_testd
subroutine cosh_testd(a, b)
real(kind=8) :: a, b
-! CHECK: fir.call @fir.cosh.f64.f64
+! CHECK: fir.call @fir.cosh.contract.f64.f64
b = cosh(a)
end subroutine
! CHECK-LABEL: cosh_testc
subroutine cosh_testc(z)
complex :: z
-! CHECK: fir.call @fir.cosh.z4.z4
+! CHECK: fir.call @fir.cosh.contract.z4.z4
z = cosh(z)
end subroutine
! CHECK-LABEL: cosh_testcd
subroutine cosh_testcd(z)
complex(kind=8) :: z
-! CHECK: fir.call @fir.cosh.z8.z8
+! CHECK: fir.call @fir.cosh.contract.z8.z8
z = cosh(z)
end subroutine
! CHECK-LABEL: sin_testr
subroutine sin_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.sin.f32.f32
+! CHECK: fir.call @fir.sin.contract.f32.f32
b = sin(a)
end subroutine
! CHECK-LABEL: sin_testd
subroutine sin_testd(a, b)
real(kind=8) :: a, b
-! CHECK: fir.call @fir.sin.f64.f64
+! CHECK: fir.call @fir.sin.contract.f64.f64
b = sin(a)
end subroutine
! CHECK-LABEL: sin_testc
subroutine sin_testc(z)
complex :: z
-! CHECK: fir.call @fir.sin.z4.z4
+! CHECK: fir.call @fir.sin.contract.z4.z4
z = sin(z)
end subroutine
! CHECK-LABEL: sin_testcd
subroutine sin_testcd(z)
complex(kind=8) :: z
-! CHECK: fir.call @fir.sin.z8.z8
+! CHECK: fir.call @fir.sin.contract.z8.z8
z = sin(z)
end subroutine
! CHECK-LABEL: sinh_testr
subroutine sinh_testr(a, b)
real :: a, b
-! CHECK: fir.call @fir.sinh.f32.f32
+! CHECK: fir.call @fir.sinh.contract.f32.f32
b = sinh(a)
end subroutine
! CHECK-LABEL: sinh_testd
subroutine sinh_testd(a, b)
real(kind=8) :: a, b
-! CHECK: fir.call @fir.sinh.f64.f64
+! CHECK: fir.call @fir.sinh.contract.f64.f64
b = sinh(a)
end subroutine
! CHECK-LABEL: sinh_testc
subroutine sinh_testc(z)
complex :: z
-! CHECK: fir.call @fir.sinh.z4.z4
+! CHECK: fir.call @fir.sinh.contract.z4.z4
z = sinh(z)
end subroutine
! CHECK-LABEL: sinh_testcd
subroutine sinh_testcd(z)
complex(kind=8) :: z
-! CHECK: fir.call @fir.sinh.z8.z8
+! CHECK: fir.call @fir.sinh.contract.z8.z8
z = sinh(z)
end subroutine
-! CHECK-LABEL: @fir.tan.f32.f32
+! CHECK-LABEL: @fir.tan.contract.f32.f32
! CHECK: math.tan %{{.*}} : f32
-! CHECK-LABEL: @fir.tan.f64.f64
+! CHECK-LABEL: @fir.tan.contract.f64.f64
! CHECK: math.tan %{{.*}} : f64
-! CHECK-LABEL: @fir.tan.z4.z4
+! CHECK-LABEL: @fir.tan.contract.z4.z4
! CMPLX-FAST: complex.tan %{{.*}} : complex<f32>
! CMPLX-PRECISE: fir.call @ctanf
-! CHECK-LABEL: @fir.tan.z8.z8
+! CHECK-LABEL: @fir.tan.contract.z8.z8
! CMPLX-FAST: complex.tan %{{.*}} : complex<f64>
! CMPLX-PRECISE: fir.call @ctan
-! CHECK-LABEL: @fir.atan.f32.f32
+! CHECK-LABEL: @fir.atan.contract.f32.f32
! CHECK: math.atan %{{.*}} : f32
-! CHECK-LABEL: @fir.atan.f64.f64
+! CHECK-LABEL: @fir.atan.contract.f64.f64
! CHECK: math.atan %{{.*}} : f64
-! CHECK-LABEL: @fir.atan.z4.z4
+! CHECK-LABEL: @fir.atan.contract.z4.z4
! CHECK: fir.call @catanf
-! CHECK-LABEL: @fir.atan.z8.z8
+! CHECK-LABEL: @fir.atan.contract.z8.z8
! CHECK: fir.call @catan
-! CHECK-LABEL: @fir.cos.f32.f32
+! CHECK-LABEL: @fir.cos.contract.f32.f32
! CHECK: math.cos %{{.*}} : f32
-! CHECK-LABEL: @fir.cos.f64.f64
+! CHECK-LABEL: @fir.cos.contract.f64.f64
! CHECK: math.cos %{{.*}} : f64
-! CHECK-LABEL: @fir.cos.z4.z4
+! CHECK-LABEL: @fir.cos.contract.z4.z4
! CMPLX-FAST: complex.cos %{{.*}} : complex<f32>
! CMPLX-PRECISE: fir.call @ccosf
-! CHECK-LABEL: @fir.cos.z8.z8
+! CHECK-LABEL: @fir.cos.contract.z8.z8
! CMPLX-FAST: complex.cos %{{.*}} : complex<f64>
! CMPLX-PRECISE: fir.call @ccos
-! CHECK-LABEL: @fir.cosh.f32.f32
+! CHECK-LABEL: @fir.cosh.contract.f32.f32
! CHECK: fir.call {{.*}}cosh
-! CHECK-LABEL: @fir.cosh.f64.f64
+! CHECK-LABEL: @fir.cosh.contract.f64.f64
! CHECK: fir.call {{.*}}cosh
-! CHECK-LABEL: @fir.cosh.z4.z4
+! CHECK-LABEL: @fir.cosh.contract.z4.z4
! CHECK: fir.call @ccoshf
-! CHECK-LABEL: @fir.cosh.z8.z8
+! CHECK-LABEL: @fir.cosh.contract.z8.z8
! CHECK: fir.call @ccosh
-! CHECK-LABEL: @fir.sin.f32.f32
+! CHECK-LABEL: @fir.sin.contract.f32.f32
! CHECK: math.sin %{{.*}} : f32
-! CHECK-LABEL: @fir.sin.f64.f64
+! CHECK-LABEL: @fir.sin.contract.f64.f64
! CHECK: math.sin %{{.*}} : f64
-! CHECK-LABEL: @fir.sin.z4.z4
+! CHECK-LABEL: @fir.sin.contract.z4.z4
! CMPLX-FAST: complex.sin %{{.*}} : complex<f32>
! CMPLX-PRECISE: fir.call @csinf
-! CHECK-LABEL: @fir.sin.z8.z8
+! CHECK-LABEL: @fir.sin.contract.z8.z8
! CMPLX-FAST: complex.sin %{{.*}} : complex<f64>
! CMPLX-PRECISE: fir.call @csin
-! CHECK-LABEL: @fir.sinh.f32.f32
+! CHECK-LABEL: @fir.sinh.contract.f32.f32
! CHECK: fir.call {{.*}}sinh
-! CHECK-LABEL: @fir.sinh.f64.f64
+! CHECK-LABEL: @fir.sinh.contract.f64.f64
! CHECK: fir.call {{.*}}sinh
-! CHECK-LABEL: @fir.sinh.z4.z4
+! CHECK-LABEL: @fir.sinh.contract.z4.z4
! CHECK: fir.call @csinhf
-! CHECK-LABEL: @fir.sinh.z8.z8
+! CHECK-LABEL: @fir.sinh.contract.z8.z8
! CHECK: fir.call @csinh
More information about the flang-commits
mailing list