Check iteration count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55680 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index b2c5977..16b8dbb 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1908,6 +1908,10 @@
 /// change the type of IV, if possible.
 void LoopStrengthReduce::OptimizeIVType(Loop *L) {
 
+  SCEVHandle IterationCount = SE->getIterationCount(L);
+  if (isa<SCEVCouldNotCompute>(IterationCount))
+    return;
+
   BasicBlock *LPH = L->getLoopPreheader();
   BasicBlock *LatchBB = L->getLoopLatch();
   SmallVector<PHINode *, 4> PHIs;
diff --git a/test/Transforms/LoopStrengthReduce/2008-09-02-IVType.ll b/test/Transforms/LoopStrengthReduce/2008-09-02-IVType.ll
index 772d9dd..49df675 100644
--- a/test/Transforms/LoopStrengthReduce/2008-09-02-IVType.ll
+++ b/test/Transforms/LoopStrengthReduce/2008-09-02-IVType.ll
@@ -49,7 +49,7 @@
 	store i16* %theDCTBufferIter.0.lcssa, i16** %tmp6, align 4
 	%tmp37 = add i16 %component.09, 1		; <i16> [#uses=2]
 	%phitmp15 = sext i16 %tmp37 to i32		; <i32> [#uses=1]
-	%tmp46 = icmp slt i32 %phitmp15, %tmp4412		; <i1> [#uses=1]
+	%tmp46 = icmp slt i32 %phitmp15, 42		; <i1> [#uses=1]
 	br i1 %tmp46, label %bb, label %bb49
 
 bb49:		; preds = %bb28, %entry