Increment iterator now because IVUseShouldUsePostIncValue may remove
authorDevang Patel <dpatel@apple.com>
Fri, 9 Mar 2007 21:19:53 +0000 (21:19 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 9 Mar 2007 21:19:53 +0000 (21:19 +0000)
User from the list of I users.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35051 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index fcbf9e301cfee558d32bb7a67afafd4d23f3fc01..ec3fed2f1babd2245c5dca847141a70a93363e61 100644 (file)
@@ -400,10 +400,14 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
   SCEVHandle Stride = Start;
   if (!getSCEVStartAndStride(ISE, L, Start, Stride))
     return false;  // Non-reducible symbolic expression, bail out.
-  
-  for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;++UI){
+
+  for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;{
     Instruction *User = cast<Instruction>(*UI);
 
+    // Increment iterator now because IVUseShouldUsePostIncValue may remove 
+    // User from the list of I users.
+    ++UI;
+
     // Do not infinitely recurse on PHI nodes.
     if (isa<PHINode>(User) && Processed.count(User))
       continue;