[llvm] r326330 - [InstCombine] move invariant call out of loop; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 08:50:51 PST 2018


Author: spatel
Date: Wed Feb 28 08:50:51 2018
New Revision: 326330

URL: http://llvm.org/viewvc/llvm-project?rev=326330&view=rev
Log:
[InstCombine] move invariant call out of loop; NFC

We really shouldn't need a 2-loop here at all, but that's another cleanup.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=326330&r1=326329&r2=326330&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Wed Feb 28 08:50:51 2018
@@ -669,14 +669,14 @@ Instruction *InstCombiner::visitFMul(Bin
   if (match(Op1, m_OneUse(m_FNeg(m_Value(X)))))
     return BinaryOperator::CreateFNegFMF(Builder.CreateFMulFMF(X, Op0, &I), &I);
 
+  // (select A, B, C) * (select A, D, E) --> select A, (B*D), (C*E)
+  if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1))
+    return replaceInstUsesWith(I, V);
+
   // Handle symmetric situation in a 2-iteration loop
   Value *Opnd0 = Op0;
   Value *Opnd1 = Op1;
   for (int i = 0; i < 2; i++) {
-    // Handle specials cases for FMul with selects feeding the operation
-    if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1))
-      return replaceInstUsesWith(I, V);
-
     // (X*Y) * X => (X*X) * Y where Y != X
     //  The purpose is two-fold:
     //   1) to form a power expression (of X).




More information about the llvm-commits mailing list