Another speculative commit to try to fix Polly's build. This is more delta than
authorChandler Carruth <chandlerc@gmail.com>
Thu, 25 Oct 2012 08:43:18 +0000 (08:43 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 25 Oct 2012 08:43:18 +0000 (08:43 +0000)
I like to make w/o being able to build, but I don't have the dependencies to
build and test polly. I'll revert if the build bots don't like it.

llvm-svn: 166670

polly/lib/IndVarSimplify.cpp

index d52016806967b71f23738d1610949b712ec86f70..7a42ddb33ccf173def7455623dedde20b9ecf196 100644 (file)
@@ -1530,7 +1530,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,
+                           const DataLayout *TD) {
   const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(IndVar));
   assert(AR && AR->getLoop() == L && AR->isAffine() && "bad loop counter");
   const SCEV *IVInit = AR->getStart();
@@ -1555,9 +1556,11 @@ static Value *genLoopLimit(PHINode *IndVar, const SCEV *IVCount, Loop *L,
     assert(AR->getStart() == SE->getSCEV(GEPBase) && "bad loop counter");
     // 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()
-           && "unit stride pointer IV must be i8*");
+    if (TD)
+      assert(SE->getSizeOfExpr(
+               cast<PointerType>(GEPBase->getType())->getElementType(),
+               TD->getIntPtrType(GEPBase->getType()))->isOne()
+             && "unit stride pointer IV must be i8*");
 
     IRBuilder<> Builder(L->getLoopPreheader()->getTerminator());
     return Builder.CreateGEP(GEPBase, GEPOffset, "lftr.limit");
@@ -1656,7 +1659,7 @@ LinearFunctionTestReplace(Loop *L,
     CmpIndVar = IndVar;
   }
 
-  Value *ExitCnt = genLoopLimit(IndVar, IVCount, L, Rewriter, SE);
+  Value *ExitCnt = genLoopLimit(IndVar, IVCount, L, Rewriter, SE, TD);
   assert(ExitCnt->getType()->isPointerTy() == IndVar->getType()->isPointerTy()
          && "genLoopLimit missed a cast");