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

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 02:58:53 PDT 2024


jayfoad wrote:

> Since it was breaking the `fsub` test with the `reassoc` flag, I conditionally propagated the `FNegOp` FMF flag.

Personally I think _all_ cases in this function should be copying FMF from `FNegOp`, not from `I`. That is simple, correct (I think!) and useful.

In some cases you might be able to infer additional flags from `I` but that is much more subtle and (I assert!) far less useful. For example copying `nnan` from `I` is probably OK, but in that case it should be ORed into the flags from `FNegOp`.

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


More information about the llvm-commits mailing list