[PATCH] D16696: InstCombine: fabs(x) * fabs(x) -> x * x

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 15:44:53 PST 2016


arsenm 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) {
----------------
I'm pretty sure this is always safe

================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:622
@@ +621,3 @@
+      // fabs(X) * fabs(X) -> X * X
+      if (II->getIntrinsicID() == Intrinsic::fabs) {
+        Instruction *FMulVal = BinaryOperator::CreateFMul(II->getOperand(0),
----------------
Maybe, but since there are only two and sqrt has an additional condition, the switch would probably be longer


http://reviews.llvm.org/D16696





More information about the llvm-commits mailing list