aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index fcbf9e301c..ec3fed2f1b 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -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;