summaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/Andersens/2007-11-19-InlineAsm.ll8
-rw-r--r--test/Analysis/Andersens/2008-03-19-External.ll12
-rw-r--r--test/Analysis/Andersens/2008-04-07-Memcpy.ll14
-rw-r--r--test/Analysis/Andersens/2008-12-27-BuiltinWrongType.ll19
-rw-r--r--test/Analysis/Andersens/basictest.ll28
-rw-r--r--test/Analysis/Andersens/dg.exp4
-rw-r--r--test/Analysis/Andersens/external.ll20
-rw-r--r--test/Analysis/Andersens/modreftest.ll15
-rw-r--r--test/Analysis/Andersens/modreftest2.ll14
-rw-r--r--test/Analysis/Andersens/trivialtest.ll3
-rw-r--r--test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll18
-rw-r--r--test/Analysis/BasicAA/2003-03-04-GEPCrash.ll7
-rw-r--r--test/Analysis/BasicAA/2003-04-22-GEPProblem.ll15
-rw-r--r--test/Analysis/BasicAA/2003-04-25-GEPCrash.ll7
-rw-r--r--test/Analysis/BasicAA/2003-05-21-GEP-Problem.ll21
-rw-r--r--test/Analysis/BasicAA/2003-06-01-AliasCrash.ll11
-rw-r--r--test/Analysis/BasicAA/2003-07-03-BasicAACrash.ll10
-rw-r--r--test/Analysis/BasicAA/2003-09-19-LocalArgument.ll12
-rw-r--r--test/Analysis/BasicAA/2003-11-04-SimpleCases.ll16
-rw-r--r--test/Analysis/BasicAA/2003-12-11-ConstExprGEP.ll18
-rw-r--r--test/Analysis/BasicAA/2004-07-28-MustAliasbug.ll10
-rw-r--r--test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll22
-rw-r--r--test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll20
-rw-r--r--test/Analysis/BasicAA/2005-03-09-BrokenBasicAA.ll15
-rw-r--r--test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll30
-rw-r--r--test/Analysis/BasicAA/2006-11-03-BasicAAVectorCrash.ll48
-rw-r--r--test/Analysis/BasicAA/2007-01-13-BasePointerBadNoAlias.ll35
-rw-r--r--test/Analysis/BasicAA/2007-08-01-NoAliasAndCalls.ll10
-rw-r--r--test/Analysis/BasicAA/2007-08-01-NoAliasAndGEP.ll17
-rw-r--r--test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll17
-rw-r--r--test/Analysis/BasicAA/2007-10-24-ArgumentsGlobals.ll14
-rw-r--r--test/Analysis/BasicAA/2007-11-05-SizeCrash.ll34
-rw-r--r--test/Analysis/BasicAA/2007-12-08-OutOfBoundsCrash.ll31
-rw-r--r--test/Analysis/BasicAA/2008-04-15-Byval.ll18
-rw-r--r--test/Analysis/BasicAA/2008-06-02-GEPTailCrash.ll15
-rw-r--r--test/Analysis/BasicAA/2008-11-23-NoaliasRet.ll12
-rw-r--r--test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll16
-rw-r--r--test/Analysis/BasicAA/2009-03-04-GEPNoalias.ll13
-rw-r--r--test/Analysis/BasicAA/byval.ll18
-rw-r--r--test/Analysis/BasicAA/cas.ll14
-rw-r--r--test/Analysis/BasicAA/constant-over-index.ll27
-rw-r--r--test/Analysis/BasicAA/dg.exp3
-rw-r--r--test/Analysis/BasicAA/featuretest.ll82
-rw-r--r--test/Analysis/BasicAA/gcsetest.ll46
-rw-r--r--test/Analysis/BasicAA/global-size.ll15
-rw-r--r--test/Analysis/BasicAA/licmtest.ll41
-rw-r--r--test/Analysis/BasicAA/modref.ll15
-rw-r--r--test/Analysis/BasicAA/no-escape-call.ll23
-rw-r--r--test/Analysis/BasicAA/nocapture.ll14
-rw-r--r--test/Analysis/BasicAA/pure-const-dce.ll33
-rw-r--r--test/Analysis/BasicAA/tailcall-modref.ll16
-rw-r--r--test/Analysis/CallGraph/2008-09-09-DirectCall.ll13
-rw-r--r--test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll8
-rw-r--r--test/Analysis/CallGraph/dg.exp3
-rw-r--r--test/Analysis/Dominators/2006-10-02-BreakCritEdges.ll20
-rw-r--r--test/Analysis/Dominators/2007-01-14-BreakCritEdges.ll187
-rw-r--r--test/Analysis/Dominators/2007-07-11-SplitBlock.ll21
-rw-r--r--test/Analysis/Dominators/2007-07-12-SplitBlock.ll13
-rw-r--r--test/Analysis/Dominators/dg.exp3
-rw-r--r--test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll18
-rw-r--r--test/Analysis/GlobalsModRef/aliastest.ll9
-rw-r--r--test/Analysis/GlobalsModRef/chaining-analysis.ll20
-rw-r--r--test/Analysis/GlobalsModRef/dg.exp3
-rw-r--r--test/Analysis/GlobalsModRef/indirect-global.ll20
-rw-r--r--test/Analysis/GlobalsModRef/modreftest.ll13
-rw-r--r--test/Analysis/GlobalsModRef/purecse.ll23
-rw-r--r--test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll30
-rw-r--r--test/Analysis/LoopInfo/dg.exp3
-rw-r--r--test/Analysis/PostDominators/2006-09-26-PostDominanceFrontier.ll97
-rw-r--r--test/Analysis/PostDominators/2007-04-17-PostDominanceFrontier.ll692
-rw-r--r--test/Analysis/PostDominators/2007-04-20-PostDom-Reset.ll28
-rw-r--r--test/Analysis/PostDominators/dg.exp3
-rw-r--r--test/Analysis/PostDominators/pr1098.ll14
-rw-r--r--test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll21
-rw-r--r--test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll18
-rw-r--r--test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll30
-rw-r--r--test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll22
-rw-r--r--test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll24
-rw-r--r--test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll18
-rw-r--r--test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll15
-rw-r--r--test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll16
-rw-r--r--test/Analysis/ScalarEvolution/2008-02-15-UMax.ll17
-rw-r--r--test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll22
-rw-r--r--test/Analysis/ScalarEvolution/2008-06-12-BinomialInt64.ll43
-rw-r--r--test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll36
-rw-r--r--test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll30
-rw-r--r--test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll15
-rw-r--r--test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll15
-rw-r--r--test/Analysis/ScalarEvolution/2008-07-29-SGTTripCount.ll27
-rw-r--r--test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll24
-rw-r--r--test/Analysis/ScalarEvolution/2008-08-04-IVOverflow.ll25
-rw-r--r--test/Analysis/ScalarEvolution/2008-08-04-LongAddRec.ll56
-rw-r--r--test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll21
-rw-r--r--test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll19
-rw-r--r--test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll32
-rw-r--r--test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll30
-rw-r--r--test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll31
-rw-r--r--test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll25
-rw-r--r--test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll28
-rw-r--r--test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll22
-rw-r--r--test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll21
-rw-r--r--test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll40
-rw-r--r--test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll37
-rw-r--r--test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll27
-rw-r--r--test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll32
-rw-r--r--test/Analysis/ScalarEvolution/and-xor.ll8
-rw-r--r--test/Analysis/ScalarEvolution/avoid-smax-0.ll35
-rw-r--r--test/Analysis/ScalarEvolution/avoid-smax-1.ll236
-rw-r--r--test/Analysis/ScalarEvolution/dg.exp3
-rw-r--r--test/Analysis/ScalarEvolution/div-overflow.ll10
-rw-r--r--test/Analysis/ScalarEvolution/do-loop.ll18
-rw-r--r--test/Analysis/ScalarEvolution/max-trip-count.ll32
-rw-r--r--test/Analysis/ScalarEvolution/pr3909.ll30
-rw-r--r--test/Analysis/ScalarEvolution/sext-inreg.ll30
-rw-r--r--test/Analysis/ScalarEvolution/sext-iv-0.ll31
-rw-r--r--test/Analysis/ScalarEvolution/sext-iv-1.ll100
-rw-r--r--test/Analysis/ScalarEvolution/smax.ll12
-rw-r--r--test/Analysis/ScalarEvolution/trip-count.ll29
-rw-r--r--test/Analysis/ScalarEvolution/trip-count2.ll35
-rw-r--r--test/Analysis/ScalarEvolution/trip-count3.ll74
-rw-r--r--test/Analysis/ScalarEvolution/trip-count4.ll24
121 files changed, 3783 insertions, 0 deletions
diff --git a/test/Analysis/Andersens/2007-11-19-InlineAsm.ll b/test/Analysis/Andersens/2007-11-19-InlineAsm.ll
new file mode 100644
index 000000000000..c1ab6c7b1a4f
--- /dev/null
+++ b/test/Analysis/Andersens/2007-11-19-InlineAsm.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -anders-aa -disable-output
+
+define void @x(i16 %Y) {
+entry:
+ %tmp = call i16 asm "bswap $0", "=r,r"(i16 %Y)
+ ret void
+}
+
diff --git a/test/Analysis/Andersens/2008-03-19-External.ll b/test/Analysis/Andersens/2008-03-19-External.ll
new file mode 100644
index 000000000000..c4f1ff083855
--- /dev/null
+++ b/test/Analysis/Andersens/2008-03-19-External.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | opt -anders-aa -gvn | llvm-dis | not grep undef
+; PR2160
+
+declare void @f(i32*)
+
+define i32 @g() {
+entry:
+ %tmp = alloca i32 ; <i32*> [#uses=2]
+ call void @f( i32* %tmp )
+ %tmp2 = load i32* %tmp ; <i32> [#uses=1]
+ ret i32 %tmp2
+}
diff --git a/test/Analysis/Andersens/2008-04-07-Memcpy.ll b/test/Analysis/Andersens/2008-04-07-Memcpy.ll
new file mode 100644
index 000000000000..935444991a38
--- /dev/null
+++ b/test/Analysis/Andersens/2008-04-07-Memcpy.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -anders-aa -gvn | llvm-dis | not grep undef
+; PR2169
+
+declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind
+declare void @use(i8)
+
+define void @f(i8* %x) {
+entry:
+ %copy = alloca i8 ; <i8*> [#uses=6]
+ call void @llvm.memcpy.i32( i8* %copy, i8* %x, i32 1, i32 4 )
+ %tmp = load i8* %copy ; <i8> [#uses=1]
+ call void @use(i8 %tmp)
+ ret void
+}
diff --git a/test/Analysis/Andersens/2008-12-27-BuiltinWrongType.ll b/test/Analysis/Andersens/2008-12-27-BuiltinWrongType.ll
new file mode 100644
index 000000000000..5f5da7464db9
--- /dev/null
+++ b/test/Analysis/Andersens/2008-12-27-BuiltinWrongType.ll
@@ -0,0 +1,19 @@
+; RUN: llvm-as < %s | opt -anders-aa
+; PR3262
+
+@.str15 = external global [3 x i8] ; <[3 x i8]*> [#uses=1]
+
+declare i8* @strtok(...)
+declare i8* @memmove(...)
+
+define void @test1(i8* %want1) nounwind {
+entry:
+ %0 = call i8* (...)* @strtok(i32 0, i8* getelementptr ([3 x i8]* @.str15, i32 0, i32 0)) nounwind ; <i8*> [#uses=0]
+ unreachable
+}
+
+define void @test2() nounwind {
+entry:
+ %0 = call i8* (...)* @memmove()
+ unreachable
+}
diff --git a/test/Analysis/Andersens/basictest.ll b/test/Analysis/Andersens/basictest.ll
new file mode 100644
index 000000000000..0005e09b2e7e
--- /dev/null
+++ b/test/Analysis/Andersens/basictest.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | opt -anders-aa -aa-eval 2>/dev/null
+
+define void @test1() {
+ %X = malloc i32*
+ %Y = malloc i32
+ %Z = ptrtoint i32* %Y to i32
+ %W = inttoptr i32 %Z to i32*
+ store i32* %W, i32** %X
+ ret void
+}
+
+define void @test2(i32* %P) {
+ %X = malloc i32*
+ %Y = malloc i32
+ store i32* %P, i32** %X
+ ret void
+}
+
+define internal i32 *@test3(i32* %P) {
+ ret i32* %P
+}
+
+define void @test4() {
+ %X = malloc i32
+ %Y = call i32* @test3(i32* %X)
+ %ZZ = getelementptr i32* null, i32 17
+ ret void
+}
diff --git a/test/Analysis/Andersens/dg.exp b/test/Analysis/Andersens/dg.exp
new file mode 100644
index 000000000000..1eb4755c4102
--- /dev/null
+++ b/test/Analysis/Andersens/dg.exp
@@ -0,0 +1,4 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
+
diff --git a/test/Analysis/Andersens/external.ll b/test/Analysis/Andersens/external.ll
new file mode 100644
index 000000000000..8a4be2590ddf
--- /dev/null
+++ b/test/Analysis/Andersens/external.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -anders-aa -gvn -deadargelim | llvm-dis | grep store | not grep null
+
+; Because the 'internal' function is passed to an external function, we don't
+; know what the incoming values will alias. As such, we cannot do the
+; optimization checked by the 'arg-must-alias.ll' test.
+
+declare void @external(i32(i32*)*)
+@G = internal constant i32* null
+
+define internal i32 @internal(i32* %ARG) {
+ ;;; We *DON'T* know that ARG always points to null!
+ store i32* %ARG, i32** @G
+ ret i32 0
+}
+
+define i32 @foo() {
+ call void @external(i32(i32*)* @internal)
+ %V = call i32 @internal(i32* null)
+ ret i32 %V
+}
diff --git a/test/Analysis/Andersens/modreftest.ll b/test/Analysis/Andersens/modreftest.ll
new file mode 100644
index 000000000000..f86c7f74d17f
--- /dev/null
+++ b/test/Analysis/Andersens/modreftest.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -anders-aa -gvn -instcombine | llvm-dis \
+; RUN: | grep {ret i1 true}
+
+@G = internal global i32* null
+declare i32 *@ext()
+
+define i1 @bar() {
+ %V1 = load i32** @G
+ %X2 = call i32 *@ext()
+ %V2 = load i32** @G
+ store i32* %X2, i32** @G
+
+ %C = icmp eq i32* %V1, %V2
+ ret i1 %C
+}
diff --git a/test/Analysis/Andersens/modreftest2.ll b/test/Analysis/Andersens/modreftest2.ll
new file mode 100644
index 000000000000..0ba91df857a6
--- /dev/null
+++ b/test/Analysis/Andersens/modreftest2.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -anders-aa -gvn | llvm-dis \
+; RUN: | not grep {ret i32 undef}
+
+;; From PR 2160
+declare void @f(i32*)
+
+define i32 @g() {
+entry:
+ %tmp = alloca i32 ; <i32*> [#uses=2]
+ call void @f( i32* %tmp )
+ %tmp2 = load i32* %tmp ; <i32> [#uses=1]
+ ret i32 %tmp2
+}
+
diff --git a/test/Analysis/Andersens/trivialtest.ll b/test/Analysis/Andersens/trivialtest.ll
new file mode 100644
index 000000000000..ce37516b3684
--- /dev/null
+++ b/test/Analysis/Andersens/trivialtest.ll
@@ -0,0 +1,3 @@
+; RUN: llvm-as < %s | opt -anders-aa -disable-output
+
+define void @foo() { ret void }
diff --git a/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll b/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll
new file mode 100644
index 000000000000..8ba66df8b99f
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll
@@ -0,0 +1,18 @@
+; This testcase makes sure that size is taken to account when alias analysis
+; is performed. It is not legal to delete the second load instruction because
+; the value computed by the first load instruction is changed by the store.
+
+; RUN: llvm-as < %s | opt -gvn -instcombine | llvm-dis | grep DONOTREMOVE
+
+define i32 @test() {
+ %A = alloca i32
+ store i32 0, i32* %A
+ %X = load i32* %A
+ %B = bitcast i32* %A to i8*
+ %C = getelementptr i8* %B, i64 1
+ store i8 1, i8* %C ; Aliases %A
+ %Y.DONOTREMOVE = load i32* %A
+ %Z = sub i32 %X, %Y.DONOTREMOVE
+ ret i32 %Z
+}
+
diff --git a/test/Analysis/BasicAA/2003-03-04-GEPCrash.ll b/test/Analysis/BasicAA/2003-03-04-GEPCrash.ll
new file mode 100644
index 000000000000..0a15deb9baa6
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-03-04-GEPCrash.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output 2>/dev/null
+; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2
+define void @test({[2 x i32],[2 x i32]}* %A, i64 %X, i64 %Y) {
+ %P1 = getelementptr {[2 x i32],[2 x i32]}* %A, i64 0, i32 0, i64 %X
+ %P2 = getelementptr {[2 x i32],[2 x i32]}* %A, i64 0, i32 1, i64 %Y
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2003-04-22-GEPProblem.ll b/test/Analysis/BasicAA/2003-04-22-GEPProblem.ll
new file mode 100644
index 000000000000..4b3cc6a0a647
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-04-22-GEPProblem.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -gvn -instcombine | llvm-dis | grep sub
+
+; BasicAA was incorrectly concluding that P1 and P2 didn't conflict!
+
+define i32 @test(i32 *%Ptr, i64 %V) {
+ %P2 = getelementptr i32* %Ptr, i64 1
+ %P1 = getelementptr i32* %Ptr, i64 %V
+ %X = load i32* %P1
+ store i32 5, i32* %P2
+
+ %Y = load i32* %P1
+
+ %Z = sub i32 %X, %Y
+ ret i32 %Z
+}
diff --git a/test/Analysis/BasicAA/2003-04-25-GEPCrash.ll b/test/Analysis/BasicAA/2003-04-25-GEPCrash.ll
new file mode 100644
index 000000000000..845613150eac
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-04-25-GEPCrash.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output 2>/dev/null
+; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2
+define void @test([17 x i16]* %mask_bits) {
+ %P1 = getelementptr [17 x i16]* %mask_bits, i64 0, i64 0
+ %P2 = getelementptr [17 x i16]* %mask_bits, i64 252645134, i64 0
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2003-05-21-GEP-Problem.ll b/test/Analysis/BasicAA/2003-05-21-GEP-Problem.ll
new file mode 100644
index 000000000000..c9049c8cc439
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-05-21-GEP-Problem.ll
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -licm -disable-output
+ %struct..apr_array_header_t = type { i32*, i32, i32, i32, i8* }
+ %struct..apr_table_t = type { %struct..apr_array_header_t, i32, [32 x i32], [32 x i32] }
+
+define void @table_reindex(%struct..apr_table_t* %t.1) { ; No predecessors!
+ br label %loopentry
+
+loopentry: ; preds = %0, %no_exit
+ %tmp.101 = getelementptr %struct..apr_table_t* %t.1, i64 0, i32 0, i32 2
+ %tmp.11 = load i32* %tmp.101 ; <i32> [#uses=0]
+ br i1 false, label %no_exit, label %UnifiedExitNode
+
+no_exit: ; preds = %loopentry
+ %tmp.25 = sext i32 0 to i64 ; <i64> [#uses=1]
+ %tmp.261 = getelementptr %struct..apr_table_t* %t.1, i64 0, i32 3, i64 %tmp.25 ; <i32*> [#uses=1]
+ store i32 0, i32* %tmp.261
+ br label %loopentry
+
+UnifiedExitNode: ; preds = %loopentry
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2003-06-01-AliasCrash.ll b/test/Analysis/BasicAA/2003-06-01-AliasCrash.ll
new file mode 100644
index 000000000000..c673a323001e
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-06-01-AliasCrash.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output 2>/dev/null
+
+define i32 @MTConcat([3 x i32]* %a.1) {
+ %tmp.961 = getelementptr [3 x i32]* %a.1, i64 0, i64 4
+ %tmp.97 = load i32* %tmp.961
+ %tmp.119 = getelementptr [3 x i32]* %a.1, i64 1, i64 0
+ %tmp.120 = load i32* %tmp.119
+ %tmp.1541 = getelementptr [3 x i32]* %a.1, i64 0, i64 4
+ %tmp.155 = load i32* %tmp.1541
+ ret i32 0
+}
diff --git a/test/Analysis/BasicAA/2003-07-03-BasicAACrash.ll b/test/Analysis/BasicAA/2003-07-03-BasicAACrash.ll
new file mode 100644
index 000000000000..d385961780d3
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-07-03-BasicAACrash.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output 2>/dev/null
+
+%struct..RefPoint = type { i32, { i32, i8, i8 } }
+%struct..RefRect = type { %struct..RefPoint, %struct..RefPoint }
+
+define i32 @BMT_CommitPartDrawObj() {
+ %tmp.19111 = getelementptr %struct..RefRect* null, i64 0, i32 0, i32 1, i32 2
+ %tmp.20311 = getelementptr %struct..RefRect* null, i64 0, i32 1, i32 1, i32 2
+ ret i32 0
+}
diff --git a/test/Analysis/BasicAA/2003-09-19-LocalArgument.ll b/test/Analysis/BasicAA/2003-09-19-LocalArgument.ll
new file mode 100644
index 000000000000..e2bb86dcb226
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-09-19-LocalArgument.ll
@@ -0,0 +1,12 @@
+; In this test, a local alloca cannot alias an incoming argument.
+
+; RUN: llvm-as < %s | opt -gvn -instcombine | llvm-dis | not grep sub
+
+define i32 @test(i32* %P) {
+ %X = alloca i32
+ %V1 = load i32* %P
+ store i32 0, i32* %X
+ %V2 = load i32* %P
+ %Diff = sub i32 %V1, %V2
+ ret i32 %Diff
+}
diff --git a/test/Analysis/BasicAA/2003-11-04-SimpleCases.ll b/test/Analysis/BasicAA/2003-11-04-SimpleCases.ll
new file mode 100644
index 000000000000..99eae1660de8
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-11-04-SimpleCases.ll
@@ -0,0 +1,16 @@
+; This testcase consists of alias relations which should be completely
+; resolvable by basicaa.
+
+; RUN: llvm-as < %s | opt -aa-eval -print-may-aliases -disable-output \
+; RUN: |& not grep May:
+
+%T = type { i32, [10 x i8] }
+
+define void @test(%T* %P) {
+ %A = getelementptr %T* %P, i64 0
+ %B = getelementptr %T* %P, i64 0, i32 0
+ %C = getelementptr %T* %P, i64 0, i32 1
+ %D = getelementptr %T* %P, i64 0, i32 1, i64 0
+ %E = getelementptr %T* %P, i64 0, i32 1, i64 5
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2003-12-11-ConstExprGEP.ll b/test/Analysis/BasicAA/2003-12-11-ConstExprGEP.ll
new file mode 100644
index 000000000000..639cb0a2f82c
--- /dev/null
+++ b/test/Analysis/BasicAA/2003-12-11-ConstExprGEP.ll
@@ -0,0 +1,18 @@
+; This testcase consists of alias relations which should be completely
+; resolvable by basicaa, but require analysis of getelementptr constant exprs.
+
+; RUN: llvm-as < %s | opt -aa-eval -print-may-aliases -disable-output \
+; RUN: |& not grep May:
+
+%T = type { i32, [10 x i8] }
+
+@G = external global %T
+
+define void @test() {
+ %D = getelementptr %T* @G, i64 0, i32 0
+ %E = getelementptr %T* @G, i64 0, i32 1, i64 5
+ %F = getelementptr i32* getelementptr (%T* @G, i64 0, i32 0), i64 0
+ %X = getelementptr [10 x i8]* getelementptr (%T* @G, i64 0, i32 1), i64 0, i64 5
+
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2004-07-28-MustAliasbug.ll b/test/Analysis/BasicAA/2004-07-28-MustAliasbug.ll
new file mode 100644
index 000000000000..407932c9d6c5
--- /dev/null
+++ b/test/Analysis/BasicAA/2004-07-28-MustAliasbug.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -dse | llvm-dis | grep {store i32 0}
+
+define void @test({i32,i32 }* %P) {
+ %Q = getelementptr {i32,i32}* %P, i32 1
+ %X = getelementptr {i32,i32}* %Q, i32 0, i32 1
+ %Y = getelementptr {i32,i32}* %Q, i32 1, i32 1
+ store i32 0, i32* %X
+ store i32 1, i32* %Y
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll b/test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll
new file mode 100644
index 000000000000..58d4da16e6e6
--- /dev/null
+++ b/test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-as < %s | opt -licm
+
+%"java/lang/Object" = type { %struct.llvm_java_object_base }
+%"java/lang/StringBuffer" = type { "java/lang/Object", i32, { "java/lang/Object", i32, [0 x i8] }*, i1 }
+%struct.llvm_java_object_base = type opaque
+
+define void @"java/lang/StringBuffer/setLength(I)V"(%struct.llvm_java_object_base*) {
+bc0:
+ br i1 false, label %bc40, label %bc65
+
+bc65: ; preds = %bc0, %bc40
+ ret void
+
+bc40: ; preds = %bc0, %bc40
+ %tmp75 = bitcast %struct.llvm_java_object_base* %0 to %"java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1]
+ %tmp76 = getelementptr %"java/lang/StringBuffer"* %tmp75, i32 0, i32 1 ; <i32*> [#uses=1]
+ store i32 0, i32* %tmp76
+ %tmp381 = bitcast %struct.llvm_java_object_base* %0 to %"java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1]
+ %tmp392 = getelementptr %"java/lang/StringBuffer"* %tmp381, i32 0, i32 1 ; <i32*> [#uses=1]
+ %tmp403 = load i32* %tmp392 ; <i32> [#uses=0]
+ br i1 false, label %bc40, label %bc65
+}
diff --git a/test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll b/test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll
new file mode 100644
index 000000000000..d96438fd43d2
--- /dev/null
+++ b/test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -dse
+
+%"java/lang/Object" = type { %struct.llvm_java_object_base }
+%"java/lang/StringBuffer" = type { "java/lang/Object", i32, { "java/lang/Object", i32, [0 x i8] }*, i1 }
+%struct.llvm_java_object_base = type opaque
+
+define void @"java/lang/StringBuffer/ensureCapacity_unsynchronized(I)V"() {
+bc0:
+ %tmp = getelementptr %"java/lang/StringBuffer"* null, i32 0, i32 3 ; <i1*> [#uses=1]
+ br i1 false, label %bc16, label %bc7
+
+bc16: ; preds = %bc0
+ %tmp91 = getelementptr %"java/lang/StringBuffer"* null, i32 0, i32 2 ; <{ "java/lang/Object", i32, [0 x i8] }**> [#uses=1]
+ store { %"java/lang/Object", i32, [0 x i8] }* null, { %"java/lang/Object", i32, [0 x i8] }** %tmp91
+ store i1 false, i1* %tmp
+ ret void
+
+bc7: ; preds = %bc0
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2005-03-09-BrokenBasicAA.ll b/test/Analysis/BasicAA/2005-03-09-BrokenBasicAA.ll
new file mode 100644
index 000000000000..21c86b774c5a
--- /dev/null
+++ b/test/Analysis/BasicAA/2005-03-09-BrokenBasicAA.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine |\
+; RUN: llvm-dis | grep {load i32\\* %A}
+
+declare double* @useit(i32*)
+
+define i32 @foo(i32 %Amt) {
+ %A = malloc i32, i32 %Amt
+ %P = call double* @useit(i32* %A)
+
+ %X = load i32* %A
+ store double 0.0, double* %P
+ %Y = load i32* %A
+ %Z = sub i32 %X, %Y
+ ret i32 %Z
+}
diff --git a/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll b/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll
new file mode 100644
index 000000000000..b8e30198e371
--- /dev/null
+++ b/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | opt -aa-eval -disable-output |& grep {2 no alias respon}
+; TEST that A[1][0] may alias A[0][i].
+
+define void @test(i32 %N) {
+entry:
+ %X = alloca [3 x [3 x i32]] ; <[3 x [3 x i32]]*> [#uses=4]
+ %tmp.24 = icmp sgt i32 %N, 0 ; <i1> [#uses=1]
+ br i1 %tmp.24, label %no_exit, label %loopexit
+
+no_exit: ; preds = %no_exit, %entry
+ %i.0.0 = phi i32 [ 0, %entry ], [ %inc, %no_exit ] ; <i32> [#uses=2]
+ %tmp.6 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 0, i32 %i.0.0 ; <i32*> [#uses=1]
+ store i32 1, i32* %tmp.6
+ %tmp.8 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 0, i32 0 ; <i32*> [#uses=1]
+ %tmp.9 = load i32* %tmp.8 ; <i32> [#uses=1]
+ %tmp.11 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 1, i32 0 ; <i32*> [#uses=1]
+ %tmp.12 = load i32* %tmp.11 ; <i32> [#uses=1]
+ %tmp.13 = add i32 %tmp.12, %tmp.9 ; <i32> [#uses=1]
+ %inc = add i32 %i.0.0, 1 ; <i32> [#uses=2]
+ %tmp.2 = icmp slt i32 %inc, %N ; <i1> [#uses=1]
+ br i1 %tmp.2, label %no_exit, label %loopexit
+
+loopexit: ; preds = %no_exit, %entry
+ %Y.0.1 = phi i32 [ 0, %entry ], [ %tmp.13, %no_exit ] ; <i32> [#uses=1]
+ %tmp.4 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 0 ; <[3 x i32]*> [#uses=1]
+ %tmp.15 = call i32 (...)* @foo( [3 x i32]* %tmp.4, i32 %Y.0.1 ) ; <i32> [#uses=0]
+ ret void
+}
+
+declare i32 @foo(...)
diff --git a/test/Analysis/BasicAA/2006-11-03-BasicAAVectorCrash.ll b/test/Analysis/BasicAA/2006-11-03-BasicAAVectorCrash.ll
new file mode 100644
index 000000000000..cc10e4b81bfd
--- /dev/null
+++ b/test/Analysis/BasicAA/2006-11-03-BasicAAVectorCrash.ll
@@ -0,0 +1,48 @@
+; RUN: llvm-as < %s | opt -licm -disable-output
+target datalayout = "E-p:32:32"
+target triple = "powerpc-apple-darwin8.7.0"
+
+define void @glgRunProcessor() {
+entry:
+ br i1 false, label %bb2037.i, label %cond_true.i18
+
+cond_true.i18: ; preds = %entry
+ ret void
+
+bb205.i: ; preds = %bb2037.i
+ switch i32 0, label %bb1013.i [
+ i32 14, label %bb239.i
+ i32 15, label %bb917.i
+ ]
+
+bb239.i: ; preds = %bb205.i
+ br i1 false, label %cond_false277.i, label %cond_true264.i
+
+cond_true264.i: ; preds = %bb239.i
+ ret void
+
+cond_false277.i: ; preds = %bb239.i
+ %tmp1062.i = getelementptr [2 x <4 x i32>]* null, i32 0, i32 1 ; <<4 x i32>*> [#uses=1]
+ store <4 x i32> zeroinitializer, <4 x i32>* %tmp1062.i
+ br i1 false, label %cond_true1032.i, label %cond_false1063.i85
+
+bb917.i: ; preds = %bb205.i
+ ret void
+
+bb1013.i: ; preds = %bb205.i
+ ret void
+
+cond_true1032.i: ; preds = %cond_false277.i
+ %tmp1187.i = getelementptr [2 x <4 x i32>]* null, i32 0, i32 0, i32 7 ; <i32*> [#uses=1]
+ store i32 0, i32* %tmp1187.i
+ br label %bb2037.i
+
+cond_false1063.i85: ; preds = %cond_false277.i
+ ret void
+
+bb2037.i: ; preds = %cond_true1032.i, %entry
+ br i1 false, label %bb205.i, label %cond_next2042.i
+
+cond_next2042.i: ; preds = %bb2037.i
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2007-01-13-BasePointerBadNoAlias.ll b/test/Analysis/BasicAA/2007-01-13-BasePointerBadNoAlias.ll
new file mode 100644
index 000000000000..08c483d6d76c
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-01-13-BasePointerBadNoAlias.ll
@@ -0,0 +1,35 @@
+; PR1109
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine | llvm-dis | \
+; RUN: grep {sub i32}
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine | llvm-dis | \
+; RUN: not grep {ret i32 0}
+; END.
+
+target datalayout = "e-p:32:32"
+target triple = "i686-apple-darwin8"
+ %struct.CONSTRAINT = type { i32, i32, i32, i32 }
+ %struct.FILE_POS = type { i8, i8, i16, i32 }
+ %struct.FIRST_UNION = type { %struct.FILE_POS }
+ %struct.FOURTH_UNION = type { %struct.CONSTRAINT }
+ %struct.GAP = type { i8, i8, i16 }
+ %struct.LIST = type { %struct.rec*, %struct.rec* }
+ %struct.SECOND_UNION = type { { i16, i8, i8 } }
+ %struct.STYLE = type { { %struct.GAP }, { %struct.GAP }, i16, i16, i16, i8, i8 }
+ %struct.THIRD_UNION = type { { [2 x i32], [2 x i32] } }
+ %struct.closure_type = type { [2 x %struct.LIST], %struct.FIRST_UNION, %struct.SECOND_UNION, %struct.THIRD_UNION, %struct.FOURTH_UNION, %struct.rec*, { %struct.rec* } }
+ %struct.head_type = type { [2 x %struct.LIST], %struct.FIRST_UNION, %struct.SECOND_UNION, %struct.THIRD_UNION, %struct.FOURTH_UNION, %struct.rec*, { %struct.rec* }, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, i32 }
+ %struct.rec = type { %struct.head_type }
+
+
+define i32 @test(%struct.closure_type* %tmp18169) {
+ %tmp18174 = getelementptr %struct.closure_type* %tmp18169, i32 0, i32 4, i32 0, i32 0 ; <i32*> [#uses=2]
+ %tmp18269 = bitcast i32* %tmp18174 to %struct.STYLE* ; <%struct.STYLE*> [#uses=1]
+ %A = load i32* %tmp18174 ; <i32> [#uses=1]
+
+ %tmp18272 = getelementptr %struct.STYLE* %tmp18269, i32 0, i32 0, i32 0, i32 2 ; <i16*> [#uses=1]
+ store i16 123, i16* %tmp18272
+
+ %Q = load i32* %tmp18174 ; <i32> [#uses=1]
+ %Z = sub i32 %A, %Q ; <i32> [#uses=1]
+ ret i32 %Z
+}
diff --git a/test/Analysis/BasicAA/2007-08-01-NoAliasAndCalls.ll b/test/Analysis/BasicAA/2007-08-01-NoAliasAndCalls.ll
new file mode 100644
index 000000000000..3b6eb11b6ae4
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-08-01-NoAliasAndCalls.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as %s -o - | opt -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {MayAlias:.*i32\\* %., i32\\* %.} | grep {%x} | grep {%y}
+
+declare i32* @unclear(i32* %a)
+
+define void @foo(i32* noalias %x) {
+ %y = call i32* @unclear(i32* %x)
+ store i32 0, i32* %x
+ store i32 0, i32* %y
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2007-08-01-NoAliasAndGEP.ll b/test/Analysis/BasicAA/2007-08-01-NoAliasAndGEP.ll
new file mode 100644
index 000000000000..9936afb19560
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-08-01-NoAliasAndGEP.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-as %s -o - | opt -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {9 no alias}
+; RUN: llvm-as %s -o - | opt -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {6 may alias}
+; RUN: llvm-as %s -o - | opt -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {MayAlias:.*i32\\* %Ipointer, i32\\* %Jpointer}
+
+define void @foo(i32* noalias %p, i32* noalias %q, i32 %i, i32 %j) {
+ %Ipointer = getelementptr i32* %p, i32 %i
+ %qi = getelementptr i32* %q, i32 %i
+ %Jpointer = getelementptr i32* %p, i32 %j
+ %qj = getelementptr i32* %q, i32 %j
+ store i32 0, i32* %p
+ store i32 0, i32* %Ipointer
+ store i32 0, i32* %Jpointer
+ store i32 0, i32* %q
+ store i32 0, i32* %qi
+ store i32 0, i32* %qj
+ ret void
+}
diff --git a/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll b/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll
new file mode 100644
index 000000000000..15aaa02a6ef9
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll
@@ -0,0 +1,17 @@
+; PR1600
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine | llvm-dis | \
+; RUN: grep {ret i32 0}
+; END.
+
+declare i16 @llvm.cttz.i16(i16)
+
+define i32 @test(i32* %P, i16* %Q) {
+ %A = load i16* %Q ; <i16> [#uses=1]
+ %x = load i32* %P ; <i32> [#uses=1]
+ %B = call i16 @llvm.cttz.i16( i16 %A ) ; <i16> [#uses=1]
+ %y = load i32* %P ; <i32> [#uses=1]
+ store i16 %B, i16* %Q
+ %z = sub i32 %x, %y ; <i32> [#uses=1]
+ ret i32 %z
+}
+
diff --git a/test/Analysis/BasicAA/2007-10-24-ArgumentsGlobals.ll b/test/Analysis/BasicAA/2007-10-24-ArgumentsGlobals.ll
new file mode 100644
index 000000000000..61ab80d5475a
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-10-24-ArgumentsGlobals.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn -dce | llvm-dis | grep tmp7
+
+ %struct.A = type { i32 }
+ %struct.B = type { %struct.A }
+@a = global %struct.B zeroinitializer ; <%struct.B*> [#uses=2]
+
+define i32 @_Z3fooP1A(%struct.A* %b) {
+entry:
+ store i32 1, i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8
+ %tmp4 = getelementptr %struct.A* %b, i32 0, i32 0 ;<i32*> [#uses=1]
+ store i32 0, i32* %tmp4, align 4
+ %tmp7 = load i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8 ; <i32> [#uses=1]
+ ret i32 %tmp7
+}
diff --git a/test/Analysis/BasicAA/2007-11-05-SizeCrash.ll b/test/Analysis/BasicAA/2007-11-05-SizeCrash.ll
new file mode 100644
index 000000000000..5a938cfef05f
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-11-05-SizeCrash.ll
@@ -0,0 +1,34 @@
+; RUN: llvm-as < %s | opt -gvn -disable-output
+; PR1774
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+ %struct.device = type { [20 x i8] }
+ %struct.pci_device_id = type { i32, i32, i32, i32, i32, i32, i64 }
+ %struct.usb_bus = type { %struct.device* }
+ %struct.usb_hcd = type { %struct.usb_bus, i64, [0 x i64] }
+@uhci_pci_ids = external constant [1 x %struct.pci_device_id] ; <[1 x %struct.pci_device_id]*> [#uses=1]
+
+@__mod_pci_device_table = alias [1 x %struct.pci_device_id]* @uhci_pci_ids
+ ; <[1 x %struct.pci_device_id]*> [#uses=0]
+
+define i32 @uhci_suspend(%struct.usb_hcd* %hcd) {
+entry:
+ %tmp17 = getelementptr %struct.usb_hcd* %hcd, i32 0, i32 2, i64 1
+ ; <i64*> [#uses=1]
+ %tmp1718 = bitcast i64* %tmp17 to i32* ; <i32*> [#uses=1]
+ %tmp19 = load i32* %tmp1718, align 4 ; <i32> [#uses=0]
+ br i1 false, label %cond_true34, label %done_okay
+
+cond_true34: ; preds = %entry
+ %tmp631 = getelementptr %struct.usb_hcd* %hcd, i32 0, i32 2, i64
+2305843009213693950 ; <i64*> [#uses=1]
+ %tmp70 = bitcast i64* %tmp631 to %struct.device** ;
+
+ %tmp71 = load %struct.device** %tmp70, align 8 ;
+
+ ret i32 undef
+
+done_okay: ; preds = %entry
+ ret i32 undef
+}
diff --git a/test/Analysis/BasicAA/2007-12-08-OutOfBoundsCrash.ll b/test/Analysis/BasicAA/2007-12-08-OutOfBoundsCrash.ll
new file mode 100644
index 000000000000..2f0c769ee58d
--- /dev/null
+++ b/test/Analysis/BasicAA/2007-12-08-OutOfBoundsCrash.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -gvn -disable-output
+; PR1782
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+ %struct.device = type { [20 x i8] }
+ %struct.pci_device_id = type { i32, i32, i32, i32, i32, i32, i64 }
+ %struct.usb_bus = type { %struct.device* }
+ %struct.usb_hcd = type { %struct.usb_bus, [0 x i64] }
+@pci_ids = external constant [1 x %struct.pci_device_id] ; <[1 x %struct.pci_device_id]*> [#uses=1]
+
+@__mod_pci_device_table = alias [1 x %struct.pci_device_id]* @pci_ids ; <[1 x %struct.pci_device_id]*> [#uses=0]
+
+define i32 @ehci_pci_setup(%struct.usb_hcd* %hcd) {
+entry:
+ %tmp14 = getelementptr %struct.usb_hcd* %hcd, i32 0, i32 0, i32 0 ; <%struct.device**> [#uses=1]
+ %tmp15 = load %struct.device** %tmp14, align 8 ; <%struct.device*> [#uses=0]
+ br i1 false, label %bb25, label %return
+
+bb25: ; preds = %entry
+ br i1 false, label %cond_true, label %return
+
+cond_true: ; preds = %bb25
+ %tmp601 = getelementptr %struct.usb_hcd* %hcd, i32 0, i32 1, i64 2305843009213693951 ; <i64*> [#uses=1]
+ %tmp67 = bitcast i64* %tmp601 to %struct.device** ; <%struct.device**> [#uses=1]
+ %tmp68 = load %struct.device** %tmp67, align 8 ; <%struct.device*> [#uses=0]
+ ret i32 undef
+
+return: ; preds = %bb25, %entry
+ ret i32 undef
+}
diff --git a/test/Analysis/BasicAA/2008-04-15-Byval.ll b/test/Analysis/BasicAA/2008-04-15-Byval.ll
new file mode 100644
index 000000000000..ee16909977d1
--- /dev/null
+++ b/test/Analysis/BasicAA/2008-04-15-Byval.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -std-compile-opts | llvm-dis | grep store
+; ModuleID = 'small2.c'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i386-apple-darwin8"
+ %struct.x = type { [4 x i32] }
+
+define void @foo(%struct.x* byval align 4 %X) nounwind {
+entry:
+ %tmp = getelementptr %struct.x* %X, i32 0, i32 0 ; <[4 x i32]*> [#uses=1]
+ %tmp1 = getelementptr [4 x i32]* %tmp, i32 0, i32 3 ; <i32*> [#uses=1]
+ store i32 2, i32* %tmp1, align 4
+ %tmp2 = call i32 (...)* @bar( %struct.x* byval align 4 %X ) nounwind ; <i32> [#uses=0]
+ br label %return
+return: ; preds = %entry
+ ret void
+}
+
+declare i32 @bar(...)
diff --git a/test/Analysis/BasicAA/2008-06-02-GEPTailCrash.ll b/test/Analysis/BasicAA/2008-06-02-GEPTailCrash.ll
new file mode 100644
index 000000000000..40d1e32d6730
--- /dev/null
+++ b/test/Analysis/BasicAA/2008-06-02-GEPTailCrash.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -gvn -disable-output
+; PR2395
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
+target triple = "i686-pc-linux-gnu"
+ %struct.S291 = type <{ %union.anon, i32 }>
+ %union.anon = type { }
+@a291 = external global [5 x %struct.S291] ; <[5 x %struct.S291]*> [#uses=2]
+
+define void @test291() nounwind {
+entry:
+ store i32 1138410269, i32* getelementptr ([5 x %struct.S291]* @a291, i32 0, i32 2, i32 1)
+ %tmp54 = load i32* bitcast (%struct.S291* getelementptr ([5 x %struct.S291]* @a291, i32 0, i32 2) to i32*), align 4 ; <i32> [#uses=0]
+ unreachable
+}
diff --git a/test/Analysis/BasicAA/2008-11-23-NoaliasRet.ll b/test/Analysis/BasicAA/2008-11-23-NoaliasRet.ll
new file mode 100644
index 000000000000..d2e823ee8a48
--- /dev/null
+++ b/test/Analysis/BasicAA/2008-11-23-NoaliasRet.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | opt -aa-eval |& grep {1 no alias response}
+
+declare noalias i32* @_Znwj(i32 %x) nounwind
+
+define i32 @foo() {
+ %A = call i32* @_Znwj(i32 4)
+ %B = call i32* @_Znwj(i32 4)
+ store i32 1, i32* %A
+ store i32 2, i32* %B
+ %C = load i32* %A
+ ret i32 %C
+}
diff --git a/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll b/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll
new file mode 100644
index 000000000000..967a36edcb3a
--- /dev/null
+++ b/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll
@@ -0,0 +1,16 @@
+; RUN: llvm-as < %s | opt -aa-eval -print-all-alias-modref-info -disable-output |& grep {MustAlias:.*%R,.*%r}
+; Make sure that basicaa thinks R and r are must aliases.
+
+define i32 @test(i8 * %P) {
+entry:
+ %Q = bitcast i8* %P to {i32, i32}*
+ %R = getelementptr {i32, i32}* %Q, i32 0, i32 1
+ %S = load i32* %R
+
+ %q = bitcast i8* %P to {i32, i32}*
+ %r = getelementptr {i32, i32}* %q, i32 0, i32 1
+ %s = load i32* %r
+
+ %t = sub i32 %S, %s
+ ret i32 %t
+}
diff --git a/test/Analysis/BasicAA/2009-03-04-GEPNoalias.ll b/test/Analysis/BasicAA/2009-03-04-GEPNoalias.ll
new file mode 100644
index 000000000000..f3891ec75f08
--- /dev/null
+++ b/test/Analysis/BasicAA/2009-03-04-GEPNoalias.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep load
+
+declare noalias i32* @noalias()
+
+define i32 @test(i32 %x) {
+ %a = call i32* @noalias()
+ store i32 1, i32* %a
+ %b = getelementptr i32* %a, i32 %x
+ store i32 2, i32* %b
+
+ %c = load i32* %a
+ ret i32 %c
+}
diff --git a/test/Analysis/BasicAA/byval.ll b/test/Analysis/BasicAA/byval.ll
new file mode 100644
index 000000000000..f0644198b7db
--- /dev/null
+++ b/test/Analysis/BasicAA/byval.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {ret i32 1}
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i686-apple-darwin8"
+ %struct.x = type { i32, i32, i32, i32 }
+@g = weak global i32 0 ; <i32*> [#uses=1]
+
+define i32 @foo(%struct.x* byval %a) nounwind {
+entry:
+ %tmp1 = tail call i32 (...)* @bar( %struct.x* %a ) nounwind ; <i32> [#uses=0]
+ %tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 ; <i32*> [#uses=2]
+ store i32 1, i32* %tmp2, align 4
+ store i32 2, i32* @g, align 4
+ %tmp4 = load i32* %tmp2, align 4 ; <i32> [#uses=1]
+ ret i32 %tmp4
+}
+
+declare i32 @bar(...)
+
diff --git a/test/Analysis/BasicAA/cas.ll b/test/Analysis/BasicAA/cas.ll
new file mode 100644
index 000000000000..9bbb5e7c373e
--- /dev/null
+++ b/test/Analysis/BasicAA/cas.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep load | count 1
+
+@flag0 = internal global i32 zeroinitializer
+@turn = internal global i32 zeroinitializer
+
+
+define i32 @main() {
+ %a = load i32* @flag0
+ %b = tail call i32 @llvm.atomic.swap.i32.p0i32(i32* @turn, i32 1)
+ %c = load i32* @flag0
+ ret i32 %c
+}
+
+declare i32 @llvm.atomic.swap.i32.p0i32(i32*, i32) nounwind \ No newline at end of file
diff --git a/test/Analysis/BasicAA/constant-over-index.ll b/test/Analysis/BasicAA/constant-over-index.ll
new file mode 100644
index 000000000000..e92995be5e69
--- /dev/null
+++ b/test/Analysis/BasicAA/constant-over-index.ll
@@ -0,0 +1,27 @@
+; RUN: llvm-as < %s | opt -aa-eval -print-all-alias-modref-info \
+; RUN: |& grep {MayAlias: double\\* \[%\]p.0.i.0, double\\* \[%\]p3\$}
+; PR4267
+
+; %p3 is equal to %p.0.i.0 on the second iteration of the loop,
+; so MayAlias is needed.
+
+define void @foo([3 x [3 x double]]* noalias %p) {
+entry:
+ %p3 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 0, i64 3
+ br label %loop
+
+loop:
+ %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
+
+ %p.0.i.0 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %i, i64 0
+
+ volatile store double 0.0, double* %p3
+ volatile store double 0.1, double* %p.0.i.0
+
+ %i.next = add i64 %i, 1
+ %cmp = icmp slt i64 %i.next, 3
+ br i1 %cmp, label %loop, label %exit
+
+exit:
+ ret void
+}
diff --git a/test/Analysis/BasicAA/dg.exp b/test/Analysis/BasicAA/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Analysis/BasicAA/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Analysis/BasicAA/featuretest.ll b/test/Analysis/BasicAA/featuretest.ll
new file mode 100644
index 000000000000..e807f882219f
--- /dev/null
+++ b/test/Analysis/BasicAA/featuretest.ll
@@ -0,0 +1,82 @@
+; This testcase tests for various features the basicaa test should be able to
+; determine, as noted in the comments.
+
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine -dce | llvm-dis | not grep REMOVE
+
+@Global = external global { i32 }
+
+; Array test: Test that operations on one local array do not invalidate
+; operations on another array. Important for scientific codes.
+;
+define i32 @different_array_test(i64 %A, i64 %B) {
+ %Array1 = alloca i32, i32 100
+ %Array2 = alloca i32, i32 200
+
+ %pointer = getelementptr i32* %Array1, i64 %A
+ %val = load i32* %pointer
+
+ %pointer2 = getelementptr i32* %Array2, i64 %B
+ store i32 7, i32* %pointer2
+
+ %REMOVE = load i32* %pointer ; redundant with above load
+ %retval = sub i32 %REMOVE, %val
+ ret i32 %retval
+}
+
+; Constant index test: Constant indexes into the same array should not
+; interfere with each other. Again, important for scientific codes.
+;
+define i32 @constant_array_index_test() {
+ %Array = alloca i32, i32 100
+ %P1 = getelementptr i32* %Array, i64 7
+ %P2 = getelementptr i32* %Array, i64 6
+
+ %A = load i32* %P1
+ store i32 1, i32* %P2 ; Should not invalidate load
+ %BREMOVE = load i32* %P1
+ %Val = sub i32 %A, %BREMOVE
+ ret i32 %Val
+}
+
+; Test that if two pointers are spaced out by a constant getelementptr, that
+; they cannot alias.
+define i32 @gep_distance_test(i32* %A) {
+ %REMOVEu = load i32* %A
+ %B = getelementptr i32* %A, i64 2 ; Cannot alias A
+ store i32 7, i32* %B
+ %REMOVEv = load i32* %A
+ %r = sub i32 %REMOVEu, %REMOVEv
+ ret i32 %r
+}
+
+; Test that if two pointers are spaced out by a constant offset, that they
+; cannot alias, even if there is a variable offset between them...
+define i32 @gep_distance_test2({i32,i32}* %A, i64 %distance) {
+ %A1 = getelementptr {i32,i32}* %A, i64 0, i32 0
+ %REMOVEu = load i32* %A1
+ %B = getelementptr {i32,i32}* %A, i64 %distance, i32 1
+ store i32 7, i32* %B ; B cannot alias A, it's at least 4 bytes away
+ %REMOVEv = load i32* %A1
+ %r = sub i32 %REMOVEu, %REMOVEv
+ ret i32 %r
+}
+
+; Test that we can do funny pointer things and that distance calc will still
+; work.
+define i32 @gep_distance_test3(i32 * %A) {
+ %X = load i32* %A
+ %B = bitcast i32* %A to i8*
+ %C = getelementptr i8* %B, i64 4
+ %Y = load i8* %C
+ ret i32 8
+}
+
+; Test that we can disambiguate globals reached through constantexpr geps
+define i32 @constexpr_test() {
+ %X = alloca i32
+ %Y = load i32* %X
+ store i32 5, i32* getelementptr ({ i32 }* @Global, i64 0, i32 0)
+ %REMOVE = load i32* %X
+ %retval = sub i32 %Y, %REMOVE
+ ret i32 %retval
+}
diff --git a/test/Analysis/BasicAA/gcsetest.ll b/test/Analysis/BasicAA/gcsetest.ll
new file mode 100644
index 000000000000..1d55ca9a2a94
--- /dev/null
+++ b/test/Analysis/BasicAA/gcsetest.ll
@@ -0,0 +1,46 @@
+; Test that GCSE uses basicaa to do alias analysis, which is capable of
+; disambiguating some obvious cases. All loads should be removable in
+; this testcase.
+
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine -dce \
+; RUN: | llvm-dis | not grep load
+
+@A = global i32 7
+@B = global i32 8
+
+define i32 @test() {
+ %A1 = load i32* @A
+
+ store i32 123, i32* @B ; Store cannot alias @A
+
+ %A2 = load i32* @A
+ %X = sub i32 %A1, %A2
+ ret i32 %X
+}
+
+define i32 @test2() {
+ %A1 = load i32* @A
+ br label %Loop
+Loop:
+ %AP = phi i32 [0, %0], [%X, %Loop]
+ store i32 %AP, i32* @B ; Store cannot alias @A
+
+ %A2 = load i32* @A
+ %X = sub i32 %A1, %A2
+ %c = icmp eq i32 %X, 0
+ br i1 %c, label %out, label %Loop
+
+out:
+ ret i32 %X
+}
+
+declare void @external()
+
+define i32 @test3() {
+ %X = alloca i32
+ store i32 7, i32* %X
+ call void @external()
+ %V = load i32* %X
+ ret i32 %V
+}
+
diff --git a/test/Analysis/BasicAA/global-size.ll b/test/Analysis/BasicAA/global-size.ll
new file mode 100644
index 000000000000..ce92a690d410
--- /dev/null
+++ b/test/Analysis/BasicAA/global-size.ll
@@ -0,0 +1,15 @@
+; A store or load cannot alias a global if the accessed amount is larger then
+; the global.
+
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine | llvm-dis | not grep load
+
+@B = global i16 8 ; <i16*> [#uses=2]
+
+define i16 @test(i32* %P) {
+ %X = load i16* @B ; <i16> [#uses=1]
+ store i32 7, i32* %P
+ %Y = load i16* @B ; <i16> [#uses=1]
+ %Z = sub i16 %Y, %X ; <i16> [#uses=1]
+ ret i16 %Z
+}
+
diff --git a/test/Analysis/BasicAA/licmtest.ll b/test/Analysis/BasicAA/licmtest.ll
new file mode 100644
index 000000000000..cfef63b1fd49
--- /dev/null
+++ b/test/Analysis/BasicAA/licmtest.ll
@@ -0,0 +1,41 @@
+; Test that LICM uses basicaa to do alias analysis, which is capable of
+; disambiguating some obvious cases. If LICM is able to disambiguate the
+; two pointers, then the load should be hoisted, and the store sunk.
+
+; RUN: llvm-as < %s | opt -basicaa -licm | llvm-dis | %prcontext @A 1 | not grep Loop
+
+@A = global i32 7 ; <i32*> [#uses=3]
+@B = global i32 8 ; <i32*> [#uses=2]
+@C = global [2 x i32] [ i32 4, i32 8 ] ; <[2 x i32]*> [#uses=2]
+
+define i32 @test(i1 %c) {
+ %Atmp = load i32* @A ; <i32> [#uses=2]
+ br label %Loop
+
+Loop: ; preds = %Loop, %0
+ %ToRemove = load i32* @A ; <i32> [#uses=1]
+ store i32 %Atmp, i32* @B
+ br i1 %c, label %Out, label %Loop
+
+Out: ; preds = %Loop
+ %X = sub i32 %ToRemove, %Atmp ; <i32> [#uses=1]
+ ret i32 %X
+}
+
+define i32 @test2(i1 %c) {
+ br label %Loop
+
+Loop: ; preds = %Loop, %0
+ %AVal = load i32* @A ; <i32> [#uses=2]
+ %C0 = getelementptr [2 x i32]* @C, i64 0, i64 0 ; <i32*> [#uses=1]
+ store i32 %AVal, i32* %C0
+ %BVal = load i32* @B ; <i32> [#uses=2]
+ %C1 = getelementptr [2 x i32]* @C, i64 0, i64 1 ; <i32*> [#uses=1]
+ store i32 %BVal, i32* %C1
+ br i1 %c, label %Out, label %Loop
+
+Out: ; preds = %Loop
+ %X = sub i32 %AVal, %BVal ; <i32> [#uses=1]
+ ret i32 %X
+}
+
diff --git a/test/Analysis/BasicAA/modref.ll b/test/Analysis/BasicAA/modref.ll
new file mode 100644
index 000000000000..819f956eaa10
--- /dev/null
+++ b/test/Analysis/BasicAA/modref.ll
@@ -0,0 +1,15 @@
+; A very rudimentary test on AliasAnalysis::getModRefInfo.
+; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output |& \
+; RUN: not grep NoModRef
+
+define i32 @callee() {
+ %X = alloca { i32, i32 } ; <{ i32, i32 }*> [#uses=1]
+ %Y = getelementptr { i32, i32 }* %X, i64 0, i32 0 ; <i32*> [#uses=1]
+ %Z = load i32* %Y ; <i32> [#uses=1]
+ ret i32 %Z
+}
+
+define i32 @caller() {
+ %X = call i32 @callee( ) ; <i32> [#uses=1]
+ ret i32 %X
+}
diff --git a/test/Analysis/BasicAA/no-escape-call.ll b/test/Analysis/BasicAA/no-escape-call.ll
new file mode 100644
index 000000000000..ab1fea78e959
--- /dev/null
+++ b/test/Analysis/BasicAA/no-escape-call.ll
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine | llvm-dis | grep {ret i1 true}
+; PR2436
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i386-apple-darwin8"
+
+define i1 @foo(i32 %i) nounwind {
+entry:
+ %arr = alloca [10 x i8*] ; <[10 x i8*]*> [#uses=1]
+ %tmp2 = call i8* @getPtr( ) nounwind ; <i8*> [#uses=2]
+ %tmp4 = getelementptr [10 x i8*]* %arr, i32 0, i32 %i ; <i8**> [#uses=2]
+ store i8* %tmp2, i8** %tmp4, align 4
+ %tmp10 = getelementptr i8* %tmp2, i32 10 ; <i8*> [#uses=1]
+ store i8 42, i8* %tmp10, align 1
+ %tmp14 = load i8** %tmp4, align 4 ; <i8*> [#uses=1]
+ %tmp16 = getelementptr i8* %tmp14, i32 10 ; <i8*> [#uses=1]
+ %tmp17 = load i8* %tmp16, align 1 ; <i8> [#uses=1]
+ %tmp19 = icmp eq i8 %tmp17, 42 ; <i1> [#uses=1]
+ ret i1 %tmp19
+}
+
+declare i8* @getPtr()
+
+declare void @abort() noreturn nounwind
diff --git a/test/Analysis/BasicAA/nocapture.ll b/test/Analysis/BasicAA/nocapture.ll
new file mode 100644
index 000000000000..0ca444c1cacb
--- /dev/null
+++ b/test/Analysis/BasicAA/nocapture.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine | llvm-dis | grep {ret i32 0}
+
+declare i32* @test(i32* nocapture)
+
+define i32 @test2() {
+ %P = alloca i32
+ %Q = call i32* @test(i32* %P)
+ %a = load i32* %P
+ store i32 4, i32* %Q ;; cannot clobber P since it is nocapture.
+ %b = load i32* %P
+ %c = sub i32 %a, %b
+ ret i32 %c
+}
+
diff --git a/test/Analysis/BasicAA/pure-const-dce.ll b/test/Analysis/BasicAA/pure-const-dce.ll
new file mode 100644
index 000000000000..b01b5c5cb81c
--- /dev/null
+++ b/test/Analysis/BasicAA/pure-const-dce.ll
@@ -0,0 +1,33 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestConst | count 2
+; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestPure | count 3
+; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestNone | count 4
+@g = global i32 0 ; <i32*> [#uses=1]
+
+define i32 @test() {
+entry:
+ %tmp0 = call i32 @TestConst( i32 5 ) readnone ; <i32> [#uses=1]
+ %tmp1 = call i32 @TestPure( i32 6 ) readonly ; <i32> [#uses=1]
+ %tmp2 = call i32 @TestNone( i32 7 ) ; <i32> [#uses=1]
+ store i32 1, i32* @g
+ %tmp3 = call i32 @TestConst( i32 5 ) readnone ; <i32> [#uses=1]
+ %tmp4 = call i32 @TestConst( i32 5 ) readnone ; <i32> [#uses=1]
+ %tmp5 = call i32 @TestPure( i32 6 ) readonly ; <i32> [#uses=1]
+ %tmp6 = call i32 @TestPure( i32 6 ) readonly ; <i32> [#uses=1]
+ %tmp7 = call i32 @TestNone( i32 7 ) ; <i32> [#uses=1]
+ %tmp8 = call i32 @TestNone( i32 7 ) ; <i32> [#uses=1]
+ %sum0 = add i32 %tmp0, %tmp1 ; <i32> [#uses=1]
+ %sum1 = add i32 %sum0, %tmp2 ; <i32> [#uses=1]
+ %sum2 = add i32 %sum1, %tmp3 ; <i32> [#uses=1]
+ %sum3 = add i32 %sum2, %tmp4 ; <i32> [#uses=1]
+ %sum4 = add i32 %sum3, %tmp5 ; <i32> [#uses=1]
+ %sum5 = add i32 %sum4, %tmp6 ; <i32> [#uses=1]
+ %sum6 = add i32 %sum5, %tmp7 ; <i32> [#uses=1]
+ %sum7 = add i32 %sum6, %tmp8 ; <i32> [#uses=1]
+ ret i32 %sum7
+}
+
+declare i32 @TestConst(i32) readnone
+
+declare i32 @TestPure(i32) readonly
+
+declare i32 @TestNone(i32)
diff --git a/test/Analysis/BasicAA/tailcall-modref.ll b/test/Analysis/BasicAA/tailcall-modref.ll
new file mode 100644
index 000000000000..ac4ea400b0f3
--- /dev/null
+++ b/test/Analysis/BasicAA/tailcall-modref.ll
@@ -0,0 +1,16 @@
+; RUN: llvm-as < %s | opt -basicaa -gvn -instcombine |\
+; RUN: llvm-dis | grep {ret i32 0}
+
+declare void @foo(i32*)
+
+declare void @bar()
+
+define i32 @test() {
+ %A = alloca i32 ; <i32*> [#uses=3]
+ call void @foo( i32* %A )
+ %X = load i32* %A ; <i32> [#uses=1]
+ tail call void @bar( )
+ %Y = load i32* %A ; <i32> [#uses=1]
+ %Z = sub i32 %X, %Y ; <i32> [#uses=1]
+ ret i32 %Z
+}
diff --git a/test/Analysis/CallGraph/2008-09-09-DirectCall.ll b/test/Analysis/CallGraph/2008-09-09-DirectCall.ll
new file mode 100644
index 000000000000..456ffa25d7bf
--- /dev/null
+++ b/test/Analysis/CallGraph/2008-09-09-DirectCall.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -print-callgraph -disable-output |& \
+; RUN: grep {Calls function 'callee'} | count 2
+
+define internal void @callee(...) {
+entry:
+ unreachable
+}
+
+define void @caller() {
+entry:
+ call void (...)* @callee( void (...)* @callee )
+ unreachable
+}
diff --git a/test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll b/test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll
new file mode 100644
index 000000000000..ffc27bbe43d1
--- /dev/null
+++ b/test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -print-callgraph -disable-output |& \
+; RUN: grep {Calls function}
+
+@a = global void ()* @f ; <void ()**> [#uses=0]
+
+define internal void @f() {
+ unreachable
+}
diff --git a/test/Analysis/CallGraph/dg.exp b/test/Analysis/CallGraph/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Analysis/CallGraph/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Analysis/Dominators/2006-10-02-BreakCritEdges.ll b/test/Analysis/Dominators/2006-10-02-BreakCritEdges.ll
new file mode 100644
index 000000000000..997ee2a8a0a6
--- /dev/null
+++ b/test/Analysis/Dominators/2006-10-02-BreakCritEdges.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -domtree -break-crit-edges -analyze \
+; RUN: -domtree | grep {3.*%brtrue }
+; PR932
+
+declare void @use1(i32)
+
+define void @f(i32 %i, i1 %c) {
+entry:
+ %A = icmp eq i32 %i, 0 ; <i1> [#uses=1]
+ br i1 %A, label %brtrue, label %brfalse
+
+brtrue: ; preds = %brtrue, %entry
+ %B = phi i1 [ true, %brtrue ], [ false, %entry ] ; <i1> [#uses=1]
+ call void @use1( i32 %i )
+ br i1 %B, label %brtrue, label %brfalse
+
+brfalse: ; preds = %brtrue, %entry
+ call void @use1( i32 %i )
+ ret void
+}
diff --git a/test/Analysis/Dominators/2007-01-14-BreakCritEdges.ll b/test/Analysis/Dominators/2007-01-14-BreakCritEdges.ll
new file mode 100644
index 000000000000..697dad25cce9
--- /dev/null
+++ b/test/Analysis/Dominators/2007-01-14-BreakCritEdges.ll
@@ -0,0 +1,187 @@
+; RUN: llvm-as < %s | opt -domtree -break-crit-edges -domtree -disable-output
+; PR1110
+
+ %struct.OggVorbis_File = type { i8*, i32, i64, i64, %struct.ogg_sync_state, i32, i64*, i64*, i32*, i64*, %struct.vorbis_info*, %struct.vorbis_comment*, i64, i32, i32, i32, double, double, %struct.ogg_stream_state, %struct.vorbis_dsp_state, %struct.vorbis_block, %struct.ov_callbacks }
+ %struct.alloc_chain = type { i8*, %struct.alloc_chain* }
+ %struct.ogg_stream_state = type { i8*, i32, i32, i32, i32*, i64*, i32, i32, i32, i32, [282 x i8], i32, i32, i32, i32, i32, i64, i64 }
+ %struct.ogg_sync_state = type { i8*, i32, i32, i32, i32, i32, i32 }
+ %struct.oggpack_buffer = type { i32, i32, i8*, i8*, i32 }
+ %struct.ov_callbacks = type { i32 (i8*, i32, i32, i8*)*, i32 (i8*, i64, i32)*, i32 (i8*)*, i32 (i8*)* }
+ %struct.vorbis_block = type { float**, %struct.oggpack_buffer, i32, i32, i32, i32, i32, i32, i64, i64, %struct.vorbis_dsp_state*, i8*, i32, i32, i32, %struct.alloc_chain*, i32, i32, i32, i32, i8* }
+ %struct.vorbis_comment = type { i8**, i32*, i32, i8* }
+ %struct.vorbis_dsp_state = type { i32, %struct.vorbis_info*, float**, float**, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i8* }
+ %struct.vorbis_info = type { i32, i32, i32, i32, i32, i32, i32, i8* }
+
+
+define void @ov_read() {
+entry:
+ br i1 false, label %bb, label %return
+
+bb: ; preds = %cond_next22, %entry
+ br i1 false, label %cond_true8, label %cond_next15
+
+cond_true8: ; preds = %bb
+ br i1 false, label %cond_next15, label %bb29
+
+cond_next15: ; preds = %cond_true8, %bb
+ br i1 false, label %return, label %cond_next22
+
+cond_next22: ; preds = %cond_next15
+ br i1 false, label %bb, label %return
+
+bb29: ; preds = %cond_true8
+ br i1 false, label %cond_true32, label %return
+
+cond_true32: ; preds = %bb29
+ br i1 false, label %cond_false37.i, label %cond_true.i11
+
+cond_true.i11: ; preds = %cond_true32
+ br i1 false, label %cond_true8.i, label %ov_info.exit
+
+cond_true8.i: ; preds = %cond_true.i11
+ br i1 false, label %cond_true44, label %cond_next48
+
+cond_false37.i: ; preds = %cond_true32
+ br label %ov_info.exit
+
+ov_info.exit: ; preds = %cond_false37.i, %cond_true.i11
+ br i1 false, label %cond_true44, label %cond_next48
+
+cond_true44: ; preds = %ov_info.exit, %cond_true8.i
+ br label %cond_next48
+
+cond_next48: ; preds = %cond_true44, %ov_info.exit, %cond_true8.i
+ br i1 false, label %cond_next53, label %return
+
+cond_next53: ; preds = %cond_next48
+ br i1 false, label %cond_true56, label %cond_false97
+
+cond_true56: ; preds = %cond_next53
+ br i1 false, label %bb85, label %cond_next304
+
+bb63: ; preds = %bb85
+ br i1 false, label %cond_next78, label %cond_false73
+
+cond_false73: ; preds = %bb63
+ br i1 false, label %cond_true76, label %cond_next78
+
+cond_true76: ; preds = %cond_false73
+ br label %cond_next78
+
+cond_next78: ; preds = %cond_true76, %cond_false73, %bb63
+ br label %bb85
+
+bb85: ; preds = %bb89, %cond_next78, %cond_true56
+ br i1 false, label %bb63, label %bb89
+
+bb89: ; preds = %bb85
+ br i1 false, label %bb85, label %cond_next304
+
+cond_false97: ; preds = %cond_next53
+ br i1 false, label %cond_true108, label %bb248
+
+cond_true108: ; preds = %cond_false97
+ br i1 false, label %bb196, label %bb149
+
+bb112: ; preds = %bb149, %bb146
+ br i1 false, label %bb119, label %bb146
+
+bb119: ; preds = %cond_next134, %bb112
+ br i1 false, label %cond_next134, label %cond_false129
+
+cond_false129: ; preds = %bb119
+ br i1 false, label %cond_true132, label %cond_next134
+
+cond_true132: ; preds = %cond_false129
+ br label %cond_next134
+
+cond_next134: ; preds = %cond_true132, %cond_false129, %bb119
+ br i1 false, label %bb119, label %bb146
+
+bb146: ; preds = %cond_next134, %bb112
+ br i1 false, label %bb112, label %cond_next304
+
+bb149: ; preds = %cond_true108
+ br i1 false, label %bb112, label %cond_next304
+
+bb155: ; preds = %bb196, %bb193
+ br i1 false, label %bb165, label %bb193
+
+bb165: ; preds = %cond_next180, %bb155
+ br i1 false, label %cond_next180, label %cond_false175
+
+cond_false175: ; preds = %bb165
+ br i1 false, label %cond_true178, label %cond_next180
+
+cond_true178: ; preds = %cond_false175
+ br label %cond_next180
+
+cond_next180: ; preds = %cond_true178, %cond_false175, %bb165
+ br i1 false, label %bb165, label %bb193
+
+bb193: ; preds = %cond_next180, %bb155
+ br i1 false, label %bb155, label %cond_next304
+
+bb196: ; preds = %cond_true108
+ br i1 false, label %bb155, label %cond_next304
+
+bb207: ; preds = %bb241
+ br i1 false, label %cond_next225, label %cond_false220
+
+cond_false220: ; preds = %bb207
+ br i1 false, label %cond_true223, label %cond_next225
+
+cond_true223: ; preds = %cond_false220
+ br label %cond_next225
+
+cond_next225: ; preds = %cond_true223, %cond_false220, %bb207
+ br label %bb241
+
+bb241: ; preds = %bb248, %bb245, %cond_next225
+ br i1 false, label %bb207, label %bb245
+
+bb245: ; preds = %bb241
+ br i1 false, label %bb241, label %cond_next304
+
+bb248: ; preds = %cond_false97
+ br i1 false, label %bb241, label %cond_next304
+
+bb256: ; preds = %bb290
+ br i1 false, label %cond_next274, label %cond_false269
+
+cond_false269: ; preds = %bb256
+ br i1 false, label %cond_true272, label %cond_next274
+
+cond_true272: ; preds = %cond_false269
+ br label %cond_next274
+
+cond_next274: ; preds = %cond_true272, %cond_false269, %bb256
+ br label %bb290
+
+bb290: ; preds = %bb294, %cond_next274
+ br i1 false, label %bb256, label %bb294
+
+bb294: ; preds = %bb290
+ br i1 false, label %bb290, label %cond_next304
+
+cond_next304: ; preds = %bb294, %bb248, %bb245, %bb196, %bb193, %bb149, %bb146, %bb89, %cond_true56
+ br i1 false, label %cond_next11.i, label %cond_true.i
+
+cond_true.i: ; preds = %cond_next304
+ br i1 false, label %vorbis_synthesis_read.exit, label %cond_next11.i
+
+cond_next11.i: ; preds = %cond_true.i, %cond_next304
+ br label %vorbis_synthesis_read.exit
+
+vorbis_synthesis_read.exit: ; preds = %cond_next11.i, %cond_true.i
+ br i1 false, label %cond_next321, label %cond_true316
+
+cond_true316: ; preds = %vorbis_synthesis_read.exit
+ ret void
+
+cond_next321: ; preds = %vorbis_synthesis_read.exit
+ ret void
+
+return: ; preds = %cond_next48, %bb29, %cond_next22, %cond_next15, %entry
+ ret void
+}
diff --git a/test/Analysis/Dominators/2007-07-11-SplitBlock.ll b/test/Analysis/Dominators/2007-07-11-SplitBlock.ll
new file mode 100644
index 000000000000..3dc6eda6de1d
--- /dev/null
+++ b/test/Analysis/Dominators/2007-07-11-SplitBlock.ll
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -loop-rotate -loop-unswitch -disable-output
+
+define i32 @stringSearch_Clib(i32 %count) {
+entry:
+ br i1 false, label %bb36, label %bb44
+
+cond_true20: ; preds = %bb36
+ %tmp33 = add i32 0, 0 ; <i32> [#uses=1]
+ br label %bb36
+
+bb36: ; preds = %cond_true20, %entry
+ %c.2 = phi i32 [ %tmp33, %cond_true20 ], [ 0, %entry ] ; <i32> [#uses=1]
+ br i1 false, label %cond_true20, label %bb41
+
+bb41: ; preds = %bb36
+ %c.2.lcssa = phi i32 [ %c.2, %bb36 ] ; <i32> [#uses=0]
+ ret i32 0
+
+bb44: ; preds = %entry
+ ret i32 0
+}
diff --git a/test/Analysis/Dominators/2007-07-12-SplitBlock.ll b/test/Analysis/Dominators/2007-07-12-SplitBlock.ll
new file mode 100644
index 000000000000..1748daf4f393
--- /dev/null
+++ b/test/Analysis/Dominators/2007-07-12-SplitBlock.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -loop-rotate -licm -loop-unswitch -disable-output
+
+define i32 @main(i32 %argc, i8** %argv) {
+entry:
+ br label %bb7
+
+bb7: ; preds = %bb7, %entry
+ %tmp54 = icmp slt i32 0, 2000000 ; <i1> [#uses=1]
+ br i1 %tmp54, label %bb7, label %bb56
+
+bb56: ; preds = %bb7
+ ret i32 0
+}
diff --git a/test/Analysis/Dominators/dg.exp b/test/Analysis/Dominators/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Analysis/Dominators/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll b/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll
new file mode 100644
index 000000000000..aba6082c62e5
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn | llvm-dis | grep call | count 2
+
+@g = internal global i32 0 ; <i32*> [#uses=2]
+
+define i32 @r() {
+ %tmp = load i32* @g ; <i32> [#uses=1]
+ ret i32 %tmp
+}
+
+define i32 @f() {
+entry:
+ %tmp = call i32 @e( ) ; <i32> [#uses=1]
+ store i32 %tmp, i32* @g
+ %tmp2 = call i32 @e( ) ; <i32> [#uses=1]
+ ret i32 %tmp2
+}
+
+declare i32 @e() readonly ; might call @r
diff --git a/test/Analysis/GlobalsModRef/aliastest.ll b/test/Analysis/GlobalsModRef/aliastest.ll
new file mode 100644
index 000000000000..5ea90fe9a3e6
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/aliastest.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn | llvm-dis | not grep load
+@X = internal global i32 4 ; <i32*> [#uses=1]
+
+define i32 @test(i32* %P) {
+ store i32 7, i32* %P
+ store i32 12, i32* @X
+ %V = load i32* %P ; <i32> [#uses=1]
+ ret i32 %V
+}
diff --git a/test/Analysis/GlobalsModRef/chaining-analysis.ll b/test/Analysis/GlobalsModRef/chaining-analysis.ll
new file mode 100644
index 000000000000..137b2c14d3dc
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/chaining-analysis.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn | llvm-dis | not grep load
+
+; This test requires the use of previous analyses to determine that
+; doesnotmodX does not modify X (because 'sin' doesn't).
+
+@X = internal global i32 4 ; <i32*> [#uses=2]
+
+declare double @sin(double) readnone
+
+define i32 @test(i32* %P) {
+ store i32 12, i32* @X
+ call double @doesnotmodX( double 1.000000e+00 ) ; <double>:1 [#uses=0]
+ %V = load i32* @X ; <i32> [#uses=1]
+ ret i32 %V
+}
+
+define double @doesnotmodX(double %V) {
+ %V2 = call double @sin( double %V ) readnone ; <double> [#uses=1]
+ ret double %V2
+}
diff --git a/test/Analysis/GlobalsModRef/dg.exp b/test/Analysis/GlobalsModRef/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Analysis/GlobalsModRef/indirect-global.ll b/test/Analysis/GlobalsModRef/indirect-global.ll
new file mode 100644
index 000000000000..ff5a0b9839d6
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/indirect-global.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn -instcombine | llvm-dis | \
+; RUN: grep {ret i32 0}
+
+@G = internal global i32* null ; <i32**> [#uses=3]
+
+define void @test() {
+ %A = malloc i32 ; <i32*> [#uses=1]
+ store i32* %A, i32** @G
+ ret void
+}
+
+define i32 @test1(i32* %P) {
+ %g1 = load i32** @G ; <i32*> [#uses=2]
+ %h1 = load i32* %g1 ; <i32> [#uses=1]
+ store i32 123, i32* %P
+ %g2 = load i32** @G ; <i32*> [#uses=0]
+ %h2 = load i32* %g1 ; <i32> [#uses=1]
+ %X = sub i32 %h1, %h2 ; <i32> [#uses=1]
+ ret i32 %X
+}
diff --git a/test/Analysis/GlobalsModRef/modreftest.ll b/test/Analysis/GlobalsModRef/modreftest.ll
new file mode 100644
index 000000000000..ffcb84defad8
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/modreftest.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn | llvm-dis | not grep load
+@X = internal global i32 4 ; <i32*> [#uses=2]
+
+define i32 @test(i32* %P) {
+ store i32 12, i32* @X
+ call void @doesnotmodX( )
+ %V = load i32* @X ; <i32> [#uses=1]
+ ret i32 %V
+}
+
+define void @doesnotmodX() {
+ ret void
+}
diff --git a/test/Analysis/GlobalsModRef/purecse.ll b/test/Analysis/GlobalsModRef/purecse.ll
new file mode 100644
index 000000000000..dc3f6adda143
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/purecse.ll
@@ -0,0 +1,23 @@
+; Test that pure functions are cse'd away
+; RUN: llvm-as < %s | opt -globalsmodref-aa -gvn -instcombine | \
+; RUN: llvm-dis | not grep sub
+
+define i32 @pure(i32 %X) {
+ %Y = add i32 %X, 1 ; <i32> [#uses=1]
+ ret i32 %Y
+}
+
+define i32 @test1(i32 %X) {
+ %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
+ %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
+ %C = sub i32 %A, %B ; <i32> [#uses=1]
+ ret i32 %C
+}
+
+define i32 @test2(i32 %X, i32* %P) {
+ %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
+ store i32 %X, i32* %P ;; Does not invalidate 'pure' call.
+ %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
+ %C = sub i32 %A, %B ; <i32> [#uses=1]
+ ret i32 %C
+}
diff --git a/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll b/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll
new file mode 100644
index 000000000000..34b9c4431810
--- /dev/null
+++ b/test/Analysis/LoopInfo/2003-05-15-NestingProblem.ll
@@ -0,0 +1,30 @@
+; This testcase was incorrectly computing that the loopentry.7 loop was
+; not a child of the loopentry.6 loop.
+;
+; RUN: llvm-as < %s | opt -analyze -loops | \
+; RUN: grep {^ Loop at depth 4 containing: %loopentry.7<header><latch><exit>}
+
+define void @getAndMoveToFrontDecode() {
+ br label %endif.2
+
+endif.2: ; preds = %loopexit.5, %0
+ br i1 false, label %loopentry.5, label %UnifiedExitNode
+
+loopentry.5: ; preds = %loopexit.6, %endif.2
+ br i1 false, label %loopentry.6, label %UnifiedExitNode
+
+loopentry.6: ; preds = %loopentry.7, %loopentry.5
+ br i1 false, label %loopentry.7, label %loopexit.6
+
+loopentry.7: ; preds = %loopentry.7, %loopentry.6
+ br i1 false, label %loopentry.7, label %loopentry.6
+
+loopexit.6: ; preds = %loopentry.6
+ br i1 false, label %loopentry.5, label %loopexit.5
+
+loopexit.5: ; preds = %loopexit.6
+ br i1 false, label %endif.2, label %UnifiedExitNode
+
+UnifiedExitNode: ; preds = %loopexit.5, %loopentry.5, %endif.2
+ ret void
+}
diff --git a/test/Analysis/LoopInfo/dg.exp b/test/Analysis/LoopInfo/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Analysis/LoopInfo/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Analysis/PostDominators/2006-09-26-PostDominanceFrontier.ll b/test/Analysis/PostDominators/2006-09-26-PostDominanceFrontier.ll
new file mode 100644
index 000000000000..b272f92499e5
--- /dev/null
+++ b/test/Analysis/PostDominators/2006-09-26-PostDominanceFrontier.ll
@@ -0,0 +1,97 @@
+; RUN: llvm-as < %s | opt -analyze -postdomfrontier \
+; RUN: -disable-verify
+; ModuleID = '2006-09-26-PostDominanceFrontier.bc'
+target datalayout = "e-p:64:64"
+target triple = "alphaev67-unknown-linux-gnu"
+ %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i32, [44 x i8] }
+ %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 }
+@TOP = external global i64* ; <i64**> [#uses=1]
+@BOT = external global i64* ; <i64**> [#uses=1]
+@str = external global [2 x i8] ; <[2 x i8]*> [#uses=0]
+
+declare void @fopen()
+
+define void @main(i8** %argv) {
+entry:
+ %netSelect.i507 = alloca i64, align 8 ; <i64*> [#uses=0]
+ %topStart.i = alloca i64, align 8 ; <i64*> [#uses=0]
+ %topEnd.i = alloca i64, align 8 ; <i64*> [#uses=0]
+ %botStart.i = alloca i64, align 8 ; <i64*> [#uses=0]
+ %botEnd.i = alloca i64, align 8 ; <i64*> [#uses=0]
+ %c1.i154 = alloca i32, align 4 ; <i32*> [#uses=0]
+ %b1.i155 = alloca i32, align 4 ; <i32*> [#uses=0]
+ %t1.i156 = alloca i32, align 4 ; <i32*> [#uses=0]
+ %c1.i = alloca i32, align 4 ; <i32*> [#uses=0]
+ %b1.i = alloca i32, align 4 ; <i32*> [#uses=0]
+ %t1.i = alloca i32, align 4 ; <i32*> [#uses=0]
+ %netSelect.i5 = alloca i64, align 8 ; <i64*> [#uses=0]
+ %netSelect.i = alloca i64, align 8 ; <i64*> [#uses=0]
+ %tmp2.i = getelementptr i8** %argv, i32 1 ; <i8**> [#uses=1]
+ %tmp3.i4 = load i8** %tmp2.i ; <i8*> [#uses=0]
+ call void @fopen( )
+ br i1 false, label %DimensionChannel.exit, label %bb.backedge.i
+
+bb.backedge.i: ; preds = %entry
+ ret void
+
+DimensionChannel.exit: ; preds = %entry
+ %tmp13.i137 = malloc i64, i32 0 ; <i64*> [#uses=1]
+ %tmp610.i = malloc i64, i32 0 ; <i64*> [#uses=1]
+ br label %cond_true.i143
+
+cond_true.i143: ; preds = %cond_true.i143, %DimensionChannel.exit
+ %tmp9.i140 = getelementptr i64* %tmp13.i137, i64 0 ; <i64*> [#uses=0]
+ %tmp12.i = getelementptr i64* %tmp610.i, i64 0 ; <i64*> [#uses=0]
+ br i1 false, label %bb18.i144, label %cond_true.i143
+
+bb18.i144: ; preds = %cond_true.i143
+ call void @fopen( )
+ %tmp76.i105 = malloc i64, i32 0 ; <i64*> [#uses=3]
+ %tmp674.i = malloc i64, i32 0 ; <i64*> [#uses=2]
+ %tmp1072.i = malloc i64, i32 0 ; <i64*> [#uses=2]
+ %tmp1470.i = malloc i64, i32 0 ; <i64*> [#uses=1]
+ br label %cond_true.i114
+
+cond_true.i114: ; preds = %cond_true.i114, %bb18.i144
+ %tmp17.i108 = getelementptr i64* %tmp76.i105, i64 0 ; <i64*> [#uses=0]
+ %tmp20.i = getelementptr i64* %tmp674.i, i64 0 ; <i64*> [#uses=0]
+ %tmp23.i111 = getelementptr i64* %tmp1470.i, i64 0 ; <i64*> [#uses=0]
+ br i1 false, label %cond_true40.i, label %cond_true.i114
+
+cond_true40.i: ; preds = %cond_true40.i, %cond_true.i114
+ %tmp33.i115 = getelementptr i64* %tmp1072.i, i64 0 ; <i64*> [#uses=0]
+ br i1 false, label %bb142.i, label %cond_true40.i
+
+cond_next54.i: ; preds = %cond_true76.i
+ %tmp57.i = getelementptr i64* %tmp55.i, i64 0 ; <i64*> [#uses=0]
+ br i1 false, label %bb64.i, label %bb69.i
+
+bb64.i: ; preds = %cond_true76.i, %cond_next54.i
+ %tmp67.i117 = getelementptr i64* %tmp76.i105, i64 0 ; <i64*> [#uses=0]
+ br i1 false, label %bb114.i, label %cond_true111.i
+
+bb69.i: ; preds = %cond_next54.i
+ br i1 false, label %bb79.i, label %cond_true76.i
+
+cond_true76.i: ; preds = %bb142.i, %bb69.i
+ %tmp48.i = getelementptr i64* %tmp46.i, i64 0 ; <i64*> [#uses=0]
+ br i1 false, label %bb64.i, label %cond_next54.i
+
+bb79.i: ; preds = %bb69.i
+ br i1 false, label %bb114.i, label %cond_true111.i
+
+cond_true111.i: ; preds = %bb79.i, %bb64.i
+ %tmp84.i127 = getelementptr i64* %tmp46.i, i64 0 ; <i64*> [#uses=0]
+ ret void
+
+bb114.i: ; preds = %bb142.i, %bb79.i, %bb64.i
+ %tmp117.i = getelementptr i64* %tmp76.i105, i64 0 ; <i64*> [#uses=0]
+ %tmp132.i131 = getelementptr i64* %tmp674.i, i64 0 ; <i64*> [#uses=0]
+ %tmp122.i = getelementptr i64* %tmp1072.i, i64 0 ; <i64*> [#uses=0]
+ ret void
+
+bb142.i: ; preds = %cond_true40.i
+ %tmp46.i = load i64** @BOT ; <i64*> [#uses=2]
+ %tmp55.i = load i64** @TOP ; <i64*> [#uses=1]
+ br i1 false, label %bb114.i, label %cond_true76.i
+}
diff --git a/test/Analysis/PostDominators/2007-04-17-PostDominanceFrontier.ll b/test/Analysis/PostDominators/2007-04-17-PostDominanceFrontier.ll
new file mode 100644
index 000000000000..51e4c2aeb553
--- /dev/null
+++ b/test/Analysis/PostDominators/2007-04-17-PostDominanceFrontier.ll
@@ -0,0 +1,692 @@
+; RUN: llvm-as < %s | opt -postdomfrontier -disable-output
+
+define void @SManager() {
+entry:
+ br label %bb.outer
+
+bb.outer: ; preds = %bb193, %entry
+ br label %bb.outer156
+
+bb.loopexit: ; preds = %bb442
+ br label %bb.outer156
+
+bb.outer156: ; preds = %bb.loopexit, %bb.outer
+ br label %bb
+
+bb: ; preds = %bb.backedge, %bb.outer156
+ br i1 false, label %cond_true, label %bb.cond_next_crit_edge
+
+bb.cond_next_crit_edge: ; preds = %bb
+ br label %cond_next
+
+cond_true: ; preds = %bb
+ br label %cond_next
+
+cond_next: ; preds = %cond_true, %bb.cond_next_crit_edge
+ br i1 false, label %cond_next.bb.backedge_crit_edge, label %cond_next107
+
+cond_next.bb.backedge_crit_edge: ; preds = %cond_next
+ br label %bb.backedge
+
+bb.backedge: ; preds = %cond_true112.bb.backedge_crit_edge, %cond_next.bb.backedge_crit_edge
+ br label %bb
+
+cond_next107: ; preds = %cond_next
+ br i1 false, label %cond_true112, label %cond_next197
+
+cond_true112: ; preds = %cond_next107
+ br i1 false, label %cond_true118, label %cond_true112.bb.backedge_crit_edge
+
+cond_true112.bb.backedge_crit_edge: ; preds = %cond_true112
+ br label %bb.backedge
+
+cond_true118: ; preds = %cond_true112
+ br i1 false, label %bb123.preheader, label %cond_true118.bb148_crit_edge
+
+cond_true118.bb148_crit_edge: ; preds = %cond_true118
+ br label %bb148
+
+bb123.preheader: ; preds = %cond_true118
+ br label %bb123
+
+bb123: ; preds = %bb142.bb123_crit_edge, %bb123.preheader
+ br i1 false, label %bb123.bb142_crit_edge, label %cond_next.i57
+
+bb123.bb142_crit_edge: ; preds = %bb123
+ br label %bb142
+
+cond_next.i57: ; preds = %bb123
+ br i1 false, label %cond_true135, label %cond_next.i57.bb142_crit_edge
+
+cond_next.i57.bb142_crit_edge: ; preds = %cond_next.i57
+ br label %bb142
+
+cond_true135: ; preds = %cond_next.i57
+ br label %bb142
+
+bb142: ; preds = %cond_true135, %cond_next.i57.bb142_crit_edge, %bb123.bb142_crit_edge
+ br i1 false, label %bb148.loopexit, label %bb142.bb123_crit_edge
+
+bb142.bb123_crit_edge: ; preds = %bb142
+ br label %bb123
+
+bb148.loopexit: ; preds = %bb142
+ br label %bb148
+
+bb148: ; preds = %bb148.loopexit, %cond_true118.bb148_crit_edge
+ br i1 false, label %bb151.preheader, label %bb148.bb177_crit_edge
+
+bb148.bb177_crit_edge: ; preds = %bb148
+ br label %bb177
+
+bb151.preheader: ; preds = %bb148
+ br label %bb151
+
+bb151: ; preds = %bb171.bb151_crit_edge, %bb151.preheader
+ br i1 false, label %bb151.bb171_crit_edge, label %cond_next.i49
+
+bb151.bb171_crit_edge: ; preds = %bb151
+ br label %bb171
+
+cond_next.i49: ; preds = %bb151
+ br i1 false, label %cond_true164, label %cond_next.i49.bb171_crit_edge
+
+cond_next.i49.bb171_crit_edge: ; preds = %cond_next.i49
+ br label %bb171
+
+cond_true164: ; preds = %cond_next.i49
+ br label %bb171
+
+bb171: ; preds = %cond_true164, %cond_next.i49.bb171_crit_edge, %bb151.bb171_crit_edge
+ br i1 false, label %bb177.loopexit, label %bb171.bb151_crit_edge
+
+bb171.bb151_crit_edge: ; preds = %bb171
+ br label %bb151
+
+bb177.loopexit: ; preds = %bb171
+ br label %bb177
+
+bb177: ; preds = %bb177.loopexit, %bb148.bb177_crit_edge
+ br i1 false, label %bb180.preheader, label %bb177.bb193_crit_edge
+
+bb177.bb193_crit_edge: ; preds = %bb177
+ br label %bb193
+
+bb180.preheader: ; preds = %bb177
+ br label %bb180
+
+bb180: ; preds = %bb180.bb180_crit_edge, %bb180.preheader
+ br i1 false, label %bb193.loopexit, label %bb180.bb180_crit_edge
+
+bb180.bb180_crit_edge: ; preds = %bb180
+ br label %bb180
+
+bb193.loopexit: ; preds = %bb180
+ br label %bb193
+
+bb193: ; preds = %bb193.loopexit, %bb177.bb193_crit_edge
+ br label %bb.outer
+
+cond_next197: ; preds = %cond_next107
+ br i1 false, label %cond_next210, label %cond_true205
+
+cond_true205: ; preds = %cond_next197
+ br i1 false, label %cond_true205.bb213_crit_edge, label %cond_true205.bb299_crit_edge
+
+cond_true205.bb299_crit_edge: ; preds = %cond_true205
+ br label %bb299
+
+cond_true205.bb213_crit_edge: ; preds = %cond_true205
+ br label %bb213
+
+cond_next210: ; preds = %cond_next197
+ br label %bb293
+
+bb213: ; preds = %bb293.bb213_crit_edge, %cond_true205.bb213_crit_edge
+ br i1 false, label %bb213.cond_next290_crit_edge, label %cond_true248
+
+bb213.cond_next290_crit_edge: ; preds = %bb213
+ br label %cond_next290
+
+cond_true248: ; preds = %bb213
+ br i1 false, label %cond_true248.cond_next290_crit_edge, label %cond_true255
+
+cond_true248.cond_next290_crit_edge: ; preds = %cond_true248
+ br label %cond_next290
+
+cond_true255: ; preds = %cond_true248
+ br i1 false, label %cond_true266, label %cond_true255.cond_next271_crit_edge
+
+cond_true255.cond_next271_crit_edge: ; preds = %cond_true255
+ br label %cond_next271
+
+cond_true266: ; preds = %cond_true255
+ br label %cond_next271
+
+cond_next271: ; preds = %cond_true266, %cond_true255.cond_next271_crit_edge
+ br label %cond_next290
+
+cond_next290: ; preds = %cond_next271, %cond_true248.cond_next290_crit_edge, %bb213.cond_next290_crit_edge
+ br label %bb293
+
+bb293: ; preds = %cond_next290, %cond_next210
+ br i1 false, label %bb293.bb213_crit_edge, label %bb293.bb299_crit_edge
+
+bb293.bb299_crit_edge: ; preds = %bb293
+ br label %bb299
+
+bb293.bb213_crit_edge: ; preds = %bb293
+ br label %bb213
+
+bb299: ; preds = %bb293.bb299_crit_edge, %cond_true205.bb299_crit_edge
+ br i1 false, label %bb302.preheader, label %bb299.bb390_crit_edge
+
+bb299.bb390_crit_edge: ; preds = %bb299
+ br label %bb390
+
+bb302.preheader: ; preds = %bb299
+ br label %bb302
+
+bb302: ; preds = %bb384.bb302_crit_edge, %bb302.preheader
+ br i1 false, label %bb302.bb384_crit_edge, label %cond_true339
+
+bb302.bb384_crit_edge: ; preds = %bb302
+ br label %bb384
+
+cond_true339: ; preds = %bb302
+ br i1 false, label %cond_true339.bb384_crit_edge, label %cond_true346
+
+cond_true339.bb384_crit_edge: ; preds = %cond_true339
+ br label %bb384
+
+cond_true346: ; preds = %cond_true339
+ br i1 false, label %cond_true357, label %cond_true346.cond_next361_crit_edge
+
+cond_true346.cond_next361_crit_edge: ; preds = %cond_true346
+ br label %cond_next361
+
+cond_true357: ; preds = %cond_true346
+ br label %cond_next361
+
+cond_next361: ; preds = %cond_true357, %cond_true346.cond_next361_crit_edge
+ br label %bb384
+
+bb384: ; preds = %cond_next361, %cond_true339.bb384_crit_edge, %bb302.bb384_crit_edge
+ br i1 false, label %bb390.loopexit, label %bb384.bb302_crit_edge
+
+bb384.bb302_crit_edge: ; preds = %bb384
+ br label %bb302
+
+bb390.loopexit: ; preds = %bb384
+ br label %bb390
+
+bb390: ; preds = %bb390.loopexit, %bb299.bb390_crit_edge
+ br i1 false, label %bb391.preheader, label %bb390.bb442.preheader_crit_edge
+
+bb390.bb442.preheader_crit_edge: ; preds = %bb390
+ br label %bb442.preheader
+
+bb391.preheader: ; preds = %bb390
+ br label %bb391
+
+bb391: ; preds = %bb413.bb391_crit_edge, %bb391.preheader
+ br i1 false, label %bb391.bb413_crit_edge, label %cond_next404
+
+bb391.bb413_crit_edge: ; preds = %bb391
+ br label %bb413
+
+cond_next404: ; preds = %bb391
+ br i1 false, label %cond_next404.HWrite.exit_crit_edge, label %cond_next.i13
+
+cond_next404.HWrite.exit_crit_edge: ; preds = %cond_next404
+ br label %HWrite.exit
+
+cond_next.i13: ; preds = %cond_next404
+ br i1 false, label %cond_next.i13.cond_next13.i_crit_edge, label %cond_true12.i
+
+cond_next.i13.cond_next13.i_crit_edge: ; preds = %cond_next.i13
+ br label %cond_next13.i
+
+cond_true12.i: ; preds = %cond_next.i13
+ br label %cond_next13.i
+
+cond_next13.i: ; preds = %cond_true12.i, %cond_next.i13.cond_next13.i_crit_edge
+ br i1 false, label %cond_next13.i.bb.i22_crit_edge, label %cond_next43.i
+
+cond_next13.i.bb.i22_crit_edge: ; preds = %cond_next13.i
+ br label %bb.i22
+
+cond_next43.i: ; preds = %cond_next13.i
+ br i1 false, label %cond_next43.i.bb.i22_crit_edge, label %bb60.i
+
+cond_next43.i.bb.i22_crit_edge: ; preds = %cond_next43.i
+ br label %bb.i22
+
+bb.i22: ; preds = %cond_next43.i.bb.i22_crit_edge, %cond_next13.i.bb.i22_crit_edge
+ br label %bb413
+
+bb60.i: ; preds = %cond_next43.i
+ br i1 false, label %bb60.i.HWrite.exit_crit_edge, label %cond_true81.i
+
+bb60.i.HWrite.exit_crit_edge: ; preds = %bb60.i
+ br label %HWrite.exit
+
+cond_true81.i: ; preds = %bb60.i
+ br label %bb413
+
+HWrite.exit: ; preds = %bb60.i.HWrite.exit_crit_edge, %cond_next404.HWrite.exit_crit_edge
+ br label %bb413
+
+bb413: ; preds = %HWrite.exit, %cond_true81.i, %bb.i22, %bb391.bb413_crit_edge
+ br i1 false, label %bb442.preheader.loopexit, label %bb413.bb391_crit_edge
+
+bb413.bb391_crit_edge: ; preds = %bb413
+ br label %bb391
+
+bb442.preheader.loopexit: ; preds = %bb413
+ br label %bb442.preheader
+
+bb442.preheader: ; preds = %bb442.preheader.loopexit, %bb390.bb442.preheader_crit_edge
+ br label %bb442.outer
+
+bb420: ; preds = %bb442
+ br i1 false, label %bb439.loopexit, label %cond_next433
+
+cond_next433: ; preds = %bb420
+ br i1 false, label %cond_next433.HRead.exit.loopexit_crit_edge, label %cond_next.i
+
+cond_next433.HRead.exit.loopexit_crit_edge: ; preds = %cond_next433
+ br label %HRead.exit.loopexit
+
+cond_next.i: ; preds = %cond_next433
+ br i1 false, label %cond_true9.i, label %cond_false223.i
+
+cond_true9.i: ; preds = %cond_next.i
+ switch i32 0, label %cond_false.i [
+ i32 1, label %cond_true9.i.cond_true15.i_crit_edge
+ i32 5, label %cond_true9.i.cond_true15.i_crit_edge9
+ ]
+
+cond_true9.i.cond_true15.i_crit_edge9: ; preds = %cond_true9.i
+ br label %cond_true15.i
+
+cond_true9.i.cond_true15.i_crit_edge: ; preds = %cond_true9.i
+ br label %cond_true15.i
+
+cond_true15.i: ; preds = %cond_true9.i.cond_true15.i_crit_edge, %cond_true9.i.cond_true15.i_crit_edge9
+ br i1 false, label %cond_true15.i.cond_true44.i_crit_edge, label %cond_true15.i.cond_false49.i_crit_edge
+
+cond_true15.i.cond_false49.i_crit_edge: ; preds = %cond_true15.i
+ br label %cond_false49.i
+
+cond_true15.i.cond_true44.i_crit_edge: ; preds = %cond_true15.i
+ br label %cond_true44.i
+
+cond_false.i: ; preds = %cond_true9.i
+ br i1 false, label %cond_false.i.cond_next39.i_crit_edge, label %cond_true30.i
+
+cond_false.i.cond_next39.i_crit_edge: ; preds = %cond_false.i
+ br label %cond_next39.i
+
+cond_true30.i: ; preds = %cond_false.i
+ br label %cond_next39.i
+
+cond_next39.i: ; preds = %cond_true30.i, %cond_false.i.cond_next39.i_crit_edge
+ br i1 false, label %cond_next39.i.cond_true44.i_crit_edge, label %cond_next39.i.cond_false49.i_crit_edge
+
+cond_next39.i.cond_false49.i_crit_edge: ; preds = %cond_next39.i
+ br label %cond_false49.i
+
+cond_next39.i.cond_true44.i_crit_edge: ; preds = %cond_next39.i
+ br label %cond_true44.i
+
+cond_true44.i: ; preds = %cond_next39.i.cond_true44.i_crit_edge, %cond_true15.i.cond_true44.i_crit_edge
+ br i1 false, label %cond_true44.i.cond_next70.i_crit_edge, label %cond_true44.i.cond_true61.i_crit_edge
+
+cond_true44.i.cond_true61.i_crit_edge: ; preds = %cond_true44.i
+ br label %cond_true61.i
+
+cond_true44.i.cond_next70.i_crit_edge: ; preds = %cond_true44.i
+ br label %cond_next70.i
+
+cond_false49.i: ; preds = %cond_next39.i.cond_false49.i_crit_edge, %cond_true15.i.cond_false49.i_crit_edge
+ br i1 false, label %cond_false49.i.cond_next70.i_crit_edge, label %cond_false49.i.cond_true61.i_crit_edge
+
+cond_false49.i.cond_true61.i_crit_edge: ; preds = %cond_false49.i
+ br label %cond_true61.i
+
+cond_false49.i.cond_next70.i_crit_edge: ; preds = %cond_false49.i
+ br label %cond_next70.i
+
+cond_true61.i: ; preds = %cond_false49.i.cond_true61.i_crit_edge, %cond_true44.i.cond_true61.i_crit_edge
+ br i1 false, label %cond_true61.i.cond_next70.i_crit_edge, label %cond_true67.i
+
+cond_true61.i.cond_next70.i_crit_edge: ; preds = %cond_true61.i
+ br label %cond_next70.i
+
+cond_true67.i: ; preds = %cond_true61.i
+ br label %cond_next70.i
+
+cond_next70.i: ; preds = %cond_true67.i, %cond_true61.i.cond_next70.i_crit_edge, %cond_false49.i.cond_next70.i_crit_edge, %cond_true44.i.cond_next70.i_crit_edge
+ br i1 false, label %cond_true77.i, label %cond_next81.i
+
+cond_true77.i: ; preds = %cond_next70.i
+ br label %bb442.outer.backedge
+
+cond_next81.i: ; preds = %cond_next70.i
+ br i1 false, label %cond_true87.i, label %cond_false94.i
+
+cond_true87.i: ; preds = %cond_next81.i
+ br i1 false, label %cond_true87.i.cond_true130.i_crit_edge, label %cond_true87.i.cond_next135.i_crit_edge
+
+cond_true87.i.cond_next135.i_crit_edge: ; preds = %cond_true87.i
+ br label %cond_next135.i
+
+cond_true87.i.cond_true130.i_crit_edge: ; preds = %cond_true87.i
+ br label %cond_true130.i
+
+cond_false94.i: ; preds = %cond_next81.i
+ switch i32 0, label %cond_false94.i.cond_next125.i_crit_edge [
+ i32 1, label %cond_false94.i.cond_true100.i_crit_edge
+ i32 5, label %cond_false94.i.cond_true100.i_crit_edge10
+ ]
+
+cond_false94.i.cond_true100.i_crit_edge10: ; preds = %cond_false94.i
+ br label %cond_true100.i
+
+cond_false94.i.cond_true100.i_crit_edge: ; preds = %cond_false94.i
+ br label %cond_true100.i
+
+cond_false94.i.cond_next125.i_crit_edge: ; preds = %cond_false94.i
+ br label %cond_next125.i
+
+cond_true100.i: ; preds = %cond_false94.i.cond_true100.i_crit_edge, %cond_false94.i.cond_true100.i_crit_edge10
+ br i1 false, label %cond_true107.i, label %cond_true100.i.cond_next109.i_crit_edge
+
+cond_true100.i.cond_next109.i_crit_edge: ; preds = %cond_true100.i
+ br label %cond_next109.i
+
+cond_true107.i: ; preds = %cond_true100.i
+ br label %cond_next109.i
+
+cond_next109.i: ; preds = %cond_true107.i, %cond_true100.i.cond_next109.i_crit_edge
+ br i1 false, label %cond_next109.i.cond_next125.i_crit_edge, label %cond_true116.i
+
+cond_next109.i.cond_next125.i_crit_edge: ; preds = %cond_next109.i
+ br label %cond_next125.i
+
+cond_true116.i: ; preds = %cond_next109.i
+ br label %cond_next125.i
+
+cond_next125.i: ; preds = %cond_true116.i, %cond_next109.i.cond_next125.i_crit_edge, %cond_false94.i.cond_next125.i_crit_edge
+ br i1 false, label %cond_next125.i.cond_true130.i_crit_edge, label %cond_next125.i.cond_next135.i_crit_edge
+
+cond_next125.i.cond_next135.i_crit_edge: ; preds = %cond_next125.i
+ br label %cond_next135.i
+
+cond_next125.i.cond_true130.i_crit_edge: ; preds = %cond_next125.i
+ br label %cond_true130.i
+
+cond_true130.i: ; preds = %cond_next125.i.cond_true130.i_crit_edge, %cond_true87.i.cond_true130.i_crit_edge
+ br label %cond_next135.i
+
+cond_next135.i: ; preds = %cond_true130.i, %cond_next125.i.cond_next135.i_crit_edge, %cond_true87.i.cond_next135.i_crit_edge
+ br i1 false, label %cond_true142.i, label %cond_next135.i.cond_next149.i_crit_edge
+
+cond_next135.i.cond_next149.i_crit_edge: ; preds = %cond_next135.i
+ br label %cond_next149.i
+
+cond_true142.i: ; preds = %cond_next135.i
+ br label %cond_next149.i
+
+cond_next149.i: ; preds = %cond_true142.i, %cond_next135.i.cond_next149.i_crit_edge
+ br i1 false, label %cond_true156.i, label %cond_next149.i.cond_next163.i_crit_edge
+
+cond_next149.i.cond_next163.i_crit_edge: ; preds = %cond_next149.i
+ br label %cond_next163.i
+
+cond_true156.i: ; preds = %cond_next149.i
+ br label %cond_next163.i
+
+cond_next163.i: ; preds = %cond_true156.i, %cond_next149.i.cond_next163.i_crit_edge
+ br i1 false, label %cond_true182.i, label %cond_next163.i.cond_next380.i_crit_edge
+
+cond_next163.i.cond_next380.i_crit_edge: ; preds = %cond_next163.i
+ br label %cond_next380.i
+
+cond_true182.i: ; preds = %cond_next163.i
+ br i1 false, label %cond_true182.i.cond_next380.i_crit_edge, label %cond_true196.i
+
+cond_true182.i.cond_next380.i_crit_edge: ; preds = %cond_true182.i
+ br label %cond_next380.i
+
+cond_true196.i: ; preds = %cond_true182.i
+ br i1 false, label %cond_true210.i, label %cond_true196.i.cond_next380.i_crit_edge
+
+cond_true196.i.cond_next380.i_crit_edge: ; preds = %cond_true196.i
+ br label %cond_next380.i
+
+cond_true210.i: ; preds = %cond_true196.i
+ br i1 false, label %cond_true216.i, label %cond_true210.i.cond_next380.i_crit_edge
+
+cond_true210.i.cond_next380.i_crit_edge: ; preds = %cond_true210.i
+ br label %cond_next380.i
+
+cond_true216.i: ; preds = %cond_true210.i
+ br label %cond_next380.i
+
+cond_false223.i: ; preds = %cond_next.i
+ br i1 false, label %cond_true229.i, label %cond_false355.i
+
+cond_true229.i: ; preds = %cond_false223.i
+ br i1 false, label %cond_true229.i.HRead.exit.loopexit_crit_edge, label %cond_next243.i
+
+cond_true229.i.HRead.exit.loopexit_crit_edge: ; preds = %cond_true229.i
+ br label %HRead.exit.loopexit
+
+cond_next243.i: ; preds = %cond_true229.i
+ br i1 false, label %cond_true248.i, label %cond_false255.i
+
+cond_true248.i: ; preds = %cond_next243.i
+ br label %cond_next260.i
+
+cond_false255.i: ; preds = %cond_next243.i
+ br label %cond_next260.i
+
+cond_next260.i: ; preds = %cond_false255.i, %cond_true248.i
+ br i1 false, label %cond_true267.i, label %cond_next273.i
+
+cond_true267.i: ; preds = %cond_next260.i
+ br label %bb442.backedge
+
+bb442.backedge: ; preds = %bb.i, %cond_true267.i
+ br label %bb442
+
+cond_next273.i: ; preds = %cond_next260.i
+ br i1 false, label %cond_true281.i, label %cond_next273.i.cond_next288.i_crit_edge
+
+cond_next273.i.cond_next288.i_crit_edge: ; preds = %cond_next273.i
+ br label %cond_next288.i
+
+cond_true281.i: ; preds = %cond_next273.i
+ br label %cond_next288.i
+
+cond_next288.i: ; preds = %cond_true281.i, %cond_next273.i.cond_next288.i_crit_edge
+ br i1 false, label %cond_true295.i, label %cond_next288.i.cond_next302.i_crit_edge
+
+cond_next288.i.cond_next302.i_crit_edge: ; preds = %cond_next288.i
+ br label %cond_next302.i
+
+cond_true295.i: ; preds = %cond_next288.i
+ br label %cond_next302.i
+
+cond_next302.i: ; preds = %cond_true295.i, %cond_next288.i.cond_next302.i_crit_edge
+ br i1 false, label %cond_next302.i.cond_next380.i_crit_edge, label %cond_true328.i
+
+cond_next302.i.cond_next380.i_crit_edge: ; preds = %cond_next302.i
+ br label %cond_next380.i
+
+cond_true328.i: ; preds = %cond_next302.i
+ br i1 false, label %cond_true343.i, label %cond_true328.i.cond_next380.i_crit_edge
+
+cond_true328.i.cond_next380.i_crit_edge: ; preds = %cond_true328.i
+ br label %cond_next380.i
+
+cond_true343.i: ; preds = %cond_true328.i
+ br i1 false, label %cond_true349.i, label %cond_true343.i.cond_next380.i_crit_edge
+
+cond_true343.i.cond_next380.i_crit_edge: ; preds = %cond_true343.i
+ br label %cond_next380.i
+
+cond_true349.i: ; preds = %cond_true343.i
+ br label %cond_next380.i
+
+cond_false355.i: ; preds = %cond_false223.i
+ br i1 false, label %cond_false355.i.bb.i_crit_edge, label %cond_next363.i
+
+cond_false355.i.bb.i_crit_edge: ; preds = %cond_false355.i
+ br label %bb.i
+
+cond_next363.i: ; preds = %cond_false355.i
+ br i1 false, label %bb377.i, label %cond_next363.i.bb.i_crit_edge
+
+cond_next363.i.bb.i_crit_edge: ; preds = %cond_next363.i
+ br label %bb.i
+
+bb.i: ; preds = %cond_next363.i.bb.i_crit_edge, %cond_false355.i.bb.i_crit_edge
+ br label %bb442.backedge
+
+bb377.i: ; preds = %cond_next363.i
+ br label %cond_next380.i
+
+cond_next380.i: ; preds = %bb377.i, %cond_true349.i, %cond_true343.i.cond_next380.i_crit_edge, %cond_true328.i.cond_next380.i_crit_edge, %cond_next302.i.cond_next380.i_crit_edge, %cond_true216.i, %cond_true210.i.cond_next380.i_crit_edge, %cond_true196.i.cond_next380.i_crit_edge, %cond_true182.i.cond_next380.i_crit_edge, %cond_next163.i.cond_next380.i_crit_edge
+ br i1 false, label %cond_next380.i.HRead.exit_crit_edge, label %cond_true391.i
+
+cond_next380.i.HRead.exit_crit_edge: ; preds = %cond_next380.i
+ br label %HRead.exit
+
+cond_true391.i: ; preds = %cond_next380.i
+ br label %bb442.outer.backedge
+
+bb442.outer.backedge: ; preds = %bb439, %cond_true391.i, %cond_true77.i
+ br label %bb442.outer
+
+HRead.exit.loopexit: ; preds = %cond_true229.i.HRead.exit.loopexit_crit_edge, %cond_next433.HRead.exit.loopexit_crit_edge
+ br label %HRead.exit
+
+HRead.exit: ; preds = %HRead.exit.loopexit, %cond_next380.i.HRead.exit_crit_edge
+ br label %bb439
+
+bb439.loopexit: ; preds = %bb420
+ br label %bb439
+
+bb439: ; preds = %bb439.loopexit, %HRead.exit
+ br label %bb442.outer.backedge
+
+bb442.outer: ; preds = %bb442.outer.backedge, %bb442.preheader
+ br label %bb442
+
+bb442: ; preds = %bb442.outer, %bb442.backedge
+ br i1 false, label %bb420, label %bb.loopexit
+}
+
+define void @Invalidate() {
+entry:
+ br i1 false, label %cond_false, label %cond_true
+
+cond_true: ; preds = %entry
+ br i1 false, label %cond_true40, label %cond_true.cond_next_crit_edge
+
+cond_true.cond_next_crit_edge: ; preds = %cond_true
+ br label %cond_next
+
+cond_true40: ; preds = %cond_true
+ br label %cond_next
+
+cond_next: ; preds = %cond_true40, %cond_true.cond_next_crit_edge
+ br i1 false, label %cond_true68, label %cond_next.cond_next73_crit_edge
+
+cond_next.cond_next73_crit_edge: ; preds = %cond_next
+ br label %cond_next73
+
+cond_true68: ; preds = %cond_next
+ br label %cond_next73
+
+cond_next73: ; preds = %cond_true68, %cond_next.cond_next73_crit_edge
+ br i1 false, label %cond_true91, label %cond_next73.cond_next96_crit_edge
+
+cond_next73.cond_next96_crit_edge: ; preds = %cond_next73
+ br label %cond_next96
+
+cond_true91: ; preds = %cond_next73
+ br label %cond_next96
+
+cond_next96: ; preds = %cond_true91, %cond_next73.cond_next96_crit_edge
+ br i1 false, label %cond_next96.cond_next112_crit_edge, label %cond_true105
+
+cond_next96.cond_next112_crit_edge: ; preds = %cond_next96
+ br label %cond_next112
+
+cond_true105: ; preds = %cond_next96
+ br label %cond_next112
+
+cond_next112: ; preds = %cond_true105, %cond_next96.cond_next112_crit_edge
+ br i1 false, label %cond_next112.cond_next127_crit_edge, label %cond_true119
+
+cond_next112.cond_next127_crit_edge: ; preds = %cond_next112
+ br label %cond_next127
+
+cond_true119: ; preds = %cond_next112
+ br label %cond_next127
+
+cond_next127: ; preds = %cond_true119, %cond_next112.cond_next127_crit_edge
+ br i1 false, label %cond_next141, label %cond_true134
+
+cond_true134: ; preds = %cond_next127
+ br i1 false, label %cond_true134.bb161_crit_edge, label %cond_true134.bb_crit_edge
+
+cond_true134.bb_crit_edge: ; preds = %cond_true134
+ br label %bb
+
+cond_true134.bb161_crit_edge: ; preds = %cond_true134
+ br label %bb161
+
+cond_next141: ; preds = %cond_next127
+ br label %bb154
+
+bb: ; preds = %bb154.bb_crit_edge, %cond_true134.bb_crit_edge
+ br label %bb154
+
+bb154: ; preds = %bb, %cond_next141
+ br i1 false, label %bb154.bb161_crit_edge, label %bb154.bb_crit_edge
+
+bb154.bb_crit_edge: ; preds = %bb154
+ br label %bb
+
+bb154.bb161_crit_edge: ; preds = %bb154
+ br label %bb161
+
+bb161: ; preds = %bb154.bb161_crit_edge, %cond_true134.bb161_crit_edge
+ br i1 false, label %bb161.cond_next201_crit_edge, label %cond_true198
+
+bb161.cond_next201_crit_edge: ; preds = %bb161
+ br label %cond_next201
+
+cond_true198: ; preds = %bb161
+ br label %cond_next201
+
+cond_next201: ; preds = %cond_true198, %bb161.cond_next201_crit_edge
+ br i1 false, label %cond_next212, label %cond_true206
+
+cond_true206: ; preds = %cond_next201
+ br label %UnifiedReturnBlock
+
+cond_false: ; preds = %entry
+ br label %UnifiedReturnBlock
+
+cond_next212: ; preds = %cond_next201
+ br label %UnifiedReturnBlock
+
+UnifiedReturnBlock: ; preds = %cond_next212, %cond_false, %cond_true206
+ ret void
+}
diff --git a/test/Analysis/PostDominators/2007-04-20-PostDom-Reset.ll b/test/Analysis/PostDominators/2007-04-20-PostDom-Reset.ll
new file mode 100644
index 000000000000..4deec98a9ee8
--- /dev/null
+++ b/test/Analysis/PostDominators/2007-04-20-PostDom-Reset.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | opt -postdomfrontier -disable-output
+
+define void @args_out_of_range() {
+entry:
+ br label %bb
+
+bb: ; preds = %bb, %entry
+ br label %bb
+}
+
+define void @args_out_of_range_3() {
+entry:
+ br label %bb
+
+bb: ; preds = %bb, %entry
+ br label %bb
+}
+
+define void @Feq() {
+entry:
+ br i1 false, label %cond_true, label %cond_next
+
+cond_true: ; preds = %entry
+ unreachable
+
+cond_next: ; preds = %entry
+ unreachable
+}
diff --git a/test/Analysis/PostDominators/dg.exp b/test/Analysis/PostDominators/dg.exp
new file mode 100644
index 000000000000..f2005891a59a
--- /dev/null
+++ b/test/Analysis/PostDominators/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
diff --git a/test/Analysis/PostDominators/pr1098.ll b/test/Analysis/PostDominators/pr1098.ll
new file mode 100644
index 000000000000..b54a9fe1c75b
--- /dev/null
+++ b/test/Analysis/PostDominators/pr1098.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -postdomtree -analyze | grep entry
+; PR932
+
+define void @foo(i1 %x) {
+entry:
+ br i1 %x, label %bb1, label %bb0
+bb0: ; preds = %entry, bb0
+ br label %bb0
+bb1: ; preds = %entry
+ br label %bb2
+bb2: ; preds = %bb1
+ ret void
+}
+
diff --git a/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll b/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll
new file mode 100644
index 000000000000..a2cbcee244bf
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep {Loop bb: backedge-taken count is 100}
+; PR1533
+
+@array = weak global [101 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=1]
+
+define void @loop(i32 %x) {
+entry:
+ br label %bb
+
+bb: ; preds = %bb, %entry
+ %i.01.0 = phi i32 [ 100, %entry ], [ %tmp4, %bb ] ; <i32> [#uses=2]
+ %tmp1 = getelementptr [101 x i32]* @array, i32 0, i32 %i.01.0 ; <i32*> [#uses=1]
+ store i32 %x, i32* %tmp1
+ %tmp4 = add i32 %i.01.0, -1 ; <i32> [#uses=2]
+ %tmp7 = icmp sgt i32 %tmp4, -1 ; <i1> [#uses=1]
+ br i1 %tmp7, label %bb, label %return
+
+return: ; preds = %bb
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll b/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll
new file mode 100644
index 000000000000..e3393d5eed62
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2007-08-06-MisinterpretBranch.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | grep "icmp s"
+; PR1598
+
+define i32 @f(i32 %a, i32 %b, i32 %x, i32 %y) {
+entry:
+ %tmp3 = icmp eq i32 %a, %b ; <i1> [#uses=1]
+ br i1 %tmp3, label %return, label %bb
+
+bb: ; preds = %bb, %entry
+ %x_addr.0 = phi i32 [ %tmp6, %bb ], [ %x, %entry ] ; <i32> [#uses=1]
+ %tmp6 = add i32 %x_addr.0, 1 ; <i32> [#uses=3]
+ %tmp9 = icmp slt i32 %tmp6, %y ; <i1> [#uses=1]
+ br i1 %tmp9, label %bb, label %return
+
+return: ; preds = %bb, %entry
+ %x_addr.1 = phi i32 [ %x, %entry ], [ %tmp6, %bb ] ; <i32> [#uses=1]
+ ret i32 %x_addr.1
+}
diff --git a/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll b/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
new file mode 100644
index 000000000000..34d97664ccb6
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop bb: backedge-taken count is (-1 + (-1 \\* %x) + %y)}
+; PR1597
+
+define i32 @f(i32 %x, i32 %y) {
+entry:
+ %tmp63 = icmp ult i32 %x, %y ; <i1> [#uses=1]
+ br i1 %tmp63, label %bb.preheader, label %bb8
+
+bb.preheader: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb3, %bb.preheader
+ %x_addr.0 = phi i32 [ %tmp2, %bb3 ], [ %x, %bb.preheader ] ; <i32> [#uses=1]
+ %tmp2 = add i32 %x_addr.0, 1 ; <i32> [#uses=3]
+ br label %bb3
+
+bb3: ; preds = %bb
+ %tmp6 = icmp ult i32 %tmp2, %y ; <i1> [#uses=1]
+ br i1 %tmp6, label %bb, label %bb8.loopexit
+
+bb8.loopexit: ; preds = %bb3
+ br label %bb8
+
+bb8: ; preds = %bb8.loopexit, %entry
+ %x_addr.1 = phi i32 [ %x, %entry ], [ %tmp2, %bb8.loopexit ] ; <i32> [#uses=1]
+ br label %return
+
+return: ; preds = %bb8
+ ret i32 %x_addr.1
+}
diff --git a/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll b/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll
new file mode 100644
index 000000000000..c4de09375598
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 13}
+; PR1706
+
+define i32 @f() {
+entry:
+ br label %bb5
+
+bb: ; preds = %bb5
+ %tmp2 = shl i32 %j.0, 1 ; <i32> [#uses=1]
+ %tmp4 = add i32 %i.0, 268435456 ; <i32> [#uses=1]
+ br label %bb5
+
+bb5: ; preds = %bb, %entry
+ %j.0 = phi i32 [ 1, %entry ], [ %tmp2, %bb ] ; <i32> [#uses=2]
+ %i.0 = phi i32 [ -1879048192, %entry ], [ %tmp4, %bb ] ; <i32> [#uses=2]
+ %tmp7 = icmp slt i32 %i.0, 1610612736 ; <i1> [#uses=1]
+ br i1 %tmp7, label %bb, label %return
+
+return: ; preds = %bb5
+ ret i32 %j.0
+}
diff --git a/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll b/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll
new file mode 100644
index 000000000000..66ca7551c240
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2007-11-14-SignedAddRec.ll
@@ -0,0 +1,24 @@
+; RUN: llvm-as < %s | opt -indvars | llvm-dis | grep printd | grep 1206807378
+; PR1798
+
+declare void @printd(i32)
+
+define i32 @test() {
+entry:
+ br label %bb6
+
+bb: ; preds = %bb6
+ %tmp3 = add i32 %x.0, %i.0 ; <i32> [#uses=1]
+ %tmp5 = add i32 %i.0, 1 ; <i32> [#uses=1]
+ br label %bb6
+
+bb6: ; preds = %bb, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %tmp5, %bb ] ; <i32> [#uses=3]
+ %x.0 = phi i32 [ 0, %entry ], [ %tmp3, %bb ] ; <i32> [#uses=3]
+ %tmp8 = icmp slt i32 %i.0, 123456789 ; <i1> [#uses=1]
+ br i1 %tmp8, label %bb, label %bb10
+
+bb10: ; preds = %bb6
+ call void @printd(i32 %x.0)
+ ret i32 0
+}
diff --git a/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll b/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll
new file mode 100644
index 000000000000..82d6ee27b457
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep -e {--> %b}
+; PR1810
+
+define void @fun() {
+entry:
+ br label %header
+header:
+ %i = phi i32 [ 1, %entry ], [ %i.next, %body ]
+ %cond = icmp eq i32 %i, 10
+ br i1 %cond, label %exit, label %body
+body:
+ %a = mul i32 %i, 5
+ %b = or i32 %a, 1
+ %i.next = add i32 %i, 1
+ br label %header
+exit:
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll b/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll
new file mode 100644
index 000000000000..182a0876e658
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop header: backedge-taken count is (0 smax %n)}
+
+define void @foo(i32 %n) {
+entry:
+ br label %header
+header:
+ %i = phi i32 [ 0, %entry ], [ %i.inc, %next ]
+ %cond = icmp sgt i32 %n, %i
+ br i1 %cond, label %next, label %return
+next:
+ %i.inc = add i32 %i, 1
+ br label %header
+return:
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll b/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll
new file mode 100644
index 000000000000..cd3a80f79194
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll
@@ -0,0 +1,16 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop loop: backedge-taken count is (100 + (-100 smax %n))}
+; PR2002
+
+define void @foo(i8 %n) {
+entry:
+ br label %loop
+loop:
+ %i = phi i8 [ -100, %entry ], [ %i.inc, %next ]
+ %cond = icmp slt i8 %i, %n
+ br i1 %cond, label %next, label %return
+next:
+ %i.inc = add i8 %i, 1
+ br label %loop
+return:
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll b/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll
new file mode 100644
index 000000000000..0f977f804eb8
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep umax
+; PR2003
+
+define i32 @foo(i32 %n) {
+entry:
+ br label %header
+header:
+ %i = phi i32 [ 100, %entry ], [ %i.inc, %next ]
+ %cond = icmp ult i32 %i, %n
+ br i1 %cond, label %next, label %return
+next:
+ %i.inc = add i32 %i, 1
+ br label %header
+return:
+ ret i32 %i
+}
+
diff --git a/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll b/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll
new file mode 100644
index 000000000000..13852d45652a
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 61}
+; PR2364
+
+define i32 @func_6() nounwind {
+entry:
+ br label %bb5
+
+bb: ; preds = %bb5
+ %tmp2 = add i32 %i.0, 1 ; <i32> [#uses=1]
+ %tmp4 = add i8 %x.0, -4 ; <i8> [#uses=1]
+ br label %bb5
+
+bb5: ; preds = %bb, %entry
+ %x.0 = phi i8 [ 0, %entry ], [ %tmp4, %bb ] ; <i8> [#uses=2]
+ %i.0 = phi i32 [ 0, %entry ], [ %tmp2, %bb ] ; <i32> [#uses=2]
+ %tmp7 = icmp eq i8 %x.0, 12 ; <i1> [#uses=1]
+ br i1 %tmp7, label %return, label %bb
+
+return: ; preds = %bb5
+ ret i32 %i.0
+}
diff --git a/test/Analysis/ScalarEvolution/2008-06-12-BinomialInt64.ll b/test/Analysis/ScalarEvolution/2008-06-12-BinomialInt64.ll
new file mode 100644
index 000000000000..cbe5c97905ce
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-06-12-BinomialInt64.ll
@@ -0,0 +1,43 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution 2>/dev/null
+; PR2433
+
+define i32 @main1(i32 %argc, i8** %argv) nounwind {
+entry:
+ br i1 false, label %bb10, label %bb23
+
+bb10: ; preds = %bb10, %entry
+ %accum.03 = phi i64 [ %tmp14, %bb10 ], [ 0, %entry ] ; <i64> [#uses=1]
+ %i.02 = phi i32 [ %tmp16, %bb10 ], [ 0, %entry ] ; <i32> [#uses=1]
+ %d.1.01 = phi i64 [ %tmp5.i, %bb10 ], [ 0, %entry ] ; <i64> [#uses=1]
+ %tmp5.i = add i64 %d.1.01, 1 ; <i64> [#uses=2]
+ %tmp14 = add i64 %accum.03, %tmp5.i ; <i64> [#uses=2]
+ %tmp16 = add i32 %i.02, 1 ; <i32> [#uses=2]
+ %tmp20 = icmp slt i32 %tmp16, 0 ; <i1> [#uses=1]
+ br i1 %tmp20, label %bb10, label %bb23
+
+bb23: ; preds = %bb10, %entry
+ %accum.0.lcssa = phi i64 [ 0, %entry ], [ %tmp14, %bb10 ] ; <i64> [#uses=0]
+ ret i32 0
+}
+
+define i32 @main2(i32 %argc, i8** %argv) {
+entry:
+ %tmp8 = tail call i32 @atoi( i8* null ) nounwind readonly ; <i32> [#uses=1]
+ br i1 false, label %bb9, label %bb21
+
+bb9: ; preds = %bb9, %entry
+ %accum.03 = phi i64 [ %tmp12, %bb9 ], [ 0, %entry ] ; <i64> [#uses=1]
+ %i.02 = phi i32 [ %tmp14, %bb9 ], [ 0, %entry ] ; <i32> [#uses=1]
+ %d.1.01 = phi i64 [ %tmp4.i, %bb9 ], [ 0, %entry ] ; <i64> [#uses=1]
+ %tmp4.i = add i64 %d.1.01, 1 ; <i64> [#uses=2]
+ %tmp12 = add i64 %accum.03, %tmp4.i ; <i64> [#uses=2]
+ %tmp14 = add i32 %i.02, 1 ; <i32> [#uses=2]
+ %tmp18 = icmp slt i32 %tmp14, %tmp8 ; <i1> [#uses=1]
+ br i1 %tmp18, label %bb9, label %bb21
+
+bb21: ; preds = %bb9, %entry
+ %accum.0.lcssa = phi i64 [ 0, %entry ], [ %tmp12, %bb9 ] ; <i64> [#uses=0]
+ ret i32 0
+}
+
+declare i32 @atoi(i8*) nounwind readonly
diff --git a/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll
new file mode 100644
index 000000000000..a0fcad713149
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll
@@ -0,0 +1,36 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& not grep smax
+; PR2261
+
+@lut = common global [256 x i8] zeroinitializer, align 32 ; <[256 x i8]*> [#uses=1]
+
+define void @foo(i32 %count, i32* %srcptr, i32* %dstptr) nounwind {
+entry:
+ icmp sgt i32 %count, 0 ; <i1>:0 [#uses=1]
+ br i1 %0, label %bb.nph, label %return
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb1, %bb.nph
+ %j.01 = phi i32 [ %8, %bb1 ], [ 0, %bb.nph ] ; <i32> [#uses=1]
+ load i32* %srcptr, align 4 ; <i32>:1 [#uses=2]
+ and i32 %1, 255 ; <i32>:2 [#uses=1]
+ and i32 %1, -256 ; <i32>:3 [#uses=1]
+ getelementptr [256 x i8]* @lut, i32 0, i32 %2 ; <i8*>:4 [#uses=1]
+ load i8* %4, align 1 ; <i8>:5 [#uses=1]
+ zext i8 %5 to i32 ; <i32>:6 [#uses=1]
+ or i32 %6, %3 ; <i32>:7 [#uses=1]
+ store i32 %7, i32* %dstptr, align 4
+ add i32 %j.01, 1 ; <i32>:8 [#uses=2]
+ br label %bb1
+
+bb1: ; preds = %bb
+ icmp slt i32 %8, %count ; <i1>:9 [#uses=1]
+ br i1 %9, label %bb, label %bb1.return_crit_edge
+
+bb1.return_crit_edge: ; preds = %bb1
+ br label %return
+
+return: ; preds = %bb1.return_crit_edge, %entry
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll
new file mode 100644
index 000000000000..5501ee28869e
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& not grep smax
+; PR2070
+
+define i32 @a(i32 %x) nounwind {
+entry:
+ icmp sgt i32 %x, 1 ; <i1>:0 [#uses=1]
+ br i1 %0, label %bb.nph, label %bb2
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb1, %bb.nph
+ %z.02 = phi i32 [ %1, %bb1 ], [ 1, %bb.nph ] ; <i32> [#uses=1]
+ %i.01 = phi i32 [ %2, %bb1 ], [ 1, %bb.nph ] ; <i32> [#uses=2]
+ mul i32 %z.02, %i.01 ; <i32>:1 [#uses=2]
+ add i32 %i.01, 1 ; <i32>:2 [#uses=2]
+ br label %bb1
+
+bb1: ; preds = %bb
+ icmp slt i32 %2, %x ; <i1>:3 [#uses=1]
+ br i1 %3, label %bb, label %bb1.bb2_crit_edge
+
+bb1.bb2_crit_edge: ; preds = %bb1
+ %.lcssa = phi i32 [ %1, %bb1 ] ; <i32> [#uses=1]
+ br label %bb2
+
+bb2: ; preds = %bb1.bb2_crit_edge, %entry
+ %z.0.lcssa = phi i32 [ %.lcssa, %bb1.bb2_crit_edge ], [ 1, %entry ] ; <i32> [#uses=1]
+ ret i32 %z.0.lcssa
+}
diff --git a/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll b/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll
new file mode 100644
index 000000000000..a3cc600053f4
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep Unpredictable
+; PR2088
+
+define void @fun() {
+entry:
+ br label %loop
+loop:
+ %i = phi i8 [ 0, %entry ], [ %i.next, %loop ]
+ %i.next = add i8 %i, 4
+ %cond = icmp ne i8 %i.next, 6
+ br i1 %cond, label %loop, label %exit
+exit:
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll b/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll
new file mode 100644
index 000000000000..9ba118c15063
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 113}
+; PR2088
+
+define void @fun() {
+entry:
+ br label %loop
+loop:
+ %i = phi i8 [ 0, %entry ], [ %i.next, %loop ]
+ %i.next = add i8 %i, 18
+ %cond = icmp ne i8 %i.next, 4
+ br i1 %cond, label %loop, label %exit
+exit:
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-07-29-SGTTripCount.ll b/test/Analysis/ScalarEvolution/2008-07-29-SGTTripCount.ll
new file mode 100644
index 000000000000..527b8b0add23
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-07-29-SGTTripCount.ll
@@ -0,0 +1,27 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
+; RUN: -scalar-evolution-max-iterations=0 | \
+; RUN: grep -F "backedge-taken count is (-1 + (-1 * %j))"
+; PR2607
+
+define i32 @_Z1aj(i32 %j) nounwind {
+entry:
+ icmp sgt i32 0, %j ; <i1>:0 [#uses=1]
+ br i1 %0, label %bb.preheader, label %return
+
+bb.preheader: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb, %bb.preheader
+ %i.01 = phi i32 [ %1, %bb ], [ 0, %bb.preheader ] ; <i32> [#uses=1]
+ add i32 %i.01, -1 ; <i32>:1 [#uses=3]
+ icmp sgt i32 %1, %j ; <i1>:2 [#uses=1]
+ br i1 %2, label %bb, label %return.loopexit
+
+return.loopexit: ; preds = %bb
+ br label %return
+
+return: ; preds = %return.loopexit, %entry
+ %i.0.lcssa = phi i32 [ 0, %entry ], [ %1, %return.loopexit ] ; <i32> [#uses=1]
+ ret i32 %i.0.lcssa
+}
+
diff --git a/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll b/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll
new file mode 100644
index 000000000000..9051dc7ec515
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll
@@ -0,0 +1,24 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
+; RUN: -scalar-evolution-max-iterations=0 | \
+; RUN: grep -F "backedge-taken count is (-2147483632 + ((-1 + (-1 * %x)) smax (-1 + (-1 * %y))))"
+; PR2607
+
+define i32 @b(i32 %x, i32 %y) nounwind {
+entry:
+ %cmp2 = icmp slt i32 %y, %x
+ %cond3 = select i1 %cmp2, i32 %y, i32 %x
+ %cmp54 = icmp slt i32 %cond3, -2147483632
+ br i1 %cmp54, label %forinc, label %afterfor
+
+forinc: ; preds = %forinc, %entry
+ %j.01 = phi i32 [ %dec, %forinc ], [ -2147483632, %entry ]
+ %dec = add i32 %j.01, -1
+ %cmp = icmp slt i32 %y, %x
+ %cond = select i1 %cmp, i32 %y, i32 %x
+ %cmp5 = icmp sgt i32 %dec, %cond
+ br i1 %cmp5, label %forinc, label %afterfor
+
+afterfor: ; preds = %forinc, %entry
+ %j.0.lcssa = phi i32 [ -2147483632, %entry ], [ %dec, %forinc ]
+ ret i32 %j.0.lcssa
+}
diff --git a/test/Analysis/ScalarEvolution/2008-08-04-IVOverflow.ll b/test/Analysis/ScalarEvolution/2008-08-04-IVOverflow.ll
new file mode 100644
index 000000000000..f8e1cfcd7fbe
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-08-04-IVOverflow.ll
@@ -0,0 +1,25 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
+; RUN: -scalar-evolution-max-iterations=0 | grep -F "Exits: 20028"
+; PR2621
+
+define i32 @a() nounwind {
+entry:
+ br label %bb1
+
+bb:
+ trunc i32 %i.0 to i16
+ add i16 %0, %x16.0
+ add i32 %i.0, 1
+ br label %bb1
+
+bb1:
+ %i.0 = phi i32 [ 0, %entry ], [ %2, %bb ]
+ %x16.0 = phi i16 [ 0, %entry ], [ %1, %bb ]
+ icmp ult i32 %i.0, 888888
+ br i1 %3, label %bb, label %bb2
+
+bb2:
+ zext i16 %x16.0 to i32
+ ret i32 %4
+}
+
diff --git a/test/Analysis/ScalarEvolution/2008-08-04-LongAddRec.ll b/test/Analysis/ScalarEvolution/2008-08-04-LongAddRec.ll
new file mode 100644
index 000000000000..fbd249fbc040
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-08-04-LongAddRec.ll
@@ -0,0 +1,56 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
+; RUN: -scalar-evolution-max-iterations=0 | grep -F "Exits: -19168"
+; PR2621
+
+define i32 @a() nounwind {
+entry:
+ br label %bb1
+
+bb: ; preds = %bb1
+ add i16 %x17.0, 1 ; <i16>:0 [#uses=2]
+ add i16 %0, %x16.0 ; <i16>:1 [#uses=2]
+ add i16 %1, %x15.0 ; <i16>:2 [#uses=2]
+ add i16 %2, %x14.0 ; <i16>:3 [#uses=2]
+ add i16 %3, %x13.0 ; <i16>:4 [#uses=2]
+ add i16 %4, %x12.0 ; <i16>:5 [#uses=2]
+ add i16 %5, %x11.0 ; <i16>:6 [#uses=2]
+ add i16 %6, %x10.0 ; <i16>:7 [#uses=2]
+ add i16 %7, %x9.0 ; <i16>:8 [#uses=2]
+ add i16 %8, %x8.0 ; <i16>:9 [#uses=2]
+ add i16 %9, %x7.0 ; <i16>:10 [#uses=2]
+ add i16 %10, %x6.0 ; <i16>:11 [#uses=2]
+ add i16 %11, %x5.0 ; <i16>:12 [#uses=2]
+ add i16 %12, %x4.0 ; <i16>:13 [#uses=2]
+ add i16 %13, %x3.0 ; <i16>:14 [#uses=2]
+ add i16 %14, %x2.0 ; <i16>:15 [#uses=2]
+ add i16 %15, %x1.0 ; <i16>:16 [#uses=1]
+ add i32 %i.0, 1 ; <i32>:17 [#uses=1]
+ br label %bb1
+
+bb1: ; preds = %bb, %entry
+ %x2.0 = phi i16 [ 0, %entry ], [ %15, %bb ] ; <i16> [#uses=1]
+ %x3.0 = phi i16 [ 0, %entry ], [ %14, %bb ] ; <i16> [#uses=1]
+ %x4.0 = phi i16 [ 0, %entry ], [ %13, %bb ] ; <i16> [#uses=1]
+ %x5.0 = phi i16 [ 0, %entry ], [ %12, %bb ] ; <i16> [#uses=1]
+ %x6.0 = phi i16 [ 0, %entry ], [ %11, %bb ] ; <i16> [#uses=1]
+ %x7.0 = phi i16 [ 0, %entry ], [ %10, %bb ] ; <i16> [#uses=1]
+ %x8.0 = phi i16 [ 0, %entry ], [ %9, %bb ] ; <i16> [#uses=1]
+ %x9.0 = phi i16 [ 0, %entry ], [ %8, %bb ] ; <i16> [#uses=1]
+ %x10.0 = phi i16 [ 0, %entry ], [ %7, %bb ] ; <i16> [#uses=1]
+ %x11.0 = phi i16 [ 0, %entry ], [ %6, %bb ] ; <i16> [#uses=1]
+ %x12.0 = phi i16 [ 0, %entry ], [ %5, %bb ] ; <i16> [#uses=1]
+ %x13.0 = phi i16 [ 0, %entry ], [ %4, %bb ] ; <i16> [#uses=1]
+ %x14.0 = phi i16 [ 0, %entry ], [ %3, %bb ] ; <i16> [#uses=1]
+ %x15.0 = phi i16 [ 0, %entry ], [ %2, %bb ] ; <i16> [#uses=1]
+ %x16.0 = phi i16 [ 0, %entry ], [ %1, %bb ] ; <i16> [#uses=1]
+ %x17.0 = phi i16 [ 0, %entry ], [ %0, %bb ] ; <i16> [#uses=1]
+ %i.0 = phi i32 [ 0, %entry ], [ %17, %bb ] ; <i32> [#uses=2]
+ %x1.0 = phi i16 [ 0, %entry ], [ %16, %bb ] ; <i16> [#uses=2]
+ icmp ult i32 %i.0, 8888 ; <i1>:18 [#uses=1]
+ br i1 %18, label %bb, label %bb2
+
+bb2: ; preds = %bb1
+ zext i16 %x1.0 to i32 ; <i32>:19 [#uses=1]
+ ret i32 %19
+}
+
diff --git a/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll b/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll
new file mode 100644
index 000000000000..c6cb87fca140
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution
+; PR1827
+
+declare void @use(i32)
+
+define void @foo() {
+entry:
+ br label %loop_1
+
+loop_1: ; preds = %loop_1, %entry
+ %a = phi i32 [ 2, %entry ], [ %b, %loop_1 ] ; <i32> [#uses=2]
+ %c = phi i32 [ 5, %entry ], [ %d, %loop_1 ] ; <i32> [#uses=1]
+ %b = add i32 %a, 1 ; <i32> [#uses=1]
+ %d = add i32 %c, %a ; <i32> [#uses=3]
+ %A = icmp ult i32 %d, 50 ; <i1> [#uses=1]
+ br i1 %A, label %loop_1, label %endloop
+
+endloop: ; preds = %loop_1
+ call void @use(i32 %d)
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll b/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll
new file mode 100644
index 000000000000..89e9efa37ca6
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll
@@ -0,0 +1,19 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution
+; PR2602
+
+define i32 @a() nounwind {
+entry:
+ br label %bb
+
+bb: ; preds = %bb, %entry
+ %w.0 = phi i32 [ 0, %entry ], [ %tmp, %bb ] ; <i32> [#uses=2]
+ %e.0 = phi i32 [ 0, %entry ], [ %e.1, %bb ] ; <i32> [#uses=2]
+ %w.1 = add i32 0, %w.0 ; <i32>:0 [#uses=1]
+ %tmp = add i32 %e.0, %w.0 ; <i32>:1 [#uses=1]
+ %e.1 = add i32 %e.0, 1 ; <i32>:2 [#uses=1]
+ %cond = icmp eq i32 %w.1, -1 ; <i1>:3 [#uses=1]
+ br i1 %cond, label %return, label %bb
+
+return: ; preds = %bb
+ ret i32 undef
+}
diff --git a/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll b/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll
new file mode 100644
index 000000000000..0651fd85487f
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& \
+; RUN: grep {Loop bb: backedge-taken count is (7 + (-1 \\* %argc))}
+; XFAIL: *
+
+define i32 @main(i32 %argc, i8** %argv) nounwind {
+entry:
+ %0 = icmp ugt i32 %argc, 7 ; <i1> [#uses=1]
+ br i1 %0, label %bb2, label %bb.nph
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb.nph, %bb1
+ %indvar = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb1 ] ; <i32> [#uses=2]
+ %argc_addr.04 = add i32 %indvar, %argc ; <i32> [#uses=1]
+ tail call void (...)* @Test() nounwind
+ %1 = add i32 %argc_addr.04, 1 ; <i32> [#uses=1]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %phitmp = icmp ugt i32 %1, 7 ; <i1> [#uses=1]
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
+ br i1 %phitmp, label %bb1.bb2_crit_edge, label %bb
+
+bb1.bb2_crit_edge: ; preds = %bb1
+ br label %bb2
+
+bb2: ; preds = %bb1.bb2_crit_edge, %entry
+ ret i32 0
+}
+
+declare void @Test(...)
diff --git a/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll b/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll
new file mode 100644
index 000000000000..78cda0e175f4
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& grep {/u 3}
+
+define i32 @f(i32 %x) nounwind readnone {
+entry:
+ %0 = icmp ugt i32 %x, 4 ; <i1> [#uses=1]
+ br i1 %0, label %bb.nph, label %bb2
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb.nph, %bb1
+ %indvar = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb1 ] ; <i32> [#uses=2]
+ %tmp = mul i32 %indvar, -3 ; <i32> [#uses=1]
+ %x_addr.04 = add i32 %tmp, %x ; <i32> [#uses=1]
+ %1 = add i32 %x_addr.04, -3 ; <i32> [#uses=2]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %2 = icmp ugt i32 %1, 4 ; <i1> [#uses=1]
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
+ br i1 %2, label %bb, label %bb1.bb2_crit_edge
+
+bb1.bb2_crit_edge: ; preds = %bb1
+ %.lcssa = phi i32 [ %1, %bb1 ] ; <i32> [#uses=1]
+ br label %bb2
+
+bb2: ; preds = %bb1.bb2_crit_edge, %entry
+ %x_addr.0.lcssa = phi i32 [ %.lcssa, %bb1.bb2_crit_edge ], [ %x, %entry ] ; <i32> [#uses=1]
+ ret i32 %x_addr.0.lcssa
+}
diff --git a/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll b/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll
new file mode 100644
index 000000000000..4a76970ce19a
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& grep {/u 3}
+; XFAIL: *
+
+define i32 @f(i32 %x) nounwind readnone {
+entry:
+ %0 = icmp ugt i32 %x, 999 ; <i1> [#uses=1]
+ br i1 %0, label %bb2, label %bb.nph
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb.nph, %bb1
+ %indvar = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb1 ] ; <i32> [#uses=2]
+ %tmp = mul i32 %indvar, 3 ; <i32> [#uses=1]
+ %x_addr.04 = add i32 %tmp, %x ; <i32> [#uses=1]
+ %1 = add i32 %x_addr.04, 3 ; <i32> [#uses=2]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %2 = icmp ugt i32 %1, 999 ; <i1> [#uses=1]
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
+ br i1 %2, label %bb1.bb2_crit_edge, label %bb
+
+bb1.bb2_crit_edge: ; preds = %bb1
+ %.lcssa = phi i32 [ %1, %bb1 ] ; <i32> [#uses=1]
+ br label %bb2
+
+bb2: ; preds = %bb1.bb2_crit_edge, %entry
+ %x_addr.0.lcssa = phi i32 [ %.lcssa, %bb1.bb2_crit_edge ], [ %x, %entry ] ; <i32> [#uses=1]
+ ret i32 %x_addr.0.lcssa
+}
diff --git a/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll b/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll
new file mode 100644
index 000000000000..3df1fe000135
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll
@@ -0,0 +1,25 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {backedge-taken count is 255}
+; XFAIL: *
+
+define i32 @foo(i32 %x, i32 %y, i32* %lam, i32* %alp) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %indvar = phi i32 [ 0, %bb1.thread ], [ %indvar.next, %bb1 ] ; <i32> [#uses=4]
+ %i.0.reg2mem.0 = sub i32 255, %indvar ; <i32> [#uses=2]
+ %0 = getelementptr i32* %alp, i32 %i.0.reg2mem.0 ; <i32*> [#uses=1]
+ %1 = load i32* %0, align 4 ; <i32> [#uses=1]
+ %2 = getelementptr i32* %lam, i32 %i.0.reg2mem.0 ; <i32*> [#uses=1]
+ store i32 %1, i32* %2, align 4
+ %3 = sub i32 254, %indvar ; <i32> [#uses=1]
+ %4 = icmp slt i32 %3, 0 ; <i1> [#uses=1]
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
+ br i1 %4, label %bb2, label %bb1
+
+bb2: ; preds = %bb1
+ %tmp10 = mul i32 %indvar, %x ; <i32> [#uses=1]
+ %z.0.reg2mem.0 = add i32 %tmp10, %y ; <i32> [#uses=1]
+ %5 = add i32 %z.0.reg2mem.0, %x ; <i32> [#uses=1]
+ ret i32 %5
+}
diff --git a/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll b/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll
new file mode 100644
index 000000000000..9703bcb15422
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {0 smax}
+; XFAIL: *
+
+define i32 @f(i32 %c.idx.val) {
+
+bb2:
+ %k.018 = add i32 %c.idx.val, -1 ; <i32> [#uses=2]
+ %a14 = icmp slt i32 %k.018, 0 ; <i1> [#uses=1]
+ br i1 %a14, label %bb19, label %bb16.preheader
+
+bb16.preheader:
+ %k.019 = phi i32 [ %k.0, %bb18 ], [ %k.018, %bb2 ] ; <i32> [#uses=5]
+ %x = phi i32 [ 0, %bb2 ], [ %x.1, %bb18]
+ br label %bb18
+
+bb18: ; preds = %bb18.loopexit
+ %x.1 = add i32 %x, 1
+ %k.0 = add i32 %k.019, -1 ; <i32> [#uses=2]
+ %a107 = icmp slt i32 %k.0, 0 ; <i1> [#uses=1]
+ br i1 %a107, label %bb18.bb19_crit_edge, label %bb16.preheader
+
+bb18.bb19_crit_edge:
+ ret i32 %x
+
+bb19:
+ ret i32 0
+
+}
diff --git a/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll b/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll
new file mode 100644
index 000000000000..4d4fcd783edb
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& \
+; RUN: grep {(((-1 \\* %i0) + (100005 smax %i0)) /u 5)}
+; XFAIL: *
+
+define i32 @foo0(i32 %i0) nounwind {
+entry:
+ br label %bb1
+
+bb: ; preds = %bb1
+ %0 = add i32 %j.0, 1 ; <i32> [#uses=1]
+ %1 = add i32 %i.0, 5 ; <i32> [#uses=1]
+ br label %bb1
+
+bb1: ; preds = %bb, %entry
+ %j.0 = phi i32 [ 0, %entry ], [ %0, %bb ] ; <i32> [#uses=2]
+ %i.0 = phi i32 [ %i0, %entry ], [ %1, %bb ] ; <i32> [#uses=2]
+ %2 = icmp sgt i32 %i.0, 100000 ; <i1> [#uses=1]
+ br i1 %2, label %return, label %bb
+
+return: ; preds = %bb1
+ ret i32 %j.0
+}
diff --git a/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll b/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll
new file mode 100644
index 000000000000..2557c8bbbab2
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& grep {/u 5}
+; XFAIL: *
+
+define i8 @foo0(i8 %i0) nounwind {
+entry:
+ br label %bb1
+
+bb: ; preds = %bb1
+ %0 = add i8 %j.0, 1 ; <i8> [#uses=1]
+ %1 = add i8 %i.0, 5 ; <i8> [#uses=1]
+ br label %bb1
+
+bb1: ; preds = %bb, %entry
+ %j.0 = phi i8 [ 0, %entry ], [ %0, %bb ] ; <i8> [#uses=2]
+ %i.0 = phi i8 [ %i0, %entry ], [ %1, %bb ] ; <i8> [#uses=2]
+ %2 = icmp sgt i8 %i.0, 100 ; <i1> [#uses=1]
+ br i1 %2, label %return, label %bb
+
+return: ; preds = %bb1
+ ret i8 %j.0
+}
diff --git a/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll b/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll
new file mode 100644
index 000000000000..07714cd1b507
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll
@@ -0,0 +1,40 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | not grep {/u -1}
+; PR3275
+
+@g_16 = external global i16 ; <i16*> [#uses=3]
+@.str = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
+
+define void @func_15() nounwind {
+entry:
+ %0 = load i16* @g_16, align 2 ; <i16> [#uses=1]
+ %1 = icmp sgt i16 %0, 0 ; <i1> [#uses=1]
+ br i1 %1, label %bb2, label %bb.nph
+
+bb.nph: ; preds = %entry
+ %g_16.promoted = load i16* @g_16 ; <i16> [#uses=1]
+ br label %bb
+
+bb: ; preds = %bb1, %bb.nph
+ %g_16.tmp.0 = phi i16 [ %g_16.promoted, %bb.nph ], [ %2, %bb1 ] ; <i16> [#uses=1]
+ %2 = add i16 %g_16.tmp.0, -1 ; <i16> [#uses=3]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %3 = icmp sgt i16 %2, 0 ; <i1> [#uses=1]
+ br i1 %3, label %bb1.bb2_crit_edge, label %bb
+
+bb1.bb2_crit_edge: ; preds = %bb1
+ store i16 %2, i16* @g_16
+ br label %bb2
+
+bb2: ; preds = %bb1.bb2_crit_edge, %entry
+ br label %return
+
+return: ; preds = %bb2
+ ret void
+}
+
+declare i32 @main() nounwind
+
+declare i32 @printf(i8*, ...) nounwind
+
diff --git a/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll b/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll
new file mode 100644
index 000000000000..c23f0f0ef1d8
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll
@@ -0,0 +1,37 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {(trunc i} | not grep ext
+
+define i16 @test1(i8 %x) {
+ %A = sext i8 %x to i32
+ %B = trunc i32 %A to i16
+ ret i16 %B
+}
+
+define i8 @test2(i16 %x) {
+ %A = sext i16 %x to i32
+ %B = trunc i32 %A to i8
+ ret i8 %B
+}
+
+define i16 @test3(i16 %x) {
+ %A = sext i16 %x to i32
+ %B = trunc i32 %A to i16
+ ret i16 %B
+}
+
+define i16 @test4(i8 %x) {
+ %A = zext i8 %x to i32
+ %B = trunc i32 %A to i16
+ ret i16 %B
+}
+
+define i8 @test5(i16 %x) {
+ %A = zext i16 %x to i32
+ %B = trunc i32 %A to i8
+ ret i8 %B
+}
+
+define i16 @test6(i16 %x) {
+ %A = zext i16 %x to i32
+ %B = trunc i32 %A to i16
+ ret i16 %B
+}
diff --git a/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll b/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll
new file mode 100644
index 000000000000..bea46a765d65
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll
@@ -0,0 +1,27 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {count is 2}
+; PR3171
+
+ %struct.Foo = type { i32 }
+ %struct.NonPod = type { [2 x %struct.Foo] }
+
+define void @_Z3foov() nounwind {
+entry:
+ %x = alloca %struct.NonPod, align 8 ; <%struct.NonPod*> [#uses=2]
+ %0 = getelementptr %struct.NonPod* %x, i32 0, i32 0 ; <[2 x %struct.Foo]*> [#uses=1]
+ %1 = getelementptr [2 x %struct.Foo]* %0, i32 1, i32 0 ; <%struct.Foo*> [#uses=1]
+ br label %bb1.i
+
+bb1.i: ; preds = %bb2.i, %entry
+ %.0.i = phi %struct.Foo* [ %1, %entry ], [ %4, %bb2.i ] ; <%struct.Foo*> [#uses=2]
+ %2 = getelementptr %struct.NonPod* %x, i32 0, i32 0, i32 0 ; <%struct.Foo*> [#uses=1]
+ %3 = icmp eq %struct.Foo* %.0.i, %2 ; <i1> [#uses=1]
+ br i1 %3, label %_ZN6NonPodD1Ev.exit, label %bb2.i
+
+bb2.i: ; preds = %bb1.i
+ %4 = getelementptr %struct.Foo* %.0.i, i32 -1 ; <%struct.Foo*> [#uses=1]
+ br label %bb1.i
+
+_ZN6NonPodD1Ev.exit: ; preds = %bb1.i
+ ret void
+}
+
diff --git a/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll b/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll
new file mode 100644
index 000000000000..76ca4a084747
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 100}
+; PR1101
+
+@A = weak global [1000 x i32] zeroinitializer, align 32
+
+
+define void @test(i32 %N) {
+entry:
+ "alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ br label %bb3
+
+bb: ; preds = %bb3
+ %tmp = getelementptr [1000 x i32]* @A, i32 0, i32 %i.0 ; <i32*> [#uses=1]
+ store i32 123, i32* %tmp
+ %tmp2 = add i32 %i.0, 1 ; <i32> [#uses=1]
+ br label %bb3
+
+bb3: ; preds = %bb, %entry
+ %i.0 = phi i32 [ 2, %entry ], [ %tmp2, %bb ] ; <i32> [#uses=3]
+ %SQ = mul i32 %i.0, %i.0
+ %tmp4 = mul i32 %i.0, 2
+ %tmp5 = sub i32 %SQ, %tmp4
+ %tmp3 = icmp sle i32 %tmp5, 9999 ; <i1> [#uses=1]
+ br i1 %tmp3, label %bb, label %bb5
+
+bb5: ; preds = %bb3
+ br label %return
+
+return: ; preds = %bb5
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/and-xor.ll b/test/Analysis/ScalarEvolution/and-xor.ll
new file mode 100644
index 000000000000..94cca83ea74d
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/and-xor.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output \
+; RUN: | grep {\\--> (zext} | count 2
+
+define i32 @foo(i32 %x) {
+ %n = and i32 %x, 255
+ %y = xor i32 %n, 255
+ ret i32 %y
+}
diff --git a/test/Analysis/ScalarEvolution/avoid-smax-0.ll b/test/Analysis/ScalarEvolution/avoid-smax-0.ll
new file mode 100644
index 000000000000..df39cc0af084
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/avoid-smax-0.ll
@@ -0,0 +1,35 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop bb3: backedge-taken count is (-1 + %n)}
+
+; We don't want to use a max in the trip count expression in
+; this testcase.
+
+define void @foo(i32 %n, i32* %p, i32* %q) nounwind {
+entry:
+ icmp sgt i32 %n, 0
+ br i1 %0, label %bb, label %return
+
+bb:
+ load i32* %q, align 4
+ icmp eq i32 %1, 0
+ br i1 %2, label %return, label %bb3.preheader
+
+bb3.preheader:
+ br label %bb3
+
+bb3:
+ %i.0 = phi i32 [ %7, %bb3 ], [ 0, %bb3.preheader ]
+ getelementptr i32* %p, i32 %i.0
+ load i32* %3, align 4
+ add i32 %4, 1
+ getelementptr i32* %p, i32 %i.0
+ store i32 %5, i32* %6, align 4
+ add i32 %i.0, 1
+ icmp slt i32 %7, %n
+ br i1 %8, label %bb3, label %return.loopexit
+
+return.loopexit:
+ br label %return
+
+return:
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/avoid-smax-1.ll b/test/Analysis/ScalarEvolution/avoid-smax-1.ll
new file mode 100644
index 000000000000..9270b6e6c890
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/avoid-smax-1.ll
@@ -0,0 +1,236 @@
+; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t
+; RUN: grep select %t | count 2
+; RUN: grep {icmp ne i32.\* %w } %t
+
+; Indvars should be able to insert a canonical induction variable
+; for the bb6 loop without using a maximum calculation (icmp, select)
+; because it should be able to prove that the comparison is guarded
+; by an appropriate conditional branch. Unfortunately, indvars is
+; not yet able to find the comparison for the other two loops in
+; this testcase.
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i386-apple-darwin9"
+
+define void @foo(i8* %r, i32 %s, i32 %w, i32 %x, i8* %j, i32 %d) nounwind {
+entry:
+ %0 = mul i32 %x, %w ; <i32> [#uses=2]
+ %1 = mul i32 %x, %w ; <i32> [#uses=1]
+ %2 = sdiv i32 %1, 4 ; <i32> [#uses=1]
+ %.sum2 = add i32 %2, %0 ; <i32> [#uses=2]
+ %cond = icmp eq i32 %d, 1 ; <i1> [#uses=1]
+ br i1 %cond, label %bb29, label %bb10.preheader
+
+bb10.preheader: ; preds = %entry
+ %3 = icmp sgt i32 %x, 0 ; <i1> [#uses=1]
+ br i1 %3, label %bb.nph9, label %bb18.loopexit
+
+bb.nph7: ; preds = %bb7.preheader
+ %4 = mul i32 %y.08, %w ; <i32> [#uses=1]
+ %5 = mul i32 %y.08, %s ; <i32> [#uses=1]
+ %6 = add i32 %5, 1 ; <i32> [#uses=1]
+ br label %bb6
+
+bb6: ; preds = %bb7, %bb.nph7
+ %x.06 = phi i32 [ %13, %bb7 ], [ 0, %bb.nph7 ] ; <i32> [#uses=3]
+ %7 = add i32 %x.06, %4 ; <i32> [#uses=1]
+ %8 = shl i32 %x.06, 1 ; <i32> [#uses=1]
+ %9 = add i32 %6, %8 ; <i32> [#uses=1]
+ %10 = getelementptr i8* %r, i32 %9 ; <i8*> [#uses=1]
+ %11 = load i8* %10, align 1 ; <i8> [#uses=1]
+ %12 = getelementptr i8* %j, i32 %7 ; <i8*> [#uses=1]
+ store i8 %11, i8* %12, align 1
+ %13 = add i32 %x.06, 1 ; <i32> [#uses=2]
+ br label %bb7
+
+bb7: ; preds = %bb6
+ %14 = icmp slt i32 %13, %w ; <i1> [#uses=1]
+ br i1 %14, label %bb6, label %bb7.bb9_crit_edge
+
+bb7.bb9_crit_edge: ; preds = %bb7
+ br label %bb9
+
+bb9: ; preds = %bb7.preheader, %bb7.bb9_crit_edge
+ %15 = add i32 %y.08, 1 ; <i32> [#uses=2]
+ br label %bb10
+
+bb10: ; preds = %bb9
+ %16 = icmp slt i32 %15, %x ; <i1> [#uses=1]
+ br i1 %16, label %bb7.preheader, label %bb10.bb18.loopexit_crit_edge
+
+bb10.bb18.loopexit_crit_edge: ; preds = %bb10
+ br label %bb10.bb18.loopexit_crit_edge.split
+
+bb10.bb18.loopexit_crit_edge.split: ; preds = %bb.nph9, %bb10.bb18.loopexit_crit_edge
+ br label %bb18.loopexit
+
+bb.nph9: ; preds = %bb10.preheader
+ %17 = icmp sgt i32 %w, 0 ; <i1> [#uses=1]
+ br i1 %17, label %bb.nph9.split, label %bb10.bb18.loopexit_crit_edge.split
+
+bb.nph9.split: ; preds = %bb.nph9
+ br label %bb7.preheader
+
+bb7.preheader: ; preds = %bb.nph9.split, %bb10
+ %y.08 = phi i32 [ %15, %bb10 ], [ 0, %bb.nph9.split ] ; <i32> [#uses=3]
+ br i1 true, label %bb.nph7, label %bb9
+
+bb.nph5: ; preds = %bb18.loopexit
+ %18 = sdiv i32 %w, 2 ; <i32> [#uses=1]
+ %19 = icmp slt i32 %w, 2 ; <i1> [#uses=1]
+ %20 = sdiv i32 %x, 2 ; <i32> [#uses=1]
+ br i1 %19, label %bb18.bb20_crit_edge.split, label %bb.nph5.split
+
+bb.nph5.split: ; preds = %bb.nph5
+ br label %bb13
+
+bb13: ; preds = %bb18, %bb.nph5.split
+ %y.14 = phi i32 [ %42, %bb18 ], [ 0, %bb.nph5.split ] ; <i32> [#uses=4]
+ %21 = mul i32 %18, %y.14 ; <i32> [#uses=2]
+ %22 = shl i32 %y.14, 1 ; <i32> [#uses=1]
+ %23 = srem i32 %y.14, 2 ; <i32> [#uses=1]
+ %24 = add i32 %23, %22 ; <i32> [#uses=1]
+ %25 = mul i32 %24, %s ; <i32> [#uses=2]
+ br i1 true, label %bb.nph3, label %bb17
+
+bb.nph3: ; preds = %bb13
+ %26 = add i32 %21, %0 ; <i32> [#uses=1]
+ %27 = add i32 %21, %.sum2 ; <i32> [#uses=1]
+ %28 = sdiv i32 %w, 2 ; <i32> [#uses=1]
+ br label %bb14
+
+bb14: ; preds = %bb15, %bb.nph3
+ %x.12 = phi i32 [ %40, %bb15 ], [ 0, %bb.nph3 ] ; <i32> [#uses=5]
+ %29 = shl i32 %x.12, 2 ; <i32> [#uses=1]
+ %30 = add i32 %29, %25 ; <i32> [#uses=1]
+ %31 = getelementptr i8* %r, i32 %30 ; <i8*> [#uses=1]
+ %32 = load i8* %31, align 1 ; <i8> [#uses=1]
+ %.sum = add i32 %26, %x.12 ; <i32> [#uses=1]
+ %33 = getelementptr i8* %j, i32 %.sum ; <i8*> [#uses=1]
+ store i8 %32, i8* %33, align 1
+ %34 = shl i32 %x.12, 2 ; <i32> [#uses=1]
+ %35 = or i32 %34, 2 ; <i32> [#uses=1]
+ %36 = add i32 %35, %25 ; <i32> [#uses=1]
+ %37 = getelementptr i8* %r, i32 %36 ; <i8*> [#uses=1]
+ %38 = load i8* %37, align 1 ; <i8> [#uses=1]
+ %.sum6 = add i32 %27, %x.12 ; <i32> [#uses=1]
+ %39 = getelementptr i8* %j, i32 %.sum6 ; <i8*> [#uses=1]
+ store i8 %38, i8* %39, align 1
+ %40 = add i32 %x.12, 1 ; <i32> [#uses=2]
+ br label %bb15
+
+bb15: ; preds = %bb14
+ %41 = icmp sgt i32 %28, %40 ; <i1> [#uses=1]
+ br i1 %41, label %bb14, label %bb15.bb17_crit_edge
+
+bb15.bb17_crit_edge: ; preds = %bb15
+ br label %bb17
+
+bb17: ; preds = %bb15.bb17_crit_edge, %bb13
+ %42 = add i32 %y.14, 1 ; <i32> [#uses=2]
+ br label %bb18
+
+bb18.loopexit: ; preds = %bb10.bb18.loopexit_crit_edge.split, %bb10.preheader
+ %43 = icmp slt i32 %x, 2 ; <i1> [#uses=1]
+ br i1 %43, label %bb20, label %bb.nph5
+
+bb18: ; preds = %bb17
+ %44 = icmp sgt i32 %20, %42 ; <i1> [#uses=1]
+ br i1 %44, label %bb13, label %bb18.bb20_crit_edge
+
+bb18.bb20_crit_edge: ; preds = %bb18
+ br label %bb18.bb20_crit_edge.split
+
+bb18.bb20_crit_edge.split: ; preds = %bb18.bb20_crit_edge, %bb.nph5
+ br label %bb20
+
+bb20: ; preds = %bb18.bb20_crit_edge.split, %bb18.loopexit
+ switch i32 %d, label %return [
+ i32 3, label %bb22
+ i32 1, label %bb29
+ ]
+
+bb22: ; preds = %bb20
+ %45 = mul i32 %x, %w ; <i32> [#uses=1]
+ %46 = sdiv i32 %45, 4 ; <i32> [#uses=1]
+ %.sum3 = add i32 %46, %.sum2 ; <i32> [#uses=2]
+ %47 = add i32 %x, 15 ; <i32> [#uses=1]
+ %48 = and i32 %47, -16 ; <i32> [#uses=1]
+ %49 = add i32 %w, 15 ; <i32> [#uses=1]
+ %50 = and i32 %49, -16 ; <i32> [#uses=1]
+ %51 = mul i32 %48, %s ; <i32> [#uses=1]
+ %52 = icmp sgt i32 %x, 0 ; <i1> [#uses=1]
+ br i1 %52, label %bb.nph, label %bb26
+
+bb.nph: ; preds = %bb22
+ br label %bb23
+
+bb23: ; preds = %bb24, %bb.nph
+ %y.21 = phi i32 [ %57, %bb24 ], [ 0, %bb.nph ] ; <i32> [#uses=3]
+ %53 = mul i32 %y.21, %50 ; <i32> [#uses=1]
+ %.sum1 = add i32 %53, %51 ; <i32> [#uses=1]
+ %54 = getelementptr i8* %r, i32 %.sum1 ; <i8*> [#uses=1]
+ %55 = mul i32 %y.21, %w ; <i32> [#uses=1]
+ %.sum5 = add i32 %55, %.sum3 ; <i32> [#uses=1]
+ %56 = getelementptr i8* %j, i32 %.sum5 ; <i8*> [#uses=1]
+ tail call void @llvm.memcpy.i32(i8* %56, i8* %54, i32 %w, i32 1)
+ %57 = add i32 %y.21, 1 ; <i32> [#uses=2]
+ br label %bb24
+
+bb24: ; preds = %bb23
+ %58 = icmp slt i32 %57, %x ; <i1> [#uses=1]
+ br i1 %58, label %bb23, label %bb24.bb26_crit_edge
+
+bb24.bb26_crit_edge: ; preds = %bb24
+ br label %bb26
+
+bb26: ; preds = %bb24.bb26_crit_edge, %bb22
+ %59 = mul i32 %x, %w ; <i32> [#uses=1]
+ %.sum4 = add i32 %.sum3, %59 ; <i32> [#uses=1]
+ %60 = getelementptr i8* %j, i32 %.sum4 ; <i8*> [#uses=1]
+ %61 = mul i32 %x, %w ; <i32> [#uses=1]
+ %62 = sdiv i32 %61, 2 ; <i32> [#uses=1]
+ tail call void @llvm.memset.i32(i8* %60, i8 -128, i32 %62, i32 1)
+ ret void
+
+bb29: ; preds = %bb20, %entry
+ %63 = add i32 %w, 15 ; <i32> [#uses=1]
+ %64 = and i32 %63, -16 ; <i32> [#uses=1]
+ %65 = icmp sgt i32 %x, 0 ; <i1> [#uses=1]
+ br i1 %65, label %bb.nph11, label %bb33
+
+bb.nph11: ; preds = %bb29
+ br label %bb30
+
+bb30: ; preds = %bb31, %bb.nph11
+ %y.310 = phi i32 [ %70, %bb31 ], [ 0, %bb.nph11 ] ; <i32> [#uses=3]
+ %66 = mul i32 %y.310, %64 ; <i32> [#uses=1]
+ %67 = getelementptr i8* %r, i32 %66 ; <i8*> [#uses=1]
+ %68 = mul i32 %y.310, %w ; <i32> [#uses=1]
+ %69 = getelementptr i8* %j, i32 %68 ; <i8*> [#uses=1]
+ tail call void @llvm.memcpy.i32(i8* %69, i8* %67, i32 %w, i32 1)
+ %70 = add i32 %y.310, 1 ; <i32> [#uses=2]
+ br label %bb31
+
+bb31: ; preds = %bb30
+ %71 = icmp slt i32 %70, %x ; <i1> [#uses=1]
+ br i1 %71, label %bb30, label %bb31.bb33_crit_edge
+
+bb31.bb33_crit_edge: ; preds = %bb31
+ br label %bb33
+
+bb33: ; preds = %bb31.bb33_crit_edge, %bb29
+ %72 = mul i32 %x, %w ; <i32> [#uses=1]
+ %73 = getelementptr i8* %j, i32 %72 ; <i8*> [#uses=1]
+ %74 = mul i32 %x, %w ; <i32> [#uses=1]
+ %75 = sdiv i32 %74, 2 ; <i32> [#uses=1]
+ tail call void @llvm.memset.i32(i8* %73, i8 -128, i32 %75, i32 1)
+ ret void
+
+return: ; preds = %bb20
+ ret void
+}
+
+declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind
+
+declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind
diff --git a/test/Analysis/ScalarEvolution/dg.exp b/test/Analysis/ScalarEvolution/dg.exp
new file mode 100644
index 000000000000..b65a2503ac6f
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.ll]]
diff --git a/test/Analysis/ScalarEvolution/div-overflow.ll b/test/Analysis/ScalarEvolution/div-overflow.ll
new file mode 100644
index 000000000000..cb64b856a777
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/div-overflow.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output \
+; RUN: | grep {\\--> ((-128 \\* %a) /u -128)}
+
+; Don't let ScalarEvolution fold this div away.
+
+define i8 @foo(i8 %a) {
+ %t0 = shl i8 %a, 7
+ %t1 = lshr i8 %t0, 7
+ ret i8 %t1
+}
diff --git a/test/Analysis/ScalarEvolution/do-loop.ll b/test/Analysis/ScalarEvolution/do-loop.ll
new file mode 100644
index 000000000000..c6b3298638b1
--- /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/max-trip-count.ll b/test/Analysis/ScalarEvolution/max-trip-count.ll
new file mode 100644
index 000000000000..05674149da82
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/max-trip-count.ll
@@ -0,0 +1,32 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
+; RUN: | grep {\{%d,+,4\}<bb>}
+
+define void @foo(i32* nocapture %d, i32 %n) nounwind {
+entry:
+ %0 = icmp sgt i32 %n, 0 ; <i1> [#uses=1]
+ br i1 %0, label %bb.nph, label %return
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb1, %bb.nph
+ %i.02 = phi i32 [ %5, %bb1 ], [ 0, %bb.nph ] ; <i32> [#uses=2]
+ %p.01 = phi i8 [ %4, %bb1 ], [ -1, %bb.nph ] ; <i8> [#uses=2]
+ %1 = sext i8 %p.01 to i32 ; <i32> [#uses=1]
+ %2 = sext i32 %i.02 to i64 ; <i64> [#uses=1]
+ %3 = getelementptr i32* %d, i64 %2 ; <i32*> [#uses=1]
+ store i32 %1, i32* %3, align 4
+ %4 = add i8 %p.01, 1 ; <i8> [#uses=1]
+ %5 = add i32 %i.02, 1 ; <i32> [#uses=2]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %6 = icmp slt i32 %5, %n ; <i1> [#uses=1]
+ br i1 %6, label %bb, label %bb1.return_crit_edge
+
+bb1.return_crit_edge: ; preds = %bb1
+ br label %return
+
+return: ; preds = %bb1.return_crit_edge, %entry
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/pr3909.ll b/test/Analysis/ScalarEvolution/pr3909.ll
new file mode 100644
index 000000000000..80720c724afb
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/pr3909.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | opt -indvars -disable-output
+; PR 3909
+
+
+ type { i32, %1* } ; type %0
+ type { i32, i8* } ; type %1
+
+define x86_stdcallcc i32 @_Dmain(%0 %unnamed) {
+entry:
+ br label %whilebody
+
+whilebody: ; preds = %endwhile5, %entry
+ %i.0 = phi i64 [ 0, %entry ], [ %tmp11, %endwhile5 ] ; <i64> [#uses=1]
+ %m.0 = phi i64 [ 0, %entry ], [ %tmp11, %endwhile5 ] ; <i64> [#uses=2]
+ %tmp2 = mul i64 %m.0, %m.0 ; <i64> [#uses=1]
+ br label %whilecond3
+
+whilecond3: ; preds = %whilebody4, %whilebody
+ %j.0 = phi i64 [ %tmp2, %whilebody ], [ %tmp9, %whilebody4 ] ; <i64> [#uses=2]
+ %tmp7 = icmp ne i64 %j.0, 0 ; <i1> [#uses=1]
+ br i1 %tmp7, label %whilebody4, label %endwhile5
+
+whilebody4: ; preds = %whilecond3
+ %tmp9 = add i64 %j.0, 1 ; <i64> [#uses=1]
+ br label %whilecond3
+
+endwhile5: ; preds = %whilecond3
+ %tmp11 = add i64 %i.0, 1 ; <i64> [#uses=2]
+ br label %whilebody
+}
diff --git a/test/Analysis/ScalarEvolution/sext-inreg.ll b/test/Analysis/ScalarEvolution/sext-inreg.ll
new file mode 100644
index 000000000000..8a88f0f7d967
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/sext-inreg.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output > %t
+; RUN: grep {sext i57 \{0,+,199\}<bb> to i64} %t | count 1
+; RUN: grep {sext i59 \{0,+,199\}<bb> to i64} %t | count 1
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i386-apple-darwin9.6"
+
+define i64 @foo(i64* nocapture %x, i64 %n) nounwind {
+entry:
+ %t0 = icmp sgt i64 %n, 0 ; <i1> [#uses=1]
+ br i1 %t0, label %bb, label %return
+
+bb: ; preds = %bb, %entry
+ %i.01 = phi i64 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2]
+ %t1 = shl i64 %i.01, 7 ; <i32> [#uses=1]
+ %t2 = ashr i64 %t1, 7 ; <i32> [#uses=1]
+ %s1 = shl i64 %i.01, 5 ; <i32> [#uses=1]
+ %s2 = ashr i64 %s1, 5 ; <i32> [#uses=1]
+ %t3 = getelementptr i64* %x, i64 %i.01 ; <i64*> [#uses=1]
+ store i64 0, i64* %t3, align 1
+ %indvar.next = add i64 %i.01, 199 ; <i32> [#uses=2]
+ %exitcond = icmp eq i64 %indvar.next, %n ; <i1> [#uses=1]
+ br i1 %exitcond, label %return, label %bb
+
+return: ; preds = %bb, %entry
+ %p = phi i64 [ 0, %entry ], [ %t2, %bb ]
+ %q = phi i64 [ 0, %entry ], [ %s2, %bb ]
+ %v = xor i64 %p, %q
+ ret i64 %v
+}
diff --git a/test/Analysis/ScalarEvolution/sext-iv-0.ll b/test/Analysis/ScalarEvolution/sext-iv-0.ll
new file mode 100644
index 000000000000..4b2fcea0df9a
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/sext-iv-0.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -disable-output -scalar-evolution -analyze \
+; RUN: | grep { --> \{-128,+,1\}<bb1> Exits: 127} | count 5
+
+; Convert (sext {-128,+,1}) to {sext(-128),+,sext(1)}, since the
+; trip count is within range where this is safe.
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo(double* nocapture %x) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
+ %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
+ %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
+ %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
+ %3 = getelementptr double* %x, i64 %2 ; <double*> [#uses=1]
+ %4 = load double* %3, align 8 ; <double> [#uses=1]
+ %5 = mul double %4, 3.900000e+00 ; <double> [#uses=1]
+ %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
+ %7 = getelementptr double* %x, i64 %6 ; <double*> [#uses=1]
+ store double %5, double* %7, align 8
+ %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
+ %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
+ br i1 %9, label %return, label %bb1
+
+return: ; preds = %bb1
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/sext-iv-1.ll b/test/Analysis/ScalarEvolution/sext-iv-1.ll
new file mode 100644
index 000000000000..a9175c31d067
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/sext-iv-1.ll
@@ -0,0 +1,100 @@
+; RUN: llvm-as < %s | opt -disable-output -scalar-evolution -analyze \
+; RUN: | grep { --> (sext i. \{.\*,+,.\*\}<bb1> to i64)} | count 5
+
+; Don't convert (sext {...,+,...}) to {sext(...),+,sext(...)} in cases
+; where the trip count is not within range.
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo0(double* nocapture %x) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
+ %0 = trunc i64 %i.0.reg2mem.0 to i7 ; <i8> [#uses=1]
+ %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
+ %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
+ %3 = getelementptr double* %x, i64 %2 ; <double*> [#uses=1]
+ %4 = load double* %3, align 8 ; <double> [#uses=1]
+ %5 = mul double %4, 3.900000e+00 ; <double> [#uses=1]
+ %6 = sext i7 %0 to i64 ; <i64> [#uses=1]
+ %7 = getelementptr double* %x, i64 %6 ; <double*> [#uses=1]
+ store double %5, double* %7, align 8
+ %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
+ %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
+ br i1 %9, label %return, label %bb1
+
+return: ; preds = %bb1
+ ret void
+}
+
+define void @foo1(double* nocapture %x) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
+ %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
+ %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
+ %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
+ %3 = getelementptr double* %x, i64 %2 ; <double*> [#uses=1]
+ %4 = load double* %3, align 8 ; <double> [#uses=1]
+ %5 = mul double %4, 3.900000e+00 ; <double> [#uses=1]
+ %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
+ %7 = getelementptr double* %x, i64 %6 ; <double*> [#uses=1]
+ store double %5, double* %7, align 8
+ %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
+ %9 = icmp sgt i64 %8, 128 ; <i1> [#uses=1]
+ br i1 %9, label %return, label %bb1
+
+return: ; preds = %bb1
+ ret void
+}
+
+define void @foo2(double* nocapture %x) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %i.0.reg2mem.0 = phi i64 [ -129, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
+ %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
+ %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
+ %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
+ %3 = getelementptr double* %x, i64 %2 ; <double*> [#uses=1]
+ %4 = load double* %3, align 8 ; <double> [#uses=1]
+ %5 = mul double %4, 3.900000e+00 ; <double> [#uses=1]
+ %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
+ %7 = getelementptr double* %x, i64 %6 ; <double*> [#uses=1]
+ store double %5, double* %7, align 8
+ %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
+ %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
+ br i1 %9, label %return, label %bb1
+
+return: ; preds = %bb1
+ ret void
+}
+
+define void @foo3(double* nocapture %x) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
+ %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
+ %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
+ %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
+ %3 = getelementptr double* %x, i64 %2 ; <double*> [#uses=1]
+ %4 = load double* %3, align 8 ; <double> [#uses=1]
+ %5 = mul double %4, 3.900000e+00 ; <double> [#uses=1]
+ %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
+ %7 = getelementptr double* %x, i64 %6 ; <double*> [#uses=1]
+ store double %5, double* %7, align 8
+ %8 = add i64 %i.0.reg2mem.0, -1 ; <i64> [#uses=2]
+ %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
+ br i1 %9, label %return, label %bb1
+
+return: ; preds = %bb1
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/smax.ll b/test/Analysis/ScalarEvolution/smax.ll
new file mode 100644
index 000000000000..4818ee97f250
--- /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/Analysis/ScalarEvolution/trip-count.ll b/test/Analysis/ScalarEvolution/trip-count.ll
new file mode 100644
index 000000000000..f8894d6428ff
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/trip-count.ll
@@ -0,0 +1,29 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution \
+; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 10000}
+; PR1101
+
+@A = weak global [1000 x i32] zeroinitializer, align 32
+
+
+define void @test(i32 %N) {
+entry:
+ "alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ br label %bb3
+
+bb: ; preds = %bb3
+ %tmp = getelementptr [1000 x i32]* @A, i32 0, i32 %i.0 ; <i32*> [#uses=1]
+ store i32 123, i32* %tmp
+ %tmp2 = add i32 %i.0, 1 ; <i32> [#uses=1]
+ br label %bb3
+
+bb3: ; preds = %bb, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %tmp2, %bb ] ; <i32> [#uses=3]
+ %tmp3 = icmp sle i32 %i.0, 9999 ; <i1> [#uses=1]
+ br i1 %tmp3, label %bb, label %bb5
+
+bb5: ; preds = %bb3
+ br label %return
+
+return: ; preds = %bb5
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/trip-count2.ll b/test/Analysis/ScalarEvolution/trip-count2.ll
new file mode 100644
index 000000000000..8615c76db69c
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/trip-count2.ll
@@ -0,0 +1,35 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | \
+; RUN: grep {backedge-taken count is 4}
+; PR1101
+
+@A = weak global [1000 x i32] zeroinitializer, align 32
+
+
+define void @test(i32 %N) {
+entry:
+ "alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ br label %bb3
+
+bb: ; preds = %bb3
+ %tmp = getelementptr [1000 x i32]* @A, i32 0, i32 %i.0 ; <i32*> [#uses=1]
+ store i32 123, i32* %tmp
+ %tmp4 = mul i32 %i.0, 4 ; <i32> [#uses=1]
+ %tmp5 = or i32 %tmp4, 1
+ %tmp61 = xor i32 %tmp5, -2147483648
+ %tmp6 = trunc i32 %tmp61 to i16
+ %tmp71 = shl i16 %tmp6, 2
+ %tmp7 = zext i16 %tmp71 to i32
+ %tmp2 = add i32 %tmp7, %i.0
+ br label %bb3
+
+bb3: ; preds = %bb, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %tmp2, %bb ] ; <i32> [#uses=3]
+ %tmp3 = icmp sle i32 %i.0, 9999 ; <i1> [#uses=1]
+ br i1 %tmp3, label %bb, label %bb5
+
+bb5: ; preds = %bb3
+ br label %return
+
+return: ; preds = %bb5
+ ret void
+}
diff --git a/test/Analysis/ScalarEvolution/trip-count3.ll b/test/Analysis/ScalarEvolution/trip-count3.ll
new file mode 100644
index 000000000000..a95138f0ef47
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/trip-count3.ll
@@ -0,0 +1,74 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output \
+; RUN: | grep {backedge-taken count is ((64 + (-64 smax (-1 + (-1 \\* %0))) + %0) /u 64)}
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+ %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
+ %struct.SHA_INFO = type { [5 x i32], i32, i32, [16 x i32] }
+ %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 }
+@_2E_str = external constant [26 x i8] ; <[26 x i8]*> [#uses=0]
+@stdin = external global %struct.FILE* ; <%struct.FILE**> [#uses=0]
+@_2E_str1 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
+@_2E_str12 = external constant [30 x i8] ; <[30 x i8]*> [#uses=0]
+
+declare void @sha_init(%struct.SHA_INFO* nocapture) nounwind
+
+declare fastcc void @sha_transform(%struct.SHA_INFO* nocapture) nounwind
+
+declare void @sha_print(%struct.SHA_INFO* nocapture) nounwind
+
+declare i32 @printf(i8* nocapture, ...) nounwind
+
+declare void @sha_final(%struct.SHA_INFO* nocapture) nounwind
+
+declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind
+
+declare void @sha_update(%struct.SHA_INFO* nocapture, i8* nocapture, i32) nounwind
+
+declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind
+
+declare i64 @fread(i8* noalias nocapture, i64, i64, %struct.FILE* noalias nocapture) nounwind
+
+declare i32 @main(i32, i8** nocapture) nounwind
+
+declare noalias %struct.FILE* @fopen(i8* noalias nocapture, i8* noalias nocapture) nounwind
+
+declare i32 @fclose(%struct.FILE* nocapture) nounwind
+
+declare void @sha_stream(%struct.SHA_INFO* nocapture, %struct.FILE* nocapture) nounwind
+
+define void @sha_stream_bb3_2E_i(%struct.SHA_INFO* %sha_info, i8* %data1, i32, i8** %buffer_addr.0.i.out, i32* %count_addr.0.i.out) nounwind {
+newFuncRoot:
+ br label %bb3.i
+
+sha_update.exit.exitStub: ; preds = %bb3.i
+ store i8* %buffer_addr.0.i, i8** %buffer_addr.0.i.out
+ store i32 %count_addr.0.i, i32* %count_addr.0.i.out
+ ret void
+
+bb2.i: ; preds = %bb3.i
+ %1 = getelementptr %struct.SHA_INFO* %sha_info, i64 0, i32 3 ; <[16 x i32]*> [#uses=1]
+ %2 = bitcast [16 x i32]* %1 to i8* ; <i8*> [#uses=1]
+ call void @llvm.memcpy.i64(i8* %2, i8* %buffer_addr.0.i, i64 64, i32 1) nounwind
+ %3 = getelementptr %struct.SHA_INFO* %sha_info, i64 0, i32 3, i64 0 ; <i32*> [#uses=1]
+ %4 = bitcast i32* %3 to i8* ; <i8*> [#uses=1]
+ br label %codeRepl
+
+codeRepl: ; preds = %bb2.i
+ call void @sha_stream_bb3_2E_i_bb1_2E_i_2E_i(i8* %4)
+ br label %byte_reverse.exit.i
+
+byte_reverse.exit.i: ; preds = %codeRepl
+ call fastcc void @sha_transform(%struct.SHA_INFO* %sha_info) nounwind
+ %5 = getelementptr i8* %buffer_addr.0.i, i64 64 ; <i8*> [#uses=1]
+ %6 = add i32 %count_addr.0.i, -64 ; <i32> [#uses=1]
+ br label %bb3.i
+
+bb3.i: ; preds = %byte_reverse.exit.i, %newFuncRoot
+ %buffer_addr.0.i = phi i8* [ %data1, %newFuncRoot ], [ %5, %byte_reverse.exit.i ] ; <i8*> [#uses=3]
+ %count_addr.0.i = phi i32 [ %0, %newFuncRoot ], [ %6, %byte_reverse.exit.i ] ; <i32> [#uses=3]
+ %7 = icmp sgt i32 %count_addr.0.i, 63 ; <i1> [#uses=1]
+ br i1 %7, label %bb2.i, label %sha_update.exit.exitStub
+}
+
+declare void @sha_stream_bb3_2E_i_bb1_2E_i_2E_i(i8*) nounwind
diff --git a/test/Analysis/ScalarEvolution/trip-count4.ll b/test/Analysis/ScalarEvolution/trip-count4.ll
new file mode 100644
index 000000000000..a61d5da57ea9
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/trip-count4.ll
@@ -0,0 +1,24 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
+; RUN: | grep {sext.*trunc.*Exits: 11}
+
+; ScalarEvolution should be able to compute a loop exit value for %indvar.i8.
+
+define void @another_count_down_signed(double* %d, i64 %n) nounwind {
+entry:
+ br label %loop
+
+loop: ; preds = %loop, %entry
+ %indvar = phi i64 [ %n, %entry ], [ %indvar.next, %loop ] ; <i64> [#uses=4]
+ %s0 = shl i64 %indvar, 8 ; <i64> [#uses=1]
+ %indvar.i8 = ashr i64 %s0, 8 ; <i64> [#uses=1]
+ %t0 = getelementptr double* %d, i64 %indvar.i8 ; <double*> [#uses=2]
+ %t1 = load double* %t0 ; <double> [#uses=1]
+ %t2 = mul double %t1, 1.000000e-01 ; <double> [#uses=1]
+ store double %t2, double* %t0
+ %indvar.next = sub i64 %indvar, 1 ; <i64> [#uses=2]
+ %exitcond = icmp eq i64 %indvar.next, 10 ; <i1> [#uses=1]
+ br i1 %exitcond, label %return, label %loop
+
+return: ; preds = %loop
+ ret void
+}