[llvm] r325541 - [InstCombine] use CreateWithCopiedFlags to reduce code; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 19 15:09:03 PST 2018
Author: spatel
Date: Mon Feb 19 15:09:03 2018
New Revision: 325541
URL: http://llvm.org/viewvc/llvm-project?rev=325541&view=rev
Log:
[InstCombine] use CreateWithCopiedFlags to reduce code; NFCI
Also, move the folds with constants closer to make it easier to follow.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=325541&r1=325540&r2=325541&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Mon Feb 19 15:09:03 2018
@@ -1313,7 +1313,8 @@ static Instruction *foldFDivConstantDivi
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(Bin
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(Bin
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)))) &&
More information about the llvm-commits
mailing list