Skip to content

Commit 0dba5b3

Browse files
paperchaliceaokblast
authored andcommitted
[flang] Remove "unsafe-fp-math" attribute support (llvm#162783)
These global flags block furthur improvements for clang, users should always use fast-math flags see also https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast/80797 Remove them incrementally, this is the flang part.
1 parent 9fe1ddd commit 0dba5b3

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
436436
"Set the no-signed-zeros-fp-math attribute on functions in the "
437437
"module.">,
438438
Option<"unsafeFPMath", "unsafe-fp-math", "bool", /*default=*/"false",
439-
"Set the unsafe-fp-math attribute on functions in the module.">,
439+
"Set all fast-math flags on instructions in the module.">,
440440
Option<"reciprocals", "mrecip", "std::string", /*default=*/"",
441441
"Set the reciprocal-estimates attribute on functions in the "
442442
"module.">,

flang/include/flang/Tools/CrossToolHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct MLIRToLLVMPassPipelineConfig : public FlangEPCallBacks {
128128
bool ApproxFuncFPMath = false; ///< Set afn flag for instructions.
129129
bool NoSignedZerosFPMath =
130130
false; ///< Set no-signed-zeros-fp-math attribute for functions.
131-
bool UnsafeFPMath = false; ///< Set unsafe-fp-math attribute for functions.
131+
bool UnsafeFPMath = false; ///< Set all fast-math flags for instructions.
132132
std::string Reciprocals = ""; ///< Set reciprocal-estimate attribute for
133133
///< functions.
134134
std::string PreferVectorWidth = ""; ///< Set prefer-vector-width attribute for

flang/lib/Optimizer/Transforms/FunctionAttr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ void FunctionAttrPass::runOnOperation() {
9999
func->setAttr(
100100
mlir::LLVM::LLVMFuncOp::getNoSignedZerosFpMathAttrName(llvmFuncOpName),
101101
mlir::BoolAttr::get(context, true));
102-
if (unsafeFPMath)
103-
func->setAttr(
104-
mlir::LLVM::LLVMFuncOp::getUnsafeFpMathAttrName(llvmFuncOpName),
105-
mlir::BoolAttr::get(context, true));
106102
if (!reciprocals.empty())
107103
func->setAttr(
108104
mlir::LLVM::LLVMFuncOp::getReciprocalEstimatesAttrName(llvmFuncOpName),

flang/test/Driver/func-attr-fast-math.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ end subroutine func
1111

1212
! CHECK-OFAST-LABEL: define void @func_() local_unnamed_addr
1313
! CHECK-OFAST-SAME: #[[ATTRS:[0-9]+]]
14-
! CHECK-OFAST: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} }
14+
! CHECK-OFAST: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true"{{.*}} }
1515

1616
! CHECK-FFAST-MATH-LABEL: define void @func_() local_unnamed_addr
1717
! CHECK-FFAST-MATH-SAME: #[[ATTRS:[0-9]+]]
18-
! CHECK-FFAST-MATH: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} }
18+
! CHECK-FFAST-MATH: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true"{{.*}} }

0 commit comments

Comments
 (0)