diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 0b8b824fbcd5a..3f095c03397fd 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -425,7 +425,6 @@ static bool initTargetOptions(const CompilerInstance &CI, LangOptions::FPModeKind::FPM_Fast || LangOpts.getDefaultFPContractMode() == LangOptions::FPModeKind::FPM_FastHonorPragmas); - Options.ApproxFuncFPMath = LangOpts.ApproxFunc; Options.BBAddrMap = CodeGenOpts.BBAddrMap; Options.BBSections = diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 5b0dd235b58da..c024f944c9050 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2013,8 +2013,6 @@ static void getTrivialDefaultFunctionAttributes( FuncAttrs.addAttribute("no-infs-fp-math", "true"); if (LangOpts.NoHonorNaNs) FuncAttrs.addAttribute("no-nans-fp-math", "true"); - if (LangOpts.ApproxFunc) - FuncAttrs.addAttribute("approx-func-fp-math", "true"); if (LangOpts.AllowFPReassoc && LangOpts.AllowRecip && LangOpts.NoSignedZero && LangOpts.ApproxFunc && (LangOpts.getDefaultFPContractMode() == diff --git a/clang/test/CodeGen/afn-flag-test.c b/clang/test/CodeGen/afn-flag-test.c index f948fc068ba25..bc2ff5b95d7b3 100644 --- a/clang/test/CodeGen/afn-flag-test.c +++ b/clang/test/CodeGen/afn-flag-test.c @@ -7,8 +7,6 @@ double afn_option_test(double x) { // CHECK-LABEL: define{{.*}} double @afn_option_test(double %x) #0 { // CHECK-AFN: %{{.*}} = call afn double @{{.*}}exp{{.*}}(double %{{.*}}) - // CHECK-AFN: attributes #0 ={{.*}} "approx-func-fp-math"="true" {{.*}} // CHECK-NO-AFN: %{{.*}} = call double @{{.*}}exp{{.*}}(double %{{.*}}) - // CHECK-NO-AFN-NOT: attributes #0 ={{.*}} "approx-func-fp-math"="true" {{.*}} } diff --git a/clang/test/CodeGen/func-attr.c b/clang/test/CodeGen/func-attr.c index 96c3d91a7a67a..1b36c51b8ce9c 100644 --- a/clang/test/CodeGen/func-attr.c +++ b/clang/test/CodeGen/func-attr.c @@ -22,7 +22,6 @@ float foo(float a, float b) { // NOFINITEONLY: define{{.*}} float @foo(float noundef %{{.*}}, float noundef %{{.*}}){{.*}} [[ATTRS:#[0-9]+]] // CHECK: attributes [[ATTRS]] = { -// CHECK-SAME: "approx-func-fp-math"="true" // CHECK-SAME: "no-signed-zeros-fp-math"="true" // CHECK-SAME: "no-trapping-math"="true" // CHECK-UNSAFE-SAME: "unsafe-fp-math"="true" diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td index b230f60b4c59e..54190f09b1ec8 100644 --- a/flang/include/flang/Optimizer/Transforms/Passes.td +++ b/flang/include/flang/Optimizer/Transforms/Passes.td @@ -419,10 +419,9 @@ def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> { "Set the no-infs-fp-math attribute on functions in the module.">, Option<"noNaNsFPMath", "no-nans-fp-math", "bool", /*default=*/"false", "Set the no-nans-fp-math attribute on functions in the module.">, - Option< - "approxFuncFPMath", "approx-func-fp-math", "bool", - /*default=*/"false", - "Set the approx-func-fp-math attribute on functions in the module.">, + Option<"approxFuncFPMath", "approx-func-fp-math", "bool", + /*default=*/"false", + "Set the afn flag on instructions in the module.">, Option<"noSignedZerosFPMath", "no-signed-zeros-fp-math", "bool", /*default=*/"false", "Set the no-signed-zeros-fp-math attribute on functions in the " diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h index 51958fa36c3ad..335f0a45531c8 100644 --- a/flang/include/flang/Tools/CrossToolHelpers.h +++ b/flang/include/flang/Tools/CrossToolHelpers.h @@ -123,8 +123,7 @@ struct MLIRToLLVMPassPipelineConfig : public FlangEPCallBacks { unsigned VScaleMax = 0; ///< SVE vector range maximum. bool NoInfsFPMath = false; ///< Set no-infs-fp-math attribute for functions. bool NoNaNsFPMath = false; ///< Set no-nans-fp-math attribute for functions. - bool ApproxFuncFPMath = - false; ///< Set approx-func-fp-math attribute for functions. + bool ApproxFuncFPMath = false; ///< Set afn flag for instructions. bool NoSignedZerosFPMath = false; ///< Set no-signed-zeros-fp-math attribute for functions. bool UnsafeFPMath = false; ///< Set unsafe-fp-math attribute for functions. diff --git a/flang/lib/Optimizer/Transforms/FunctionAttr.cpp b/flang/lib/Optimizer/Transforms/FunctionAttr.cpp index 5ac4ed8a93b6b..9dfe26cbf5899 100644 --- a/flang/lib/Optimizer/Transforms/FunctionAttr.cpp +++ b/flang/lib/Optimizer/Transforms/FunctionAttr.cpp @@ -95,10 +95,6 @@ void FunctionAttrPass::runOnOperation() { func->setAttr( mlir::LLVM::LLVMFuncOp::getNoNansFpMathAttrName(llvmFuncOpName), mlir::BoolAttr::get(context, true)); - if (approxFuncFPMath) - func->setAttr( - mlir::LLVM::LLVMFuncOp::getApproxFuncFpMathAttrName(llvmFuncOpName), - mlir::BoolAttr::get(context, true)); if (noSignedZerosFPMath) func->setAttr( mlir::LLVM::LLVMFuncOp::getNoSignedZerosFpMathAttrName(llvmFuncOpName), diff --git a/flang/test/Driver/func-attr-fast-math.f90 b/flang/test/Driver/func-attr-fast-math.f90 index c21f385fe690f..3b6ce602c5373 100644 --- a/flang/test/Driver/func-attr-fast-math.f90 +++ b/flang/test/Driver/func-attr-fast-math.f90 @@ -11,8 +11,8 @@ end subroutine func ! CHECK-OFAST-LABEL: define void @func_() local_unnamed_addr ! CHECK-OFAST-SAME: #[[ATTRS:[0-9]+]] -! CHECK-OFAST: attributes #[[ATTRS]] = { {{.*}}"approx-func-fp-math"="true" {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} } +! CHECK-OFAST: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} } ! CHECK-FFAST-MATH-LABEL: define void @func_() local_unnamed_addr ! CHECK-FFAST-MATH-SAME: #[[ATTRS:[0-9]+]] -! CHECK-FFAST-MATH: attributes #[[ATTRS]] = { {{.*}}"approx-func-fp-math"="true" {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} } +! 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"{{.*}} } diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h index d500e941036e6..39c5a8d479a5f 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -66,8 +66,6 @@ LLVM_ABI bool getEnableNoNaNsFPMath(); LLVM_ABI bool getEnableNoSignedZerosFPMath(); -LLVM_ABI bool getEnableApproxFuncFPMath(); - LLVM_ABI bool getEnableNoTrappingFPMath(); LLVM_ABI DenormalMode::DenormalModeKind getDenormalFPMath(); diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td index 112853965407c..ef816fb86ed1d 100644 --- a/llvm/include/llvm/IR/Attributes.td +++ b/llvm/include/llvm/IR/Attributes.td @@ -406,7 +406,6 @@ def AllowDirectAccessInHotPatchFunction def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; -def ApproxFuncFPMath : StrBoolAttr<"approx-func-fp-math">; def NoSignedZerosFPMath : StrBoolAttr<"no-signed-zeros-fp-math">; def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; def NoJumpTables : StrBoolAttr<"no-jump-tables">; @@ -471,7 +470,6 @@ class MergeRule { def : MergeRule<"setAND">; def : MergeRule<"setAND">; def : MergeRule<"setAND">; -def : MergeRule<"setAND">; def : MergeRule<"setAND">; def : MergeRule<"setAND">; def : MergeRule<"setOR">; diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index db90f2e4cc7cc..2c2122a7b204f 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -120,7 +120,7 @@ class TargetOptions { TargetOptions() : UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false), NoTrappingFPMath(true), NoSignedZerosFPMath(false), - ApproxFuncFPMath(false), EnableAIXExtendedAltivecABI(false), + EnableAIXExtendedAltivecABI(false), HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false), GuaranteedTailCallOpt(false), StackSymbolOrdering(true), EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false), @@ -186,12 +186,6 @@ class TargetOptions { /// argument or result as insignificant. unsigned NoSignedZerosFPMath : 1; - /// ApproxFuncFPMath - This flag is enabled when the - /// -enable-approx-func-fp-math is specified on the command line. This - /// specifies that optimizations are allowed to substitute math functions - /// with approximate calculations - unsigned ApproxFuncFPMath : 1; - /// EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is /// specified. The code generator is then able to use both volatile and /// nonvolitle vector registers. When false, the code generator only uses diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index 810dc29d728d4..0522698adf183 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -68,7 +68,6 @@ CGOPT(bool, EnableUnsafeFPMath) CGOPT(bool, EnableNoInfsFPMath) CGOPT(bool, EnableNoNaNsFPMath) CGOPT(bool, EnableNoSignedZerosFPMath) -CGOPT(bool, EnableApproxFuncFPMath) CGOPT(bool, EnableNoTrappingFPMath) CGOPT(bool, EnableAIXExtendedAltivecABI) CGOPT(DenormalMode::DenormalModeKind, DenormalFPMath) @@ -245,12 +244,6 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { cl::init(false)); CGBINDOPT(EnableNoSignedZerosFPMath); - static cl::opt EnableApproxFuncFPMath( - "enable-approx-func-fp-math", - cl::desc("Enable FP math optimizations that assume approx func"), - cl::init(false)); - CGBINDOPT(EnableApproxFuncFPMath); - static cl::opt EnableNoTrappingFPMath( "enable-no-trapping-fp-math", cl::desc("Enable setting the FP exceptions build " @@ -563,7 +556,6 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) { Options.NoInfsFPMath = getEnableNoInfsFPMath(); Options.NoNaNsFPMath = getEnableNoNaNsFPMath(); Options.NoSignedZerosFPMath = getEnableNoSignedZerosFPMath(); - Options.ApproxFuncFPMath = getEnableApproxFuncFPMath(); Options.NoTrappingFPMath = getEnableNoTrappingFPMath(); DenormalMode::DenormalModeKind DenormKind = getDenormalFPMath(); @@ -718,7 +710,6 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features, HANDLE_BOOL_ATTR(EnableNoInfsFPMathView, "no-infs-fp-math"); HANDLE_BOOL_ATTR(EnableNoNaNsFPMathView, "no-nans-fp-math"); HANDLE_BOOL_ATTR(EnableNoSignedZerosFPMathView, "no-signed-zeros-fp-math"); - HANDLE_BOOL_ATTR(EnableApproxFuncFPMathView, "approx-func-fp-math"); if (DenormalFPMathView->getNumOccurrences() > 0 && !F.hasFnAttribute("denormal-fp-math")) { diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 69b6e26e602f6..ad7e503cb1552 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -162,7 +162,6 @@ void TargetMachine::resetTargetOptions(const Function &F) const { RESET_OPTION(NoInfsFPMath, "no-infs-fp-math"); RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math"); RESET_OPTION(NoSignedZerosFPMath, "no-signed-zeros-fp-math"); - RESET_OPTION(ApproxFuncFPMath, "approx-func-fp-math"); } /// Returns the code generation relocation model. The choices are static, PIC, diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 3f27f6d9ae8b7..cccbf8d57ecc6 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -1961,7 +1961,6 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [ OptionalAttr:$unsafe_fp_math, OptionalAttr:$no_infs_fp_math, OptionalAttr:$no_nans_fp_math, - OptionalAttr:$approx_func_fp_math, OptionalAttr:$no_signed_zeros_fp_math, OptionalAttr:$denormal_fp_math, OptionalAttr:$denormal_fp_math_f32, diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp index 40726365cd06e..078a073df8fd6 100644 --- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp @@ -2536,7 +2536,6 @@ static constexpr std::array kExplicitAttributes{ StringLiteral("aarch64_pstate_sm_compatible"), StringLiteral("aarch64_pstate_sm_enabled"), StringLiteral("alwaysinline"), - StringLiteral("approx-func-fp-math"), StringLiteral("convergent"), StringLiteral("denormal-fp-math"), StringLiteral("denormal-fp-math-f32"), @@ -2704,10 +2703,6 @@ void ModuleImport::processFunctionAttributes(llvm::Function *func, attr.isStringAttribute()) funcOp.setNoNansFpMath(attr.getValueAsBool()); - if (llvm::Attribute attr = func->getFnAttribute("approx-func-fp-math"); - attr.isStringAttribute()) - funcOp.setApproxFuncFpMath(attr.getValueAsBool()); - if (llvm::Attribute attr = func->getFnAttribute("instrument-function-entry"); attr.isStringAttribute()) funcOp.setInstrumentFunctionEntry( diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index b3a06e2be7fe6..8adfaf85335df 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1561,10 +1561,6 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) { if (auto noNansFpMath = func.getNoNansFpMath()) llvmFunc->addFnAttr("no-nans-fp-math", llvm::toStringRef(*noNansFpMath)); - if (auto approxFuncFpMath = func.getApproxFuncFpMath()) - llvmFunc->addFnAttr("approx-func-fp-math", - llvm::toStringRef(*approxFuncFpMath)); - if (auto noSignedZerosFpMath = func.getNoSignedZerosFpMath()) llvmFunc->addFnAttr("no-signed-zeros-fp-math", llvm::toStringRef(*noSignedZerosFpMath)); diff --git a/mlir/test/Dialect/LLVMIR/func.mlir b/mlir/test/Dialect/LLVMIR/func.mlir index a168cebff019b..071f12431e5b7 100644 --- a/mlir/test/Dialect/LLVMIR/func.mlir +++ b/mlir/test/Dialect/LLVMIR/func.mlir @@ -276,12 +276,6 @@ module { llvm.return } - llvm.func @approx_func_fp_math_roundtrip() attributes {approx_func_fp_math = true} { - // CHECK: @approx_func_fp_math_roundtrip - // CHECK-SAME: attributes {approx_func_fp_math = true} - llvm.return - } - llvm.func @no_signed_zeros_fp_math_roundtrip() attributes {no_signed_zeros_fp_math = true} { // CHECK: @no_signed_zeros_fp_math_roundtrip // CHECK-SAME: attributes {no_signed_zeros_fp_math = true} diff --git a/mlir/test/Target/LLVMIR/Import/function-attributes.ll b/mlir/test/Target/LLVMIR/Import/function-attributes.ll index 0b13645853cea..c0657f6f0903f 100644 --- a/mlir/test/Target/LLVMIR/Import/function-attributes.ll +++ b/mlir/test/Target/LLVMIR/Import/function-attributes.ll @@ -339,18 +339,6 @@ declare void @func_attr_no_nans_fp_math_false() "no-nans-fp-math"="false" ; // ----- -; CHECK-LABEL: @func_attr_approx_func_fp_math_true -; CHECK-SAME: attributes {approx_func_fp_math = true} -declare void @func_attr_approx_func_fp_math_true() "approx-func-fp-math"="true" - -; // ----- - -; CHECK-LABEL: @func_attr_approx_func_fp_math_false -; CHECK-SAME: attributes {approx_func_fp_math = false} -declare void @func_attr_approx_func_fp_math_false() "approx-func-fp-math"="false" - -; // ----- - ; CHECK-LABEL: @func_attr_no_signed_zeros_fp_math_true ; CHECK-SAME: attributes {no_signed_zeros_fp_math = true} declare void @func_attr_no_signed_zeros_fp_math_true() "no-signed-zeros-fp-math"="true" diff --git a/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir b/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir index 673cbd8b87828..7b11fdc6121f6 100644 --- a/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir +++ b/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir @@ -54,24 +54,6 @@ llvm.func @no_nans_fp_math_func_false() attributes {no_nans_fp_math = false} { // ----- -// CHECK-LABEL: define void @approx_func_fp_math_func_true() -// CHECK-SAME: #[[ATTRS:[0-9]+]] -llvm.func @approx_func_fp_math_func_true() attributes {approx_func_fp_math = true} { - llvm.return -} -// CHECK: attributes #[[ATTRS]] = { "approx-func-fp-math"="true" } - -// ----- -// -// CHECK-LABEL: define void @approx_func_fp_math_func_false() -// CHECK-SAME: #[[ATTRS:[0-9]+]] -llvm.func @approx_func_fp_math_func_false() attributes {approx_func_fp_math = false} { - llvm.return -} -// CHECK: attributes #[[ATTRS]] = { "approx-func-fp-math"="false" } - -// ----- - // CHECK-LABEL: define void @no_signed_zeros_fp_math_func_true() // CHECK-SAME: #[[ATTRS:[0-9]+]] llvm.func @no_signed_zeros_fp_math_func_true() attributes {no_signed_zeros_fp_math = true} {