Remove indeterminism from a loop. We think this will
authorDale Johannesen <dalej@apple.com>
Sat, 17 Nov 2007 02:48:01 +0000 (02:48 +0000)
committerDale Johannesen <dalej@apple.com>
Sat, 17 Nov 2007 02:48:01 +0000 (02:48 +0000)
fix an occasional nonrepeatable bootstrap failure we've
been seeing on Darwin.

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

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index bd1d66a44de1cb86d5cc47fa9e0b0c065407008e..d107799583160d628eb872ab4d16f6c98f2acee1 100644 (file)
@@ -1028,8 +1028,12 @@ unsigned LoopStrengthReduce::CheckForIVReuse(bool HasBaseReg,
                                 const std::vector<BasedUser>& UsersToProcess) {
   if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Stride)) {
     int64_t SInt = SC->getValue()->getSExtValue();
-    for (std::map<SCEVHandle, IVsOfOneStride>::iterator SI= IVsByStride.begin(),
-           SE = IVsByStride.end(); SI != SE; ++SI) {
+    for (unsigned NewStride = 0, e = StrideOrder.size(); NewStride != e;
+         ++NewStride) {
+      std::map<SCEVHandle, IVsOfOneStride>::iterator SI = 
+                IVsByStride.find(StrideOrder[NewStride]);
+      if (SI == IVsByStride.end()) 
+        continue;
       int64_t SSInt = cast<SCEVConstant>(SI->first)->getValue()->getSExtValue();
       if (SI->first != Stride &&
           (unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0))