[PATCH] D16696: InstCombine: fabs(x) * fabs(x) -> x * x
David Kreitzer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 13:36:21 PST 2016
DavidKreitzer added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:621
@@ -620,1 +620,3 @@
+ // fabs(X) * fabs(X) -> X * X
+ if (II->getIntrinsicID() == Intrinsic::fabs) {
----------------
arsenm wrote:
> I'm pretty sure this is always safe
If X is -NaN, this transform will change the result of fabs(X) * fabs(X) from +NaN to -NaN. (In all other cases, it will produce the same result.)
So my recommendation is to guard this transformation by I.hasNoNaNs().
http://reviews.llvm.org/D16696
More information about the llvm-commits
mailing list