Non-affine post-inc SCEV expansions have more code which must be
[oota-llvm.git] / lib / Analysis / ScalarEvolutionExpander.cpp
index 9aa8bfbdb17a37d662db318c6eb5b7d19cef0b80..b6c7ce64481f6bbb053d29840fc3a9f642e688d1 100644 (file)
@@ -1087,7 +1087,7 @@ Value *SCEVExpander::expand(const SCEV *S) {
       // If the SCEV is computable at this level, insert it into the header
       // after the PHIs (and after any other instructions that we've inserted
       // there) so that it is guaranteed to dominate any user inside the loop.
-      if (L && S->hasComputableLoopEvolution(L))
+      if (L && S->hasComputableLoopEvolution(L) && L != PostIncLoop)
         InsertPt = L->getHeader()->getFirstNonPHI();
       while (isInsertedInstruction(InsertPt))
         InsertPt = llvm::next(BasicBlock::iterator(InsertPt));