summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-06-29 00:19:31 +0000
committerPhilip Reames <listmail@philipreames.com>2019-06-29 00:19:31 +0000
commit1504b6ee7ea0f146dfaafaddc1125d01939a617f (patch)
tree333741de7c9f69caa8aea5f656452fb0c73c802a /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
parentda47e2cac3812802ccd97127084464ac8d4710db (diff)
downloadbcm5719-llvm-1504b6ee7ea0f146dfaafaddc1125d01939a617f.tar.gz
bcm5719-llvm-1504b6ee7ea0f146dfaafaddc1125d01939a617f.zip
[IndVars] Remove a bit of manual constant folding [NFC]
SCEV is more than capable of folding (add x, trunc(0)) to x. llvm-svn: 364693
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index eb09e7883b9..f3352a3d5b4 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2353,21 +2353,16 @@ static Value *genLoopLimit(PHINode *IndVar, BasicBlock *ExitingBB,
// 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);
OpenPOWER on IntegriCloud