Skip to content

Commit 1f99c15

Browse files
committed
[IR][CodeGen] Remove unsafe-fp-math attribute support
1 parent 34cf8bb commit 1f99c15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+89
-199
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,6 @@ static bool initTargetOptions(const CompilerInstance &CI,
430430
Options.NoInfsFPMath = LangOpts.NoHonorInfs;
431431
Options.NoNaNsFPMath = LangOpts.NoHonorNaNs;
432432
Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
433-
Options.UnsafeFPMath = LangOpts.AllowFPReassoc && LangOpts.AllowRecip &&
434-
LangOpts.NoSignedZero && LangOpts.ApproxFunc &&
435-
(LangOpts.getDefaultFPContractMode() ==
436-
LangOptions::FPModeKind::FPM_Fast ||
437-
LangOpts.getDefaultFPContractMode() ==
438-
LangOptions::FPModeKind::FPM_FastHonorPragmas);
439433

440434
Options.BBAddrMap = CodeGenOpts.BBAddrMap;
441435
Options.BBSections =

llvm/docs/CommandGuide/llc.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,6 @@ End-user Options
125125

126126
Enable setting the FP exceptions build attribute not to use exceptions.
127127

128-
.. option:: --enable-unsafe-fp-math
129-
130-
Enable optimizations that make unsafe assumptions about IEEE math (e.g. that
131-
addition is associative) or may not work for all input ranges. These
132-
optimizations allow the code generator to make use of some instructions which
133-
would otherwise not be usable (such as ``fsin`` on X86).
134-
135128
.. option:: --stats
136129

137130
Print statistics recorded by code-generation passes.

llvm/docs/CommandGuide/lli.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ FLOATING POINT OPTIONS
107107

108108
Enable optimizations that assume no NAN values.
109109

110-
.. option:: -enable-unsafe-fp-math
111-
112-
Causes :program:`lli` to enable optimizations that may decrease floating point
113-
precision.
114-
115110
.. option:: -soft-float
116111

117112
Causes :program:`lli` to generate software floating point library calls instead of

llvm/include/llvm/CodeGen/CommandFlags.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ LLVM_ABI CodeGenFileType getFileType();
5858

5959
LLVM_ABI FramePointerKind getFramePointerUsage();
6060

61-
LLVM_ABI bool getEnableUnsafeFPMath();
62-
6361
LLVM_ABI bool getEnableNoInfsFPMath();
6462

6563
LLVM_ABI bool getEnableNoNaNsFPMath();

llvm/include/llvm/IR/Attributes.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
410410
def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
411411
def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
412412
def NoSignedZerosFPMath : StrBoolAttr<"no-signed-zeros-fp-math">;
413-
def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
414413
def NoJumpTables : StrBoolAttr<"no-jump-tables">;
415414
def NoInlineLineTables : StrBoolAttr<"no-inline-line-tables">;
416415
def ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">;
@@ -474,7 +473,6 @@ def : MergeRule<"setAND<LessPreciseFPMADAttr>">;
474473
def : MergeRule<"setAND<NoInfsFPMathAttr>">;
475474
def : MergeRule<"setAND<NoNansFPMathAttr>">;
476475
def : MergeRule<"setAND<NoSignedZerosFPMathAttr>">;
477-
def : MergeRule<"setAND<UnsafeFPMathAttr>">;
478476
def : MergeRule<"setOR<NoImplicitFloatAttr>">;
479477
def : MergeRule<"setOR<NoJumpTablesAttr>">;
480478
def : MergeRule<"setOR<ProfileSampleAccurateAttr>">;

llvm/include/llvm/Target/TargetOptions.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ enum CodeObjectVersionKind {
118118
class TargetOptions {
119119
public:
120120
TargetOptions()
121-
: UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
122-
NoTrappingFPMath(true), NoSignedZerosFPMath(false),
123-
EnableAIXExtendedAltivecABI(false),
121+
: NoInfsFPMath(false), NoNaNsFPMath(false), NoTrappingFPMath(true),
122+
NoSignedZerosFPMath(false), EnableAIXExtendedAltivecABI(false),
124123
HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
125124
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
126125
EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
@@ -156,13 +155,6 @@ class TargetOptions {
156155
/// MCAsmInfo::BinutilsVersion.
157156
std::pair<int, int> BinutilsVersion{0, 0};
158157

159-
/// UnsafeFPMath - This flag is enabled when the
160-
/// -enable-unsafe-fp-math flag is specified on the command line. When
161-
/// this flag is off (the default), the code generator is not allowed to
162-
/// produce results that are "less precise" than IEEE allows. This includes
163-
/// use of X86 instructions like FSIN and FCOS instead of libcalls.
164-
unsigned UnsafeFPMath : 1;
165-
166158
/// NoInfsFPMath - This flag is enabled when the
167159
/// -enable-no-infs-fp-math flag is specified on the command line. When
168160
/// this flag is off (the default), the code generator is not allowed to

llvm/lib/CodeGen/CommandFlags.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ CGOPT_EXP(uint64_t, LargeDataThreshold)
6464
CGOPT(ExceptionHandling, ExceptionModel)
6565
CGOPT_EXP(CodeGenFileType, FileType)
6666
CGOPT(FramePointerKind, FramePointerUsage)
67-
CGOPT(bool, EnableUnsafeFPMath)
6867
CGOPT(bool, EnableNoInfsFPMath)
6968
CGOPT(bool, EnableNoNaNsFPMath)
7069
CGOPT(bool, EnableNoSignedZerosFPMath)
@@ -219,12 +218,6 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
219218
"Enable frame pointer elimination")));
220219
CGBINDOPT(FramePointerUsage);
221220

222-
static cl::opt<bool> EnableUnsafeFPMath(
223-
"enable-unsafe-fp-math",
224-
cl::desc("Enable optimizations that may decrease FP precision"),
225-
cl::init(false));
226-
CGBINDOPT(EnableUnsafeFPMath);
227-
228221
static cl::opt<bool> EnableNoInfsFPMath(
229222
"enable-no-infs-fp-math",
230223
cl::desc("Enable FP math optimizations that assume no +-Infs"),
@@ -552,7 +545,6 @@ TargetOptions
552545
codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) {
553546
TargetOptions Options;
554547
Options.AllowFPOpFusion = getFuseFPOps();
555-
Options.UnsafeFPMath = getEnableUnsafeFPMath();
556548
Options.NoInfsFPMath = getEnableNoInfsFPMath();
557549
Options.NoNaNsFPMath = getEnableNoNaNsFPMath();
558550
Options.NoSignedZerosFPMath = getEnableNoSignedZerosFPMath();
@@ -706,7 +698,6 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features,
706698
if (getStackRealign())
707699
NewAttrs.addAttribute("stackrealign");
708700

709-
HANDLE_BOOL_ATTR(EnableUnsafeFPMathView, "unsafe-fp-math");
710701
HANDLE_BOOL_ATTR(EnableNoInfsFPMathView, "no-infs-fp-math");
711702
HANDLE_BOOL_ATTR(EnableNoNaNsFPMathView, "no-nans-fp-math");
712703
HANDLE_BOOL_ATTR(EnableNoSignedZerosFPMathView, "no-signed-zeros-fp-math");

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17462,9 +17462,9 @@ SDValue DAGCombiner::visitFSUBForFMACombine(SDNode *N) {
1746217462
// fold (fsub (fpext (fneg (fmul, x, y))), z)
1746317463
// -> (fneg (fma (fpext x), (fpext y), z))
1746417464
// Note: This could be removed with appropriate canonicalization of the
17465-
// input expression into (fneg (fadd (fpext (fmul, x, y)), z). However, the
17466-
// orthogonal flags -fp-contract=fast and -enable-unsafe-fp-math prevent
17467-
// from implementing the canonicalization in visitFSUB.
17465+
// input expression into (fneg (fadd (fpext (fmul, x, y)), z). However,
17466+
// -fp-contract=fast prevent from implementing the canonicalization
17467+
// in visitFSUB.
1746817468
if (matcher.match(N0, ISD::FP_EXTEND)) {
1746917469
SDValue N00 = N0.getOperand(0);
1747017470
if (matcher.match(N00, ISD::FNEG)) {
@@ -17486,9 +17486,9 @@ SDValue DAGCombiner::visitFSUBForFMACombine(SDNode *N) {
1748617486
// fold (fsub (fneg (fpext (fmul, x, y))), z)
1748717487
// -> (fneg (fma (fpext x)), (fpext y), z)
1748817488
// Note: This could be removed with appropriate canonicalization of the
17489-
// input expression into (fneg (fadd (fpext (fmul, x, y)), z). However, the
17490-
// orthogonal flags -fp-contract=fast and -enable-unsafe-fp-math prevent
17491-
// from implementing the canonicalization in visitFSUB.
17489+
// input expression into (fneg (fadd (fpext (fmul, x, y)), z). However,
17490+
// -fp-contract=fast prevent from implementing the canonicalization
17491+
// in visitFSUB.
1749217492
if (matcher.match(N0, ISD::FNEG)) {
1749317493
SDValue N00 = N0.getOperand(0);
1749417494
if (matcher.match(N00, ISD::FP_EXTEND)) {

llvm/lib/CodeGen/TargetOptionsImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bool TargetOptions::FramePointerIsReserved(const MachineFunction &MF) const {
5151
/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
5252
/// that the rounding mode of the FPU can change from its default.
5353
bool TargetOptions::HonorSignDependentRoundingFPMath() const {
54-
return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
54+
return HonorSignDependentRoundingFPMathOption;
5555
}
5656

5757
/// NOTE: There are targets that still do not support the debug entry values

llvm/lib/Target/TargetMachine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ void TargetMachine::resetTargetOptions(const Function &F) const {
158158
Options.X = F.getFnAttribute(Y).getValueAsBool(); \
159159
} while (0)
160160

161-
RESET_OPTION(UnsafeFPMath, "unsafe-fp-math");
162161
RESET_OPTION(NoInfsFPMath, "no-infs-fp-math");
163162
RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math");
164163
RESET_OPTION(NoSignedZerosFPMath, "no-signed-zeros-fp-math");

0 commit comments

Comments
 (0)