[llvm] r364693 - [IndVars] Remove a bit of manual constant folding [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 17:19:31 PDT 2019


Author: reames
Date: Fri Jun 28 17:19:31 2019
New Revision: 364693

URL: http://llvm.org/viewvc/llvm-project?rev=364693&view=rev
Log:
[IndVars] Remove a bit of manual constant folding [NFC]

SCEV is more than capable of folding (add x, trunc(0)) to x.  


Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=364693&r1=364692&r2=364693&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Jun 28 17:19:31 2019
@@ -2353,21 +2353,16 @@ static Value *genLoopLimit(PHINode *IndV
     // were generated on top of case #2, which is not expected.
 
     assert(AR->getStepRecurrence(*SE)->isOne() && "only handles unit stride");
-    const SCEV *IVLimit = nullptr;
     // For unit stride, IVCount = Start + BECount with 2's complement overflow.
-    // For non-zero Start, compute IVCount here.
-    if (AR->getStart()->isZero())
-      IVLimit = IVCount;
-    else {
-      const SCEV *IVInit = AR->getStart();
+    const SCEV *IVInit = AR->getStart();
 
-      // For integer IVs, truncate the IV before computing IVInit + BECount.
-      if (SE->getTypeSizeInBits(IVInit->getType())
-          > SE->getTypeSizeInBits(IVCount->getType()))
-        IVInit = SE->getTruncateExpr(IVInit, IVCount->getType());
+    // For integer IVs, truncate the IV before computing IVInit + BECount.
+    if (SE->getTypeSizeInBits(IVInit->getType())
+        > SE->getTypeSizeInBits(IVCount->getType()))
+      IVInit = SE->getTruncateExpr(IVInit, IVCount->getType());
 
-      IVLimit = SE->getAddExpr(IVInit, IVCount);
-    }
+    const SCEV *IVLimit = SE->getAddExpr(IVInit, IVCount);
+    
     // Expand the code for the iteration count.
     BranchInst *BI = cast<BranchInst>(ExitingBB->getTerminator());
     IRBuilder<> Builder(BI);




More information about the llvm-commits mailing list