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.
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))
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)))) &&