diff options
Diffstat (limited to 'test/Analysis/ScalarEvolution')
4 files changed, 135 insertions, 6 deletions
diff --git a/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll b/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll new file mode 100644 index 0000000000000..29bb64ad642b9 --- /dev/null +++ b/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll @@ -0,0 +1,50 @@ +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; Exercise getConstantEvolvingPHIOperands on an interesting loop. +; This should complete in milliseconds, not minutes. + +; Just check that it actually ran trip count analysis. +; CHECK: Determining loop execution counts for: @test +define void @test() nounwind { +entry: + br label %loop + +loop: + %iv = phi i32 [ %30, %loop ], [ 0, %entry ] + %0 = add i32 %iv, 1 + %1 = add i32 %0, 2 + %2 = add i32 %1, %0 + %3 = add i32 %2, %1 + %4 = add i32 %3, %2 + %5 = add i32 %4, %3 + %6 = add i32 %5, %4 + %7 = add i32 %6, %5 + %8 = add i32 %7, %6 + %9 = add i32 %8, %7 + %10 = add i32 %9, %8 + %11 = add i32 %10, %9 + %12 = add i32 %11, %10 + %13 = add i32 %12, %11 + %14 = add i32 %13, %12 + %15 = add i32 %14, %13 + %16 = add i32 %15, %14 + %17 = add i32 %16, %15 + %18 = add i32 %17, %16 + %19 = add i32 %18, %17 + %20 = add i32 %19, %18 + %21 = add i32 %20, %19 + %22 = add i32 %21, %20 + %23 = add i32 %22, %21 + %24 = add i32 %23, %22 + %25 = add i32 %24, %23 + %26 = add i32 %25, %24 + %27 = add i32 %26, %25 + %28 = add i32 %27, %26 + %29 = add i32 %28, %27 + %30 = add i32 %29, %28 + %cmp = icmp eq i32 %30, -108 + br i1 %cmp, label %exit, label %loop + +exit: + unreachable +} diff --git a/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll b/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll index ec95141fbe925..06f1b6fe33a62 100644 --- a/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll +++ b/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll @@ -1,11 +1,11 @@ ; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 100} +; RUN: -scalar-evolution-max-iterations=0 | FileCheck %s + ; PR1101 @A = weak global [1000 x i32] zeroinitializer, align 32 - -define void @test(i32 %N) { +define void @test1(i32 %N) { entry: %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] br label %bb3 @@ -30,3 +30,53 @@ bb5: ; preds = %bb3 return: ; preds = %bb5 ret void } +; CHECK: Determining loop execution counts for: @test1 +; CHECK-NEXT: backedge-taken count is 100 + + +; PR10383 +; These next two used to crash. + +define void @test2(i1 %cmp, i64 %n) { +entry: + br label %for.body1 + +for.body1: + %a0.08 = phi i64 [ 0, %entry ], [ %inc512, %for.body1 ] + %inc512 = add i64 %a0.08, 1 + br i1 %cmp, label %preheader, label %for.body1 + +preheader: + br label %for.body2 + +for.body2: + %indvar = phi i64 [ 0, %preheader ], [ %indvar.next, %for.body2 ] + %tmp111 = add i64 %n, %indvar + %tmp114 = mul i64 %a0.08, %indvar + %mul542 = mul i64 %tmp114, %tmp111 + %indvar.next = add i64 %indvar, 1 + br i1 undef, label %end, label %for.body2 + +end: + ret void +} +; CHECK: Determining loop execution counts for: @test2 + +define i32 @test3() { +if.then466: + br i1 undef, label %for.cond539.preheader, label %for.inc479 + +for.inc479: + %a2.07 = phi i32 [ %add495, %for.inc479 ], [ 0, %if.then466 ] + %j.36 = phi i32 [ %inc497, %for.inc479 ], [ undef, %if.then466 ] + %mul484 = mul nsw i32 %j.36, %j.36 + %mul491 = mul i32 %j.36, %j.36 + %mul493 = mul i32 %mul491, %mul484 + %add495 = add nsw i32 %mul493, %a2.07 + %inc497 = add nsw i32 %j.36, 1 + br i1 undef, label %for.cond539.preheader, label %for.inc479 + +for.cond539.preheader: + unreachable +} +; CHECK: Determining loop execution counts for: @test3 diff --git a/test/Analysis/ScalarEvolution/avoid-smax-1.ll b/test/Analysis/ScalarEvolution/avoid-smax-1.ll index 474d564c70c6e..e90a55559d7f2 100644 --- a/test/Analysis/ScalarEvolution/avoid-smax-1.ll +++ b/test/Analysis/ScalarEvolution/avoid-smax-1.ll @@ -1,6 +1,4 @@ -; RUN: opt < %s -indvars -S > %t -; RUN: grep select %t | count 2 -; RUN: grep {icmp ne i32.\* } %t +; 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) @@ -8,6 +6,9 @@ ; 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: 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/max-trip-count.ll b/test/Analysis/ScalarEvolution/max-trip-count.ll index 843fb073087c6..0cdbdf57a64ca 100644 --- a/test/Analysis/ScalarEvolution/max-trip-count.ll +++ b/test/Analysis/ScalarEvolution/max-trip-count.ll @@ -70,3 +70,31 @@ for.end: ; preds = %for.body, %for.cond } declare i32 @printf(i8*, ...) + +define void @test(i8* %a, i32 %n) nounwind { +entry: + %cmp1 = icmp sgt i32 %n, 0 + br i1 %cmp1, label %for.body.lr.ph, label %for.end + +for.body.lr.ph: ; preds = %entry + %tmp = zext i32 %n to i64 + br label %for.body + +for.body: ; preds = %for.body, %for.body.lr.ph + %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.lr.ph ] + %arrayidx = getelementptr i8* %a, i64 %indvar + store i8 0, i8* %arrayidx, align 1 + %indvar.next = add i64 %indvar, 1 + %exitcond = icmp ne i64 %indvar.next, %tmp + br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge + +for.cond.for.end_crit_edge: ; preds = %for.body + br label %for.end + +for.end: ; preds = %for.cond.for.end_crit_edge, %entry + ret void +} + +; CHECK: Determining loop execution counts for: @test +; CHECK-NEXT: backedge-taken count is +; CHECK-NEXT: max backedge-taken count is -1 |
