summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2013-10-24 05:29:56 +0000
committerJuergen Ributzka <juergen@apple.com>2013-10-24 05:29:56 +0000
commitd04d096ecfc2e4c82ce77f406b6cdd868941b6eb (patch)
tree39e2844d292603dfb804df0f0f8747692163f18a /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
parent986730303ffd2b77a19a03126a7d43fc1849b855 (diff)
downloadbcm5719-llvm-d04d096ecfc2e4c82ce77f406b6cdd868941b6eb.tar.gz
bcm5719-llvm-d04d096ecfc2e4c82ce77f406b6cdd868941b6eb.zip
Fix a bug in LinearFunctionTestReplace that created invalid loop exit checks.
Reviewed by Andy llvm-svn: 193303
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 7785855d0e1..cfd8db0f6cc 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1479,8 +1479,14 @@ static Value *genLoopLimit(PHINode *IndVar, const SCEV *IVCount, Loop *L,
if (IndVar->getType()->isPointerTy()
&& !IVCount->getType()->isPointerTy()) {
+ // IVOffset will be the new GEP offset that is interpreted by GEP as a
+ // signed value. IVCount on the other hand represents the loop trip count,
+ // which is an unsigned value. FindLoopCounter only allows induction
+ // variables that have a positive unit stride of one. This means we don't
+ // have to handle the case of negative offsets (yet) and just need to zero
+ // extend IVCount.
Type *OfsTy = SE->getEffectiveSCEVType(IVInit->getType());
- const SCEV *IVOffset = SE->getTruncateOrSignExtend(IVCount, OfsTy);
+ const SCEV *IVOffset = SE->getTruncateOrZeroExtend(IVCount, OfsTy);
// Expand the code for the iteration count.
assert(SE->isLoopInvariant(IVOffset, L) &&
OpenPOWER on IntegriCloud