[SCEVExpander] Have hoistIVInc preserve LCSSA
[oota-llvm.git] / lib / Analysis / ScalarEvolutionExpander.cpp
index 8c5805e9d1684a2a05e13ec9c273f1daa3fe2f44..abfcfbafb32e51eb4490e01224c477ccc9dfb469 100644 (file)
@@ -933,6 +933,9 @@ bool SCEVExpander::hoistIVInc(Instruction *IncV, Instruction *InsertPos) {
       !SE.DT.dominates(InsertPos->getParent(), IncV->getParent()))
     return false;
 
+  if (!SE.LI.movementPreservesLCSSAForm(IncV, InsertPos))
+    return false;
+
   // Check that the chain of IV operands leading back to Phi can be hoisted.
   SmallVector<Instruction*, 4> IVIncs;
   for(;;) {