diff options
Diffstat (limited to 'test/Analysis/ScalarEvolution')
-rw-r--r-- | test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll | 3 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/2012-03-26-LoadConstant.ll | 47 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/avoid-smax-1.ll | 20 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/dg.exp | 3 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/lit.local.cfg | 1 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/load.ll | 65 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/nsw-offset.ll | 6 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/nsw.ll | 24 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/trip-count11.ll | 29 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/trip-count12.ll | 35 |
10 files changed, 212 insertions, 21 deletions
diff --git a/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll b/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll index 4f14a0d9a5ea6..ce0329d9ce8c9 100644 --- a/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll +++ b/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll @@ -1,6 +1,7 @@ -; RUN: opt < %s -scalar-evolution -analyze | grep {Loop %loop: backedge-taken count is (100 + (-100 smax %n))} +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s ; PR2002 +; CHECK: Loop %loop: backedge-taken count is (100 + (-100 smax %n)) define void @foo(i8 %n) { entry: br label %loop diff --git a/test/Analysis/ScalarEvolution/2012-03-26-LoadConstant.ll b/test/Analysis/ScalarEvolution/2012-03-26-LoadConstant.ll new file mode 100644 index 0000000000000..138c015f12caf --- /dev/null +++ b/test/Analysis/ScalarEvolution/2012-03-26-LoadConstant.ll @@ -0,0 +1,47 @@ +; RUN: opt < %s -basicaa -globalopt -instcombine -loop-rotate -licm -instcombine -indvars -loop-deletion -constmerge -S +; PR11882: ComputeLoadConstantCompareExitLimit crash. +; +; for.body is deleted leaving a loop-invariant load. +; CHECK-NOT: for.body +target datalayout = "e-p:64:64:64-n32:64" + +@func_21_l_773 = external global i32, align 4 +@g_814 = external global i32, align 4 +@g_244 = internal global [1 x [0 x i32]] zeroinitializer, align 4 + +define void @func_21() nounwind uwtable ssp { +entry: + br label %lbl_818 + +lbl_818: ; preds = %for.end, %entry + call void (...)* @func_27() + store i32 0, i32* @g_814, align 4, !tbaa !0 + br label %for.cond + +for.cond: ; preds = %for.body, %lbl_818 + %0 = load i32* @g_814, align 4, !tbaa !0 + %cmp = icmp sle i32 %0, 0 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %idxprom = sext i32 %0 to i64 + %arrayidx = getelementptr inbounds [0 x i32]* getelementptr inbounds ([1 x [0 x i32]]* @g_244, i32 0, i64 0), i32 0, i64 %idxprom + %1 = load i32* %arrayidx, align 1, !tbaa !0 + store i32 %1, i32* @func_21_l_773, align 4, !tbaa !0 + store i32 1, i32* @g_814, align 4, !tbaa !0 + br label %for.cond + +for.end: ; preds = %for.cond + %2 = load i32* @func_21_l_773, align 4, !tbaa !0 + %tobool = icmp ne i32 %2, 0 + br i1 %tobool, label %lbl_818, label %if.end + +if.end: ; preds = %for.end + ret void +} + +declare void @func_27(...) + +!0 = metadata !{metadata !"int", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA", null} diff --git a/test/Analysis/ScalarEvolution/avoid-smax-1.ll b/test/Analysis/ScalarEvolution/avoid-smax-1.ll index e90a55559d7f2..d9b83a929aa74 100644 --- a/test/Analysis/ScalarEvolution/avoid-smax-1.ll +++ b/test/Analysis/ScalarEvolution/avoid-smax-1.ll @@ -1,14 +1,12 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s - -; 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. -; CHECK: entry: -; CHECK-NOT: select -; CHECK: bb6: +; RUN: opt < %s -analyze -scalar-evolution -S | FileCheck %s + +; Indvars should be able to find the trip count 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. +; +; CHECK: Loop %bb6: backedge-taken count is (-1 + %w) 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" diff --git a/test/Analysis/ScalarEvolution/dg.exp b/test/Analysis/ScalarEvolution/dg.exp deleted file mode 100644 index b65a2503ac6f0..0000000000000 --- a/test/Analysis/ScalarEvolution/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.ll]] diff --git a/test/Analysis/ScalarEvolution/lit.local.cfg b/test/Analysis/ScalarEvolution/lit.local.cfg new file mode 100644 index 0000000000000..c6106e4746f2d --- /dev/null +++ b/test/Analysis/ScalarEvolution/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll'] diff --git a/test/Analysis/ScalarEvolution/load.ll b/test/Analysis/ScalarEvolution/load.ll new file mode 100644 index 0000000000000..2c753f5befcba --- /dev/null +++ b/test/Analysis/ScalarEvolution/load.ll @@ -0,0 +1,65 @@ +; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s + +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-n8:16:32" +target triple = "i386-pc-linux-gnu" + +@arr1 = internal unnamed_addr constant [50 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50], align 4 +@arr2 = internal unnamed_addr constant [50 x i32] [i32 49, i32 48, i32 47, i32 46, i32 45, i32 44, i32 43, i32 42, i32 41, i32 40, i32 39, i32 38, i32 37, i32 36, i32 35, i32 34, i32 33, i32 32, i32 31, i32 30, i32 29, i32 28, i32 27, i32 26, i32 25, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 17, i32 16, i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0], align 4 + +; PR11034 +define i32 @test1() nounwind readnone { +; CHECK: test1 +entry: + br label %for.body + +for.body: ; preds = %entry, %for.body + %sum.04 = phi i32 [ 0, %entry ], [ %add2, %for.body ] +; CHECK: --> %sum.04{{ *}}Exits: 2450 + %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds [50 x i32]* @arr1, i32 0, i32 %i.03 + %0 = load i32* %arrayidx, align 4 +; CHECK: --> %0{{ *}}Exits: 50 + %arrayidx1 = getelementptr inbounds [50 x i32]* @arr2, i32 0, i32 %i.03 + %1 = load i32* %arrayidx1, align 4 +; CHECK: --> %1{{ *}}Exits: 0 + %add = add i32 %0, %sum.04 + %add2 = add i32 %add, %1 + %inc = add nsw i32 %i.03, 1 + %cmp = icmp eq i32 %inc, 50 + br i1 %cmp, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret i32 %add2 +} + + +%struct.ListNode = type { %struct.ListNode*, i32 } + +@node5 = internal constant { %struct.ListNode*, i32, [4 x i8] } { %struct.ListNode* bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node4 to %struct.ListNode*), i32 4, [4 x i8] undef }, align 8 +@node4 = internal constant { %struct.ListNode*, i32, [4 x i8] } { %struct.ListNode* bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node3 to %struct.ListNode*), i32 3, [4 x i8] undef }, align 8 +@node3 = internal constant { %struct.ListNode*, i32, [4 x i8] } { %struct.ListNode* bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node2 to %struct.ListNode*), i32 2, [4 x i8] undef }, align 8 +@node2 = internal constant { %struct.ListNode*, i32, [4 x i8] } { %struct.ListNode* bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node1 to %struct.ListNode*), i32 1, [4 x i8] undef }, align 8 +@node1 = internal constant { %struct.ListNode*, i32, [4 x i8] } { %struct.ListNode* null, i32 0, [4 x i8] undef }, align 8 + +define i32 @test2() nounwind uwtable readonly { +; CHECK: test2 +entry: + br label %for.body + +for.body: ; preds = %entry, %for.body + %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ] +; CHECK: --> %sum.02{{ *}}Exits: 10 + %n.01 = phi %struct.ListNode* [ bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node5 to %struct.ListNode*), %entry ], [ %1, %for.body ] +; CHECK: --> %n.01{{ *}}Exits: @node1 + %i = getelementptr inbounds %struct.ListNode* %n.01, i64 0, i32 1 + %0 = load i32* %i, align 4 + %add = add nsw i32 %0, %sum.02 + %next = getelementptr inbounds %struct.ListNode* %n.01, i64 0, i32 0 + %1 = load %struct.ListNode** %next, align 8 +; CHECK: --> %1{{ *}}Exits: 0 + %cmp = icmp eq %struct.ListNode* %1, null + br i1 %cmp, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret i32 %add +} diff --git a/test/Analysis/ScalarEvolution/nsw-offset.ll b/test/Analysis/ScalarEvolution/nsw-offset.ll index 8969a5ad4ceb2..a919319bdcd50 100644 --- a/test/Analysis/ScalarEvolution/nsw-offset.ll +++ b/test/Analysis/ScalarEvolution/nsw-offset.ll @@ -23,7 +23,7 @@ bb: ; preds = %bb.nph, %bb1 %1 = sext i32 %i.01 to i64 ; <i64> [#uses=1] ; CHECK: %2 = getelementptr inbounds double* %d, i64 %1 -; CHECK: --> {%d,+,16}<nsw><%bb> +; CHECK: --> {%d,+,16}<nuw><%bb> %2 = getelementptr inbounds double* %d, i64 %1 ; <double*> [#uses=1] %3 = load double* %2, align 8 ; <double> [#uses=1] @@ -37,7 +37,7 @@ bb: ; preds = %bb.nph, %bb1 %8 = sext i32 %7 to i64 ; <i64> [#uses=1] ; CHECK: %9 = getelementptr inbounds double* %q, i64 %8 -; CHECK: {(8 + %q),+,16}<nsw><%bb> +; CHECK: {(8 + %q),+,16}<nuw><%bb> %9 = getelementptr inbounds double* %q, i64 %8 ; <double*> [#uses=1] ; Artificially repeat the above three instructions, this time using @@ -49,7 +49,7 @@ bb: ; preds = %bb.nph, %bb1 %t8 = sext i32 %t7 to i64 ; <i64> [#uses=1] ; CHECK: %t9 = getelementptr inbounds double* %q, i64 %t8 -; CHECK: {(8 + %q),+,16}<nsw><%bb> +; CHECK: {(8 + %q),+,16}<nuw><%bb> %t9 = getelementptr inbounds double* %q, i64 %t8 ; <double*> [#uses=1] %10 = load double* %9, align 8 ; <double> [#uses=1] diff --git a/test/Analysis/ScalarEvolution/nsw.ll b/test/Analysis/ScalarEvolution/nsw.ll index da35a6cf7ae24..288b6facd94dd 100644 --- a/test/Analysis/ScalarEvolution/nsw.ll +++ b/test/Analysis/ScalarEvolution/nsw.ll @@ -92,10 +92,10 @@ for.body.i.i: ; preds = %entry, %for.body.i. ; CHECK: {1,+,1}<nuw><nsw><%for.body.i.i> %ptrincdec.i.i = getelementptr inbounds i32* %begin, i64 %tmp ; CHECK: %ptrincdec.i.i = -; CHECK: {(4 + %begin),+,4}<nsw><%for.body.i.i> +; CHECK: {(4 + %begin),+,4}<nuw><%for.body.i.i> %__first.addr.08.i.i = getelementptr inbounds i32* %begin, i64 %indvar.i.i ; CHECK: %__first.addr.08.i.i -; CHECK: {%begin,+,4}<nsw><%for.body.i.i> +; CHECK: {%begin,+,4}<nuw><%for.body.i.i> store i32 0, i32* %__first.addr.08.i.i, align 4 %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end br i1 %cmp.i.i, label %_ZSt4fillIPiiEvT_S1_RKT0_.exit, label %for.body.i.i @@ -103,4 +103,22 @@ for.body.i.i: ; preds = %entry, %for.body.i. ; CHECK: Loop %for.body.i.i: max backedge-taken count is ((-4 + (-1 * %begin) + %end) /u 4) _ZSt4fillIPiiEvT_S1_RKT0_.exit: ; preds = %for.body.i.i, %entry ret void -}
\ No newline at end of file +} + +; A single AddExpr exists for (%a + %b), which is not always <nsw>. +; CHECK: @addnsw +; CHECK-NOT: --> (%a + %b)<nsw> +define i32 @addnsw(i32 %a, i32 %b) nounwind ssp { +entry: + %tmp = add i32 %a, %b + %cmp = icmp sgt i32 %tmp, 0 + br i1 %cmp, label %greater, label %exit + +greater: + %tmp2 = add nsw i32 %a, %b + br label %exit + +exit: + %result = phi i32 [ %a, %entry ], [ %tmp2, %greater ] + ret i32 %result +} diff --git a/test/Analysis/ScalarEvolution/trip-count11.ll b/test/Analysis/ScalarEvolution/trip-count11.ll new file mode 100644 index 0000000000000..71915037ec8ba --- /dev/null +++ b/test/Analysis/ScalarEvolution/trip-count11.ll @@ -0,0 +1,29 @@ +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +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-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@foo.a = internal constant [8 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7], align 16 + +define i32 @foo() nounwind uwtable noinline { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ] +; CHECK: --> %sum.0 Exits: 28 + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %cmp = icmp ult i32 %i.0, 8 + br i1 %cmp, label %for.inc, label %for.end + +for.inc: ; preds = %for.cond + %idxprom = sext i32 %i.0 to i64 + %arrayidx = getelementptr inbounds [8 x i32]* @foo.a, i64 0, i64 %idxprom + %0 = load i32* %arrayidx, align 4 + %add = add nsw i32 %sum.0, %0 + %inc = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret i32 %sum.0 +} diff --git a/test/Analysis/ScalarEvolution/trip-count12.ll b/test/Analysis/ScalarEvolution/trip-count12.ll new file mode 100644 index 0000000000000..8f960e1c1c770 --- /dev/null +++ b/test/Analysis/ScalarEvolution/trip-count12.ll @@ -0,0 +1,35 @@ +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; CHECK: Determining loop execution counts for: @test +; CHECK: Loop %for.body: backedge-taken count is ((-2 + %len) /u 2) +; CHECK: Loop %for.body: max backedge-taken count is 1073741823 + +define zeroext i16 @test(i16* nocapture %p, i32 %len) nounwind readonly { +entry: + %cmp2 = icmp sgt i32 %len, 1 + br i1 %cmp2, label %for.body.preheader, label %for.end + +for.body.preheader: ; preds = %entry + br label %for.body + +for.body: ; preds = %for.body, %for.body.preheader + %p.addr.05 = phi i16* [ %incdec.ptr, %for.body ], [ %p, %for.body.preheader ] + %len.addr.04 = phi i32 [ %sub, %for.body ], [ %len, %for.body.preheader ] + %res.03 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ] + %incdec.ptr = getelementptr inbounds i16* %p.addr.05, i32 1 + %0 = load i16* %p.addr.05, align 2 + %conv = zext i16 %0 to i32 + %add = add i32 %conv, %res.03 + %sub = add nsw i32 %len.addr.04, -2 + %cmp = icmp sgt i32 %sub, 1 + br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge + +for.cond.for.end_crit_edge: ; preds = %for.body + %extract.t = trunc i32 %add to i16 + br label %for.end + +for.end: ; preds = %for.cond.for.end_crit_edge, %entry + %res.0.lcssa.off0 = phi i16 [ %extract.t, %for.cond.for.end_crit_edge ], [ 0, %entry ] + ret i16 %res.0.lcssa.off0 +} + |