[llvm] r332155 - [DAG] add convenience function to propagate FMF; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri May 11 16:13:36 PDT 2018
Author: spatel
Date: Fri May 11 16:13:36 2018
New Revision: 332155
URL: http://llvm.org/viewvc/llvm-project?rev=332155&view=rev
Log:
[DAG] add convenience function to propagate FMF; NFC
There's only one use of this currently, but that could
change with D46563. Either way, we shouldn't have to
update code outside of the flags struct when those
flag definitions change.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=332155&r1=332154&r2=332155&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri May 11 16:13:36 2018
@@ -37,6 +37,7 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Operator.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
@@ -374,7 +375,19 @@ public:
: AnyDefined(false), NoUnsignedWrap(false), NoSignedWrap(false),
Exact(false), NoNaNs(false), NoInfs(false),
NoSignedZeros(false), AllowReciprocal(false), VectorReduction(false),
- AllowContract(false), ApproximateFuncs(false), AllowReassociation(false) {}
+ AllowContract(false), ApproximateFuncs(false),
+ AllowReassociation(false) {}
+
+ /// Propagate the fast-math-flags from an IR FPMathOperator.
+ void copyFMF(const FPMathOperator &FPMO) {
+ setNoNaNs(FPMO.hasNoNaNs());
+ setNoInfs(FPMO.hasNoInfs());
+ setNoSignedZeros(FPMO.hasNoSignedZeros());
+ setAllowReciprocal(FPMO.hasAllowReciprocal());
+ setAllowContract(FPMO.hasAllowContract());
+ setApproximateFuncs(FPMO.hasApproxFunc());
+ setAllowReassociation(FPMO.hasAllowReassoc());
+ }
/// Sets the state of the flags to the defined state.
void setDefined() { AnyDefined = true; }
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=332155&r1=332154&r2=332155&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri May 11 16:13:36 2018
@@ -2753,13 +2753,7 @@ void SelectionDAGBuilder::visitBinary(co
DEBUG(dbgs() << "Detected a reduction operation:" << I << "\n");
}
if (auto *FPOp = dyn_cast<FPMathOperator>(&I)) {
- Flags.setAllowReciprocal(FPOp->hasAllowReciprocal());
- Flags.setAllowContract(FPOp->hasAllowContract());
- Flags.setNoInfs(FPOp->hasNoInfs());
- Flags.setNoNaNs(FPOp->hasNoNaNs());
- Flags.setNoSignedZeros(FPOp->hasNoSignedZeros());
- Flags.setApproximateFuncs(FPOp->hasApproxFunc());
- Flags.setAllowReassociation(FPOp->hasAllowReassoc());
+ Flags.copyFMF(*FPOp);
}
SDValue Op1 = getValue(I.getOperand(0));
More information about the llvm-commits
mailing list