[PATCH] D151934: InstCombine: Recognize fneg when performed as bitcasted integer

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 10:42:37 PDT 2023


arsenm added a comment.

In D151934#4411516 <https://reviews.llvm.org/D151934#4411516>, @efriedma wrote:

>> You can't really do anything unsafe with an fneg on its own, it has to be connected to something where the unsafe flag already applied.
>
> If the fneg is the only use of an unsafe floating-point operation, there isn't really any way to observe whether the fneg itself is safe or unsafe.  But we could produce contradictory results if the operand has multiple uses.  For example, it's normally safe to assume `x ^ 0x80000000 != x`.  But if fneg is treated as an unsafe math operation, there are some situations where `fneg(x) == x`.  This could lead to a miscompile, at least in theory. Not sure how likely it is for anyone to trip over that in practice.

I think you have no right to complain once your code touches fast math code. It's not a miscompile if you permitted it. The sign bit changing would have to originate from the fast math imbued instruction


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151934/new/

https://reviews.llvm.org/D151934



More information about the llvm-commits mailing list