[PATCH] D37989: InstCombine: Insert missing canonicalizes
Steve Canon via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 11:23:15 PST 2017
scanon added a comment.
In https://reviews.llvm.org/D37989#936369, @escha wrote:
> In https://reviews.llvm.org/D37989#936337, @scanon wrote:
>
> > IEEE 754 rules are that everything canonicalizes except bitwise operations (copy, abs, negate, copysign) and decimal re-encoding operations (which you don't care about).
>
>
> Does this mean that we need to make all other float optimizations in LLVM do the same?
>
> for example, we cannot optimize fmul(x, 1) to x, we must optimize it to fcanonicalize(x), right? thus preventing pretty much all float optimizations, since presumably that will act as a barrier.
Well, so far we're saved by the fact that there are no non-canonical floats or doubles in IEEE 754 (platforms that treat denorms as non-canonical zeros are already outside IEEE 754, so do whatever you like). Non-canonical encodings *do* exist for float80, but they canonicalize if you look at them funny, so it hasn't been a problem.
If we want to get this really formally right at some point, then yes, fmul(x,1) would become fcanonicalize(x), which would usually be consumed into whatever consumes the result of the multiply, because everything except the aforementioned functions is described in terms of canonicalized inputs.
https://reviews.llvm.org/D37989
More information about the llvm-commits
mailing list