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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 15:15:17 PDT 2023


efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

> 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

The point here is that there should be a boundary between fast and non-fast instructions: if you have a "fast" algorithm, you should be able to use its output in non-"fast" code without infecting it.

But I think it only ends up being an issue with the function-wide flag, not the per-instruction flags, so anyone who cares about that can just avoid setting that bit.

> imo should require a cast back to float. If we are keeping it as an integer, I think xor is more recognizable/canonical.

fneg seems more likely to actually correspond to a natively supported instruction, and more likely to be combined with adjacent operations.


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

https://reviews.llvm.org/D151934



More information about the llvm-commits mailing list