diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-02-19 23:09:03 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-02-19 23:09:03 +0000 |
commit | 2816560b2c2c05c78c00a1df5849566ff093bb86 (patch) | |
tree | bd2fee6aff48fd9958e32c065aeab69d2d2b3b9f /llvm/lib/Transforms | |
parent | 2e8a8629d6096a2333d76d089646651772baf769 (diff) | |
download | bcm5719-llvm-2816560b2c2c05c78c00a1df5849566ff093bb86.tar.gz bcm5719-llvm-2816560b2c2c05c78c00a1df5849566ff093bb86.zip |
[InstCombine] use CreateWithCopiedFlags to reduce code; NFCI
Also, move the folds with constants closer to make it easier to follow.
llvm-svn: 325541
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 9df0d4673b8..6d0b9ac9c62 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -1313,7 +1313,8 @@ static Instruction *foldFDivConstantDivisor(BinaryOperator &FDiv) { return nullptr; auto *RecipCFP = ConstantFP::get(FDiv.getType(), Reciprocal); - return BinaryOperator::CreateFMul(FDiv.getOperand(0), RecipCFP); + return BinaryOperator::CreateWithCopiedFlags(Instruction::FMul, RecipCFP, + FDiv.getOperand(0), &FDiv); } /// Try to reassociate C / X expressions where X includes another constant. @@ -1352,10 +1353,11 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) { SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); - if (Instruction *FMul = foldFDivConstantDivisor(I)) { - FMul->copyFastMathFlags(&I); + if (Instruction *FMul = foldFDivConstantDivisor(I)) return FMul; - } + + if (Instruction *NewFDiv = foldFDivConstantDividend(I)) + return NewFDiv; if (isa<Constant>(Op0)) if (SelectInst *SI = dyn_cast<SelectInst>(Op1)) @@ -1394,9 +1396,6 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) { return nullptr; } - if (Instruction *NewFDiv = foldFDivConstantDividend(I)) - return NewFDiv; - if (AllowReassociate) { Value *X, *Y; if (match(Op0, m_OneUse(m_FDiv(m_Value(X), m_Value(Y)))) && |