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

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 15:41:25 PST 2016


mgrang added a subscriber: mgrang.

================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:621
@@ -620,1 +620,3 @@
 
+      // fabs(X) * fabs(X) -> X * X
+      if (II->getIntrinsicID() == Intrinsic::fabs) {
----------------
Should this transformation also be guarded under AllowReassociate?

================
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),
----------------
Would it be better to move the checks for the IntrinsicID under a switch-case?

switch (II->getIntrinsicID())


http://reviews.llvm.org/D16696





More information about the llvm-commits mailing list