[llvm] [InstCombine] Ensure Safe Handling of Flags in foldFNegIntoConstant (PR #94148)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 20:16:18 PST 2024


================
@@ -2742,6 +2742,17 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
   return TryToNarrowDeduceFlags();
 }
 
+static FastMathFlags combineFastMathFlagsForFNeg(FastMathFlags FMF,
----------------
SahilPatidar wrote:

Can we try this approach in `FMF`?
```cpp
    FastMathFlags Result = this->Flags & Other.Flags;
    Result.setNoNaNs(this->noNaNs() || Other.noNaNs());
    Result.setNoSignedZeros(this->noSignedZeros() || Other.noSignedZeros());
    return Result;
```

https://github.com/llvm/llvm-project/pull/94148


More information about the llvm-commits mailing list