diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /test/Analysis/ScalarEvolution | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'test/Analysis/ScalarEvolution')
-rw-r--r-- | test/Analysis/ScalarEvolution/load-with-range-metadata.ll | 37 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/nsw-offset-assume.ll | 83 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/nsw.ll | 23 | ||||
-rw-r--r-- | test/Analysis/ScalarEvolution/sext-iv-1.ll | 9 |
4 files changed, 149 insertions, 3 deletions
diff --git a/test/Analysis/ScalarEvolution/load-with-range-metadata.ll b/test/Analysis/ScalarEvolution/load-with-range-metadata.ll new file mode 100644 index 0000000..2f6dcd0 --- /dev/null +++ b/test/Analysis/ScalarEvolution/load-with-range-metadata.ll @@ -0,0 +1,37 @@ +; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s + +define i32 @slt_trip_count_with_range(i32 *%ptr0, i32 *%ptr1) { +; CHECK-LABEL: slt_trip_count_with_range + entry: + %limit = load i32* %ptr0, !range !0 + br label %loop + + loop: +; CHECK: Loop %loop: max backedge-taken count is 98 + %index = phi i32 [ 0, %entry ], [ %index.inc, %loop ] + %index.inc = add i32 %index, 1 + %continue = icmp slt i32 %index.inc, %limit + br i1 %continue, label %loop, label %loop.exit + + loop.exit: + ret i32 0 +} + +define i32 @ult_trip_count_with_range(i32 *%ptr0, i32 *%ptr1) { +; CHECK-LABEL: ult_trip_count_with_range + entry: + %limit = load i32* %ptr0, !range !0 + br label %loop + + loop: +; CHECK: Loop %loop: max backedge-taken count is 98 + %index = phi i32 [ 0, %entry ], [ %index.inc, %loop ] + %index.inc = add i32 %index, 1 + %continue = icmp ult i32 %index.inc, %limit + br i1 %continue, label %loop, label %loop.exit + + loop.exit: + ret i32 0 +} + +!0 = metadata !{i32 1, i32 100} diff --git a/test/Analysis/ScalarEvolution/nsw-offset-assume.ll b/test/Analysis/ScalarEvolution/nsw-offset-assume.ll new file mode 100644 index 0000000..29cf658 --- /dev/null +++ b/test/Analysis/ScalarEvolution/nsw-offset-assume.ll @@ -0,0 +1,83 @@ +; RUN: opt < %s -S -analyze -scalar-evolution | FileCheck %s + +; ScalarEvolution should be able to fold away the sign-extensions +; on this loop with a primary induction variable incremented with +; a nsw add of 2 (this test is derived from the nsw-offset.ll test, but uses an +; assume instead of a preheader conditional branch to guard the loop). + +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" + +define void @foo(i32 %no, double* nocapture %d, double* nocapture %q) nounwind { +entry: + %n = and i32 %no, 4294967294 + %0 = icmp sgt i32 %n, 0 ; <i1> [#uses=1] + tail call void @llvm.assume(i1 %0) + br label %bb.nph + +bb.nph: ; preds = %entry + br label %bb + +bb: ; preds = %bb.nph, %bb1 + %i.01 = phi i32 [ %16, %bb1 ], [ 0, %bb.nph ] ; <i32> [#uses=5] + +; CHECK: %1 = sext i32 %i.01 to i64 +; CHECK: --> {0,+,2}<nuw><nsw><%bb> + %1 = sext i32 %i.01 to i64 ; <i64> [#uses=1] + +; CHECK: %2 = getelementptr inbounds double* %d, i64 %1 +; CHECK: --> {%d,+,16}<nsw><%bb> + %2 = getelementptr inbounds double* %d, i64 %1 ; <double*> [#uses=1] + + %3 = load double* %2, align 8 ; <double> [#uses=1] + %4 = sext i32 %i.01 to i64 ; <i64> [#uses=1] + %5 = getelementptr inbounds double* %q, i64 %4 ; <double*> [#uses=1] + %6 = load double* %5, align 8 ; <double> [#uses=1] + %7 = or i32 %i.01, 1 ; <i32> [#uses=1] + +; CHECK: %8 = sext i32 %7 to i64 +; CHECK: --> {1,+,2}<nuw><nsw><%bb> + %8 = sext i32 %7 to i64 ; <i64> [#uses=1] + +; CHECK: %9 = getelementptr inbounds double* %q, i64 %8 +; CHECK: {(8 + %q),+,16}<nsw><%bb> + %9 = getelementptr inbounds double* %q, i64 %8 ; <double*> [#uses=1] + +; Artificially repeat the above three instructions, this time using +; add nsw instead of or. + %t7 = add nsw i32 %i.01, 1 ; <i32> [#uses=1] + +; CHECK: %t8 = sext i32 %t7 to i64 +; CHECK: --> {1,+,2}<nuw><nsw><%bb> + %t8 = sext i32 %t7 to i64 ; <i64> [#uses=1] + +; CHECK: %t9 = getelementptr inbounds double* %q, i64 %t8 +; CHECK: {(8 + %q),+,16}<nsw><%bb> + %t9 = getelementptr inbounds double* %q, i64 %t8 ; <double*> [#uses=1] + + %10 = load double* %9, align 8 ; <double> [#uses=1] + %11 = fadd double %6, %10 ; <double> [#uses=1] + %12 = fadd double %11, 3.200000e+00 ; <double> [#uses=1] + %13 = fmul double %3, %12 ; <double> [#uses=1] + %14 = sext i32 %i.01 to i64 ; <i64> [#uses=1] + %15 = getelementptr inbounds double* %d, i64 %14 ; <double*> [#uses=1] + store double %13, double* %15, align 8 + %16 = add nsw i32 %i.01, 2 ; <i32> [#uses=2] + br label %bb1 + +bb1: ; preds = %bb + %17 = icmp slt i32 %16, %n ; <i1> [#uses=1] + br i1 %17, 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 +} + +declare void @llvm.assume(i1) nounwind + +; Note: Without the preheader assume, there is an 'smax' in the +; backedge-taken count expression: +; CHECK: Loop %bb: backedge-taken count is ((-1 + (2 * (%no /u 2))) /u 2) +; CHECK: Loop %bb: max backedge-taken count is 1073741822 diff --git a/test/Analysis/ScalarEvolution/nsw.ll b/test/Analysis/ScalarEvolution/nsw.ll index 05992ea..d776a5a 100644 --- a/test/Analysis/ScalarEvolution/nsw.ll +++ b/test/Analysis/ScalarEvolution/nsw.ll @@ -123,9 +123,8 @@ exit: ret i32 %result } -; TODO: This could fold down to '1' ; CHECK-LABEL: PR12375 -; CHECK: --> {(4 + %arg),+,4}<nuw><%bb1> Exits: (4 + (4 * ((-1 + (-1 * %arg) + ((4 + %arg) umax (8 + %arg)<nsw>)) /u 4)) + %arg) +; CHECK: --> {(4 + %arg),+,4}<nuw><%bb1> Exits: (8 + %arg)<nsw> define i32 @PR12375(i32* readnone %arg) { bb: %tmp = getelementptr inbounds i32* %arg, i64 2 @@ -158,3 +157,23 @@ bb2: ; preds = %bb2, %bb bb5: ; preds = %bb2 ret void } + +declare void @f(i32) + +; CHECK-LABEL: nswnowrap +; CHECK: --> {(1 + %v),+,1}<nsw><%for.body> Exits: (2 + %v) +define void @nswnowrap(i32 %v) { +entry: + %add = add nsw i32 %v, 1 + br label %for.body + +for.body: + %i.04 = phi i32 [ %v, %entry ], [ %inc, %for.body ] + %inc = add nsw i32 %i.04, 1 + tail call void @f(i32 %i.04) + %cmp = icmp slt i32 %i.04, %add + br i1 %cmp, label %for.body, label %for.end + +for.end: + ret void +} diff --git a/test/Analysis/ScalarEvolution/sext-iv-1.ll b/test/Analysis/ScalarEvolution/sext-iv-1.ll index c34596d..a6f70db 100644 --- a/test/Analysis/ScalarEvolution/sext-iv-1.ll +++ b/test/Analysis/ScalarEvolution/sext-iv-1.ll @@ -1,5 +1,12 @@ ; RUN: opt < %s -scalar-evolution -analyze \ -; RUN: | grep " --> (sext i. {.*,+,.*}<%bb1> to i64)" | count 5 +; RUN: | FileCheck %s + +; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64) +; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64) +; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64) +; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64) +; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64) +; CHECK-NOT: --> (sext ; Don't convert (sext {...,+,...}) to {sext(...),+,sext(...)} in cases ; where the trip count is not within range. |