From aa76e9e2cf50af190de90bc778b7f7e42ef9ceff Mon Sep 17 00:00:00 2001 From: Micah Villmow Date: Wed, 24 Oct 2012 15:52:52 +0000 Subject: 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 --- lib/Transforms/Scalar/IndVarSimplify.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp') 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(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(GEPBase->getType())->getElementType())->isOne() + cast(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"); -- cgit v1.2.3