Skip to content

Commit ea79ea0

Browse files
committed
[CodeGen] Remove most NoNaNsFPMath uses
1 parent dd44e63 commit ea79ea0

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,7 @@ bool llvm::isKnownNeverNaN(Register Val, const MachineRegisterInfo &MRI,
818818
if (!DefMI)
819819
return false;
820820

821-
const TargetMachine& TM = DefMI->getMF()->getTarget();
822-
if (DefMI->getFlag(MachineInstr::FmNoNans) || TM.Options.NoNaNsFPMath)
821+
if (DefMI->getFlag(MachineInstr::FmNoNans))
823822
return true;
824823

825824
// If the value is a constant, we can obviously see if it is a NaN or not.

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17759,7 +17759,6 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
1775917759
bool N1CFP = DAG.isConstantFPBuildVectorOrConstantFP(N1);
1776017760
EVT VT = N->getValueType(0);
1776117761
SDLoc DL(N);
17762-
const TargetOptions &Options = DAG.getTarget().Options;
1776317762
SDNodeFlags Flags = N->getFlags();
1776417763
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1776517764

@@ -17825,7 +17824,7 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
1782517824
bool AllowNewConst = (Level < AfterLegalizeDAG);
1782617825

1782717826
// If nnan is enabled, fold lots of things.
17828-
if ((Options.NoNaNsFPMath || Flags.hasNoNaNs()) && AllowNewConst) {
17827+
if (Flags.hasNoNaNs() && AllowNewConst) {
1782917828
// If allowed, fold (fadd (fneg x), x) -> 0.0
1783017829
if (N0.getOpcode() == ISD::FNEG && N0.getOperand(0) == N1)
1783117830
return DAG.getConstantFP(0.0, DL, VT);
@@ -17974,7 +17973,6 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
1797417973
ConstantFPSDNode *N1CFP = isConstOrConstSplatFP(N1, true);
1797517974
EVT VT = N->getValueType(0);
1797617975
SDLoc DL(N);
17977-
const TargetOptions &Options = DAG.getTarget().Options;
1797817976
const SDNodeFlags Flags = N->getFlags();
1797917977
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1798017978

@@ -18002,7 +18000,7 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
1800218000

1800318001
if (N0 == N1) {
1800418002
// (fsub x, x) -> 0.0
18005-
if (Options.NoNaNsFPMath || Flags.hasNoNaNs())
18003+
if (Flags.hasNoNaNs())
1800618004
return DAG.getConstantFP(0.0f, DL, VT);
1800718005
}
1800818006

@@ -18313,7 +18311,6 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
1831318311
ConstantFPSDNode *N2CFP = dyn_cast<ConstantFPSDNode>(N2);
1831418312
EVT VT = N->getValueType(0);
1831518313
SDLoc DL(N);
18316-
const TargetOptions &Options = DAG.getTarget().Options;
1831718314
// FMA nodes have flags that propagate to the created nodes.
1831818315
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1831918316
MatchContextClass matcher(DAG, TLI, N);
@@ -18339,8 +18336,7 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
1833918336
return matcher.getNode(ISD::FMA, DL, VT, NegN0, NegN1, N2);
1834018337
}
1834118338

18342-
if ((Options.NoNaNsFPMath && N->getFlags().hasNoInfs()) ||
18343-
(N->getFlags().hasNoNaNs() && N->getFlags().hasNoInfs())) {
18339+
if (N->getFlags().hasNoNaNs() && N->getFlags().hasNoInfs()) {
1834418340
if (N->getFlags().hasNoSignedZeros() ||
1834518341
(N2CFP && !N2CFP->isExactlyValue(-0.0))) {
1834618342
if (N0CFP && N0CFP->isZero())

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5877,7 +5877,7 @@ bool SelectionDAG::isKnownNeverNaN(SDValue Op, const APInt &DemandedElts,
58775877
assert(!DemandedElts.isZero() && "No demanded elements");
58785878

58795879
// If we're told that NaNs won't happen, assume they won't.
5880-
if (getTarget().Options.NoNaNsFPMath || Op->getFlags().hasNoNaNs())
5880+
if (Op->getFlags().hasNoNaNs())
58815881
return true;
58825882

58835883
if (Depth >= MaxRecursionDepth)

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ SelectionDAGBuilder::EmitBranchForMergedCondition(const Value *Cond,
24352435
FCmpInst::Predicate Pred =
24362436
InvertCond ? FC->getInversePredicate() : FC->getPredicate();
24372437
Condition = getFCmpCondCode(Pred);
2438-
if (TM.Options.NoNaNsFPMath)
2438+
if (dyn_cast<FPMathOperator>(FC)->hasNoNaNs())
24392439
Condition = getFCmpCodeWithoutNaN(Condition);
24402440
}
24412441

@@ -3711,7 +3711,7 @@ void SelectionDAGBuilder::visitFCmp(const FCmpInst &I) {
37113711

37123712
ISD::CondCode Condition = getFCmpCondCode(predicate);
37133713
auto *FPMO = cast<FPMathOperator>(&I);
3714-
if (FPMO->hasNoNaNs() || TM.Options.NoNaNsFPMath)
3714+
if (FPMO->hasNoNaNs())
37153715
Condition = getFCmpCodeWithoutNaN(Condition);
37163716

37173717
SDNodeFlags Flags;

0 commit comments

Comments
 (0)