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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 10 13:17:52 PDT 2023


efriedma added a comment.

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


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

https://reviews.llvm.org/D151934



More information about the llvm-commits mailing list