Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44319 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/ScalarEvolution/do-loop.ll b/test/Analysis/ScalarEvolution/do-loop.ll
new file mode 100644
index 0000000..c6b3298
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/do-loop.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep smax
+; PR1614
+
+define i32 @f(i32 %x, i32 %y) {
+entry:
+	br label %bb
+
+bb:		; preds = %bb, %entry
+	%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]		; <i32> [#uses=2]
+	%x_addr.0 = add i32 %indvar, %x		; <i32> [#uses=1]
+	%tmp2 = add i32 %x_addr.0, 1		; <i32> [#uses=2]
+	%tmp5 = icmp slt i32 %tmp2, %y		; <i1> [#uses=1]
+	%indvar.next = add i32 %indvar, 1		; <i32> [#uses=1]
+	br i1 %tmp5, label %bb, label %bb7
+
+bb7:		; preds = %bb
+	ret i32 %tmp2
+}
diff --git a/test/Analysis/ScalarEvolution/smax.ll b/test/Analysis/ScalarEvolution/smax.ll
new file mode 100644
index 0000000..157d54f
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/smax.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep smax | count 2
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep \
+; RUN:     "%. smax  %. smax  %."
+; PR1614
+
+define i32 @x(i32 %a, i32 %b, i32 %c) {
+  %A = icmp sgt i32 %a, %b
+  %B = select i1 %A, i32 %a, i32 %b
+  %C = icmp sle i32 %c, %B
+  %D = select i1 %C, i32 %B, i32 %c
+  ret i32 %D
+}
diff --git a/test/Transforms/IndVarsSimplify/loop_evaluate_2.ll b/test/Transforms/IndVarsSimplify/loop_evaluate_2.ll
index c742691..635950a 100644
--- a/test/Transforms/IndVarsSimplify/loop_evaluate_2.ll
+++ b/test/Transforms/IndVarsSimplify/loop_evaluate_2.ll
@@ -1,5 +1,5 @@
-; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | grep select
-; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | not grep br
+; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | opt \
+; RUN:     -analyze -loops | not grep "^Loop Containing" 
 ; PR1179
 
 define i32 @ltst(i32 %x) {