[llvm] [InstCombine] Ensure Safe Handling of Flags in foldFNegIntoConstant (PR #94148)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 23:47:23 PDT 2024
================
@@ -2653,8 +2653,15 @@ static Instruction *foldFNegIntoConstant(Instruction &I, const DataLayout &DL) {
// Fold negation into constant operand.
// -(X * C) --> X * (-C)
if (match(FNegOp, m_FMul(m_Value(X), m_Constant(C))))
- if (Constant *NegC = ConstantFoldUnaryOpOperand(Instruction::FNeg, C, DL))
+ if (Constant *NegC = ConstantFoldUnaryOpOperand(Instruction::FNeg, C, DL)) {
+ if (match(C, m_AnyZeroFP()) && I.getFastMathFlags().noInfs()) {
+ return BinaryOperator::CreateFMulFMF(
+ X, NegC,
+ I.getFastMathFlags() &
+ cast<FPMathOperator>(I.getOperand(0))->getFastMathFlags());
----------------
SahilPatidar wrote:
Yeah, you're right. I was just making combinations, so is that what you're looking for?
https://github.com/llvm/llvm-project/pull/94148
More information about the llvm-commits
mailing list