diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-05-11 23:13:36 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-05-11 23:13:36 +0000 |
commit | fe645d295fab5f7b86db39f43b3e2a6269a9a6c0 (patch) | |
tree | 09182927e88a97f1121d46ce93c66ebb4abdb371 | |
parent | 655fdd3f82fc2c25eccd921755708deed0a02405 (diff) | |
download | bcm5719-llvm-fe645d295fab5f7b86db39f43b3e2a6269a9a6c0.tar.gz bcm5719-llvm-fe645d295fab5f7b86db39f43b3e2a6269a9a6c0.zip |
[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.
llvm-svn: 332155
-rw-r--r-- | llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 15 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 8 |
2 files changed, 15 insertions, 8 deletions
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index f9dd35745ab..b1f8b8c02ba 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -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; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index ee17fb94495..57eadbb4410 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2753,13 +2753,7 @@ void SelectionDAGBuilder::visitBinary(const User &I, unsigned Opcode) { 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)); |