diff options
author | Micah Villmow <villmow@gmail.com> | 2012-10-24 15:52:52 +0000 |
---|---|---|
committer | Micah Villmow <villmow@gmail.com> | 2012-10-24 15:52:52 +0000 |
commit | aa76e9e2cf50af190de90bc778b7f7e42ef9ceff (patch) | |
tree | 5206b0fb0ac695e3ab1c9cf434b5a85195abf336 /lib/Transforms/Scalar/IndVarSimplify.cpp | |
parent | 3575222175b4982f380ff291bb17be67aadc0966 (diff) |
Add in support for getIntPtrType to get the pointer type based on the address space.
This checkin also adds in some tests that utilize these paths and updates some of the
clients.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 82eb746467..8a2f093629 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -1430,7 +1430,8 @@ FindLoopCounter(Loop *L, const SCEV *BECount, /// genLoopLimit - Help LinearFunctionTestReplace by generating a value that /// holds the RHS of the new loop test. static Value *genLoopLimit(PHINode *IndVar, const SCEV *IVCount, Loop *L, - SCEVExpander &Rewriter, ScalarEvolution *SE) { + SCEVExpander &Rewriter, ScalarEvolution *SE, + Type *IntPtrTy) { const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(IndVar)); assert(AR && AR->getLoop() == L && AR->isAffine() && "bad loop counter"); const SCEV *IVInit = AR->getStart(); @@ -1456,7 +1457,8 @@ static Value *genLoopLimit(PHINode *IndVar, const SCEV *IVCount, Loop *L, // We could handle pointer IVs other than i8*, but we need to compensate for // gep index scaling. See canExpandBackedgeTakenCount comments. assert(SE->getSizeOfExpr( - cast<PointerType>(GEPBase->getType())->getElementType())->isOne() + cast<PointerType>(GEPBase->getType())->getElementType(), + IntPtrTy)->isOne() && "unit stride pointer IV must be i8*"); IRBuilder<> Builder(L->getLoopPreheader()->getTerminator()); @@ -1555,7 +1557,9 @@ LinearFunctionTestReplace(Loop *L, CmpIndVar = IndVar; } - Value *ExitCnt = genLoopLimit(IndVar, IVCount, L, Rewriter, SE); + Type *IntPtrTy = TD ? TD->getIntPtrType(IndVar->getType()) : + IntegerType::getInt64Ty(IndVar->getContext()); + Value *ExitCnt = genLoopLimit(IndVar, IVCount, L, Rewriter, SE, IntPtrTy); assert(ExitCnt->getType()->isPointerTy() == IndVar->getType()->isPointerTy() && "genLoopLimit missed a cast"); |