Strengthen the "non-constant stride must dominate loop preheader" check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64703 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 055114c..0945a57 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -438,16 +438,11 @@
   Start = SE->getAddExpr(Start, AddRec->getOperand(0));
   
   if (!isa<SCEVConstant>(AddRec->getOperand(1))) {
-    // If stride is an instruction, make sure it dominates the loop header.
+    // If stride is an instruction, make sure it dominates the loop preheader.
     // Otherwise we could end up with a use before def situation.
-    if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(AddRec->getOperand(1))) {
-      if (Instruction *I = dyn_cast<Instruction>(SU->getValue())) {
-        BasicBlock *StrideBB = I->getParent();
-        BasicBlock *Preheader = L->getLoopPreheader();
-        if (!DT->dominates(StrideBB, Preheader))
-          return false;
-      }
-    }
+    BasicBlock *Preheader = L->getLoopPreheader();
+    if (!AddRec->getOperand(1)->dominates(Preheader, DT))
+      return false;
 
     DOUT << "[" << L->getHeader()->getName()
          << "] Variable stride: " << *AddRec << "\n";