summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp56
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h2
2 files changed, 22 insertions, 36 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index c88a89c3ed1..ee17fb94495 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2739,46 +2739,32 @@ static bool isVectorReductionOp(const User *I) {
return ReduxExtracted;
}
-void SelectionDAGBuilder::visitBinary(const User &I, unsigned OpCode) {
- SDValue Op1 = getValue(I.getOperand(0));
- SDValue Op2 = getValue(I.getOperand(1));
-
- bool nuw = false;
- bool nsw = false;
- bool exact = false;
- bool vec_redux = false;
- FastMathFlags FMF;
-
- if (const OverflowingBinaryOperator *OFBinOp =
- dyn_cast<const OverflowingBinaryOperator>(&I)) {
- nuw = OFBinOp->hasNoUnsignedWrap();
- nsw = OFBinOp->hasNoSignedWrap();
+void SelectionDAGBuilder::visitBinary(const User &I, unsigned Opcode) {
+ SDNodeFlags Flags;
+ if (auto *OFBinOp = dyn_cast<OverflowingBinaryOperator>(&I)) {
+ Flags.setNoSignedWrap(OFBinOp->hasNoSignedWrap());
+ Flags.setNoUnsignedWrap(OFBinOp->hasNoUnsignedWrap());
+ }
+ if (auto *ExactOp = dyn_cast<PossiblyExactOperator>(&I)) {
+ Flags.setExact(ExactOp->isExact());
}
- if (const PossiblyExactOperator *ExactOp =
- dyn_cast<const PossiblyExactOperator>(&I))
- exact = ExactOp->isExact();
- if (const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(&I))
- FMF = FPOp->getFastMathFlags();
-
if (isVectorReductionOp(&I)) {
- vec_redux = true;
+ Flags.setVectorReduction(true);
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());
+ }
- SDNodeFlags Flags;
- Flags.setExact(exact);
- Flags.setNoSignedWrap(nsw);
- Flags.setNoUnsignedWrap(nuw);
- Flags.setVectorReduction(vec_redux);
- Flags.setAllowReciprocal(FMF.allowReciprocal());
- Flags.setAllowContract(FMF.allowContract());
- Flags.setNoInfs(FMF.noInfs());
- Flags.setNoNaNs(FMF.noNaNs());
- Flags.setNoSignedZeros(FMF.noSignedZeros());
- Flags.setApproximateFuncs(FMF.approxFunc());
- Flags.setAllowReassociation(FMF.allowReassoc());
-
- SDValue BinNodeValue = DAG.getNode(OpCode, getCurSDLoc(), Op1.getValueType(),
+ SDValue Op1 = getValue(I.getOperand(0));
+ SDValue Op2 = getValue(I.getOperand(1));
+ SDValue BinNodeValue = DAG.getNode(Opcode, getCurSDLoc(), Op1.getValueType(),
Op1, Op2, Flags);
setValue(&I, BinNodeValue);
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index 780cd3e250a..bcea94ec5a4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -847,7 +847,7 @@ private:
void visitInvoke(const InvokeInst &I);
void visitResume(const ResumeInst &I);
- void visitBinary(const User &I, unsigned OpCode);
+ void visitBinary(const User &I, unsigned Opcode);
void visitShift(const User &I, unsigned Opcode);
void visitAdd(const User &I) { visitBinary(I, ISD::ADD); }
void visitFAdd(const User &I) { visitBinary(I, ISD::FADD); }
OpenPOWER on IntegriCloud