[PATCH] D139785: [InstCombine] preserve signbit semantics of NAN with fold to fabs

Ralf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 11 08:52:44 PST 2022


RalfJung added a comment.

I am a bit confused by the explanation. The signbit of NaN is "insignificant" for operations like `+` in the sense that they just pick an arbitrary sign bit if the result is NaN (and so the sign bit of a NaN input has no effect). But it affects the behavior of `>`, `fneg`, and `fabs` (the operations involved here) in totally deterministic ways, right? When only `>`, `fneg`, `fabs` are used (and copies of the floating point value from one register to another), the sign bit is fully significant, like all the others.

The actual issue is that `X > 0.0` is `false` for negative NaNs, so the LHS returns `X` in that case -- meaning the LHS can sometimes return a value with the sign bit set, but the RHS will never have the sign bit set. Hence the transformation is wrong. This has nothing to do with sign bits being insignificant or so though?


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

https://reviews.llvm.org/D139785



More information about the llvm-commits mailing list