diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:10:27 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:10:27 +0000 |
commit | 30815c536baacc07e925f0aef23a5395883173dc (patch) | |
tree | 2cbcf22585e99f8a87d12d5ff94f392c0d266819 /test/Analysis | |
parent | 411bd29eea3c360d5b48a18a17b5e87f5671af0e (diff) |
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll | 4 | ||||
-rw-r--r-- | test/Analysis/BasicAA/cas.ll | 4 | ||||
-rw-r--r-- | test/Analysis/BasicAA/gep-alias.ll | 32 | ||||
-rw-r--r-- | test/Analysis/BasicAA/memset_pattern.ll | 21 | ||||
-rw-r--r-- | test/Analysis/BasicAA/modref.ll | 17 | ||||
-rw-r--r-- | test/Analysis/BlockFrequencyInfo/basic.ll | 92 | ||||
-rw-r--r-- | test/Analysis/BlockFrequencyInfo/dg.exp | 3 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll | 50 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll | 56 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/avoid-smax-1.ll | 7 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/max-trip-count.ll | 28 |
11 files changed, 301 insertions, 13 deletions
diff --git a/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll b/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll index 5078dd53a79f..4b6a12e821e1 100644 --- a/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll +++ b/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll @@ -1,14 +1,12 @@ ; RUN: opt -basicaa -gvn -instcombine -S < %s | FileCheck %s target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" -declare i8 @llvm.atomic.load.add.i8.p0i8(i8*, i8) - define i8 @foo(i8* %ptr) { %P = getelementptr i8* %ptr, i32 0 %Q = getelementptr i8* %ptr, i32 1 ; CHECK: getelementptr %X = load i8* %P - %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) + %Y = atomicrmw add i8* %Q, i8 1 monotonic %Z = load i8* %P ; CHECK-NOT: = load %A = sub i8 %X, %Z diff --git a/test/Analysis/BasicAA/cas.ll b/test/Analysis/BasicAA/cas.ll index 8dd3695d6d57..754309cd81bb 100644 --- a/test/Analysis/BasicAA/cas.ll +++ b/test/Analysis/BasicAA/cas.ll @@ -6,10 +6,8 @@ define i32 @main() { %a = load i32* @flag0 - %b = tail call i32 @llvm.atomic.swap.i32.p0i32(i32* @turn, i32 1) + %b = atomicrmw xchg i32* @turn, i32 1 monotonic %c = load i32* @flag0 %d = sub i32 %a, %c ret i32 %d } - -declare i32 @llvm.atomic.swap.i32.p0i32(i32*, i32) nounwind diff --git a/test/Analysis/BasicAA/gep-alias.ll b/test/Analysis/BasicAA/gep-alias.ll index 69f7fafaca07..4bb28326612c 100644 --- a/test/Analysis/BasicAA/gep-alias.ll +++ b/test/Analysis/BasicAA/gep-alias.ll @@ -169,3 +169,35 @@ define i8 @test10([4 x i8] *%P, i32 %i) { ; CHECK: @test10 ; CHECK: ret i8 0 } + +; (This was a miscompilation.) +define float @test11(i32 %indvar, [4 x [2 x float]]* %q) nounwind ssp { + %tmp = mul i32 %indvar, -1 + %dec = add i32 %tmp, 3 + %scevgep = getelementptr [4 x [2 x float]]* %q, i32 0, i32 %dec + %scevgep35 = bitcast [2 x float]* %scevgep to i64* + %arrayidx28 = getelementptr inbounds [4 x [2 x float]]* %q, i32 0, i32 0 + %y29 = getelementptr inbounds [2 x float]* %arrayidx28, i32 0, i32 1 + store float 1.0, float* %y29, align 4 + store i64 0, i64* %scevgep35, align 4 + %tmp30 = load float* %y29, align 4 + ret float %tmp30 + ; CHECK: @test11 + ; CHECK: ret float %tmp30 +} + +; (This was a miscompilation.) +define i32 @test12(i32 %x, i32 %y, i8* %p) nounwind { + %a = bitcast i8* %p to [13 x i8]* + %b = getelementptr [13 x i8]* %a, i32 %x + %c = bitcast [13 x i8]* %b to [15 x i8]* + %d = getelementptr [15 x i8]* %c, i32 %y, i32 8 + %castd = bitcast i8* %d to i32* + %castp = bitcast i8* %p to i32* + store i32 1, i32* %castp + store i32 0, i32* %castd + %r = load i32* %castp + ret i32 %r + ; CHECK: @test12 + ; CHECK: ret i32 %r +} diff --git a/test/Analysis/BasicAA/memset_pattern.ll b/test/Analysis/BasicAA/memset_pattern.ll new file mode 100644 index 000000000000..590664c5084e --- /dev/null +++ b/test/Analysis/BasicAA/memset_pattern.ll @@ -0,0 +1,21 @@ +; RUN: opt -S -basicaa -gvn < %s | FileCheck %s +; PR10872 +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" +target triple = "x86_64-apple-macosx10.7" + +@z = internal global i32 0, align 4 +@y = internal global i32 0, align 4 +@x = internal constant i32 0, align 4 + +; CHECK: @test +define i32 @test() nounwind uwtable ssp { +entry: + store i32 1, i32* @z + tail call void @memset_pattern16(i8* bitcast (i32* @y to i8*), i8* bitcast (i32* @x to i8*), i64 4) nounwind +; CHECK-NOT: load + %l = load i32* @z +; CHECK: ret i32 1 + ret i32 %l +} + +declare void @memset_pattern16(i8*, i8*, i64) diff --git a/test/Analysis/BasicAA/modref.ll b/test/Analysis/BasicAA/modref.ll index 233396b7e5ca..8421faf9c2c4 100644 --- a/test/Analysis/BasicAA/modref.ll +++ b/test/Analysis/BasicAA/modref.ll @@ -129,8 +129,23 @@ define i8 @test6(i8* %p, i8* noalias %a) { ; CHECK: ret } +; PR10628 +declare void @test7decl(i32* nocapture %x) +define i32 @test7() nounwind uwtable ssp { +entry: + %x = alloca i32, align 4 + store i32 0, i32* %x, align 4 + %add.ptr = getelementptr inbounds i32* %x, i64 1 + call void @test7decl(i32* %add.ptr) + %tmp = load i32* %x, align 4 + ret i32 %tmp +; CHECK: @test7( +; CHECK: store i32 0 +; CHECK: call void @test7decl +; CHECK: load i32* +} + declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i32, i1) nounwind declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i32, i1) nounwind declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind - diff --git a/test/Analysis/BlockFrequencyInfo/basic.ll b/test/Analysis/BlockFrequencyInfo/basic.ll new file mode 100644 index 000000000000..540d06b1f562 --- /dev/null +++ b/test/Analysis/BlockFrequencyInfo/basic.ll @@ -0,0 +1,92 @@ +; RUN: opt < %s -analyze -block-freq | FileCheck %s + +define i32 @test1(i32 %i, i32* %a) { +; CHECK: Printing analysis {{.*}} for function 'test1' +; CHECK: entry = 1024 +entry: + br label %body + +; Loop backedges are weighted and thus their bodies have a greater frequency. +; CHECK: body = 31744 +body: + %iv = phi i32 [ 0, %entry ], [ %next, %body ] + %base = phi i32 [ 0, %entry ], [ %sum, %body ] + %arrayidx = getelementptr inbounds i32* %a, i32 %iv + %0 = load i32* %arrayidx + %sum = add nsw i32 %0, %base + %next = add i32 %iv, 1 + %exitcond = icmp eq i32 %next, %i + br i1 %exitcond, label %exit, label %body + +; CHECK: exit = 1024 +exit: + ret i32 %sum +} + +define i32 @test2(i32 %i, i32 %a, i32 %b) { +; CHECK: Printing analysis {{.*}} for function 'test2' +; CHECK: entry = 1024 +entry: + %cond = icmp ult i32 %i, 42 + br i1 %cond, label %then, label %else, !prof !0 + +; The 'then' branch is predicted more likely via branch weight metadata. +; CHECK: then = 963 +then: + br label %exit + +; CHECK: else = 60 +else: + br label %exit + +; FIXME: It may be a bug that we don't sum back to 1024. +; CHECK: exit = 1023 +exit: + %result = phi i32 [ %a, %then ], [ %b, %else ] + ret i32 %result +} + +!0 = metadata !{metadata !"branch_weights", i32 64, i32 4} + +define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { +; CHECK: Printing analysis {{.*}} for function 'test3' +; CHECK: entry = 1024 +entry: + switch i32 %i, label %case_a [ i32 1, label %case_b + i32 2, label %case_c + i32 3, label %case_d + i32 4, label %case_e ], !prof !1 + +; CHECK: case_a = 51 +case_a: + br label %exit + +; CHECK: case_b = 51 +case_b: + br label %exit + +; The 'case_c' branch is predicted more likely via branch weight metadata. +; CHECK: case_c = 819 +case_c: + br label %exit + +; CHECK: case_d = 51 +case_d: + br label %exit + +; CHECK: case_e = 51 +case_e: + br label %exit + +; FIXME: It may be a bug that we don't sum back to 1024. +; CHECK: exit = 1023 +exit: + %result = phi i32 [ %a, %case_a ], + [ %b, %case_b ], + [ %c, %case_c ], + [ %d, %case_d ], + [ %e, %case_e ] + ret i32 %result +} + +!1 = metadata !{metadata !"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4} diff --git a/test/Analysis/BlockFrequencyInfo/dg.exp b/test/Analysis/BlockFrequencyInfo/dg.exp new file mode 100644 index 000000000000..f2005891a59a --- /dev/null +++ b/test/Analysis/BlockFrequencyInfo/dg.exp @@ -0,0 +1,3 @@ +load_lib llvm.exp + +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] 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 000000000000..29bb64ad642b --- /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 ec95141fbe92..06f1b6fe33a6 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 474d564c70c6..e90a55559d7f 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 843fb073087c..0cdbdf57a64c 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 |