allow -1 strides to reuse "1" strides.
[oota-llvm.git] / lib / Transforms / Scalar / LoopStrengthReduce.cpp
index 744e0548bad0480870bdf9b6890d7684bd957532..db8ab485e394c428ae1b60e83ab27864e3f17893 100644 (file)
@@ -929,7 +929,8 @@ unsigned LoopStrengthReduce::CheckForIVReuse(const SCEVHandle &Stride,
     for (std::map<SCEVHandle, IVsOfOneStride>::iterator SI= IVsByStride.begin(),
            SE = IVsByStride.end(); SI != SE; ++SI) {
       int64_t SSInt = cast<SCEVConstant>(SI->first)->getValue()->getSExtValue();
-      if (unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0)
+      if (SInt != -SSInt &&
+          (unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0))
         continue;
       int64_t Scale = SInt / SSInt;
       // Check that this stride is valid for all the types used for loads and