[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 11:13:53 PST 2022


RalfJung added a comment.

Note that semantics of fneg/fabs is irrelevant for this optimization to be a problem. That's why I keep using  `float Y = true ? X1 : X2;` as the example. To my knowledge nobody disputes that `NaN < 0.0` should return false, so `X < 0.0 ? -X : X` will behave the same as `false ? -X : X` when `X` is a NAN, which is the same as just `X` -- I hope this much is uncontroversial. The only potential question then is whether `float Y = X` must preserve the NAN sign bit of `X`.

I personally would be extremely surprised if just coping a value was allowed to alter any of its bits. Is that the alternative NAN semantics you meant, or am I misunderstanding something?


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

https://reviews.llvm.org/D139785



More information about the llvm-commits mailing list