diff options
author | Philip Reames <preames@rivosinc.com> | 2024-03-05 17:20:06 -0800 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2024-03-05 17:41:58 -0800 |
commit | 31c304ba7ba8bb5c236072df55640154ea49b588 (patch) | |
tree | 2ef172c7037ad18d0d80a6655e593c1bb78adbff | |
parent | 889d99a50f38150570f6fca903d61ee9770bd932 (diff) | |
download | llvm-31c304ba7ba8bb5c236072df55640154ea49b588.zip llvm-31c304ba7ba8bb5c236072df55640154ea49b588.tar.gz llvm-31c304ba7ba8bb5c236072df55640154ea49b588.tar.bz2 |
[SCEV] Migrate some tests to be autogenerated
In advance of a change which needs to update these. This batch was the
"easy" ones, I'll be landing the harder set a few a time for easier
review.
14 files changed, 434 insertions, 149 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll b/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll index 4a799bd..dbd9b83 100644 --- a/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll +++ b/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll @@ -1,7 +1,5 @@ -; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s - -; CHECK: Loop %bb: backedge-taken count is ((-5 + %x) /u 3) -; CHECK: Loop %bb: constant max backedge-taken count is 1431655764 +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s ; ScalarEvolution can't compute a trip count because it doesn't know if @@ -9,6 +7,16 @@ ; be teaching it how to use a more elaborate trip count computation. define i32 @f(i32 %x) nounwind readnone { +; +; CHECK-LABEL: 'f' +; CHECK-NEXT: Determining loop execution counts for: @f +; CHECK-NEXT: Loop %bb: backedge-taken count is ((-5 + %x) /u 3) +; CHECK-NEXT: Loop %bb: constant max backedge-taken count is 1431655764 +; CHECK-NEXT: Loop %bb: symbolic max backedge-taken count is ((-5 + %x) /u 3) +; CHECK-NEXT: Loop %bb: Predicated backedge-taken count is ((-5 + %x) /u 3) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %bb: Trip multiple is 1 +; entry: %0 = icmp ugt i32 %x, 4 ; <i1> [#uses=1] br i1 %0, label %bb.nph, label %bb2 diff --git a/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll b/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll index 566f74868..ca472d4 100644 --- a/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll +++ b/llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll @@ -1,13 +1,20 @@ -; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 2>&1 | FileCheck %s - -; CHECK: Loop %bb: backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x))))) -; CHECK: Loop %bb: constant max backedge-taken count is 334 - +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 2>&1 | FileCheck %s ; This is a tricky testcase for unsigned wrap detection which ScalarEvolution ; doesn't yet know how to do. define i32 @f(i32 %x) nounwind readnone { +; +; CHECK-LABEL: 'f' +; CHECK-NEXT: Determining loop execution counts for: @f +; CHECK-NEXT: Loop %bb: backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x))))) +; CHECK-NEXT: Loop %bb: constant max backedge-taken count is 334 +; CHECK-NEXT: Loop %bb: symbolic max backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x))))) +; CHECK-NEXT: Loop %bb: Predicated backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x))))) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %bb: Trip multiple is 1 +; entry: %0 = icmp ugt i32 %x, 999 ; <i1> [#uses=1] br i1 %0, label %bb2, label %bb.nph diff --git a/llvm/test/Analysis/ScalarEvolution/exhaustive-trip-counts.ll b/llvm/test/Analysis/ScalarEvolution/exhaustive-trip-counts.ll index 8a84737..2892b5a 100644 --- a/llvm/test/Analysis/ScalarEvolution/exhaustive-trip-counts.ll +++ b/llvm/test/Analysis/ScalarEvolution/exhaustive-trip-counts.ll @@ -1,14 +1,20 @@ -; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" define void @f_0() { -; CHECK-LABEL: Printing analysis 'Scalar Evolution Analysis' for function 'f_0': -; CHECK: Loop %for.body: backedge-taken count is 5 -; CHECK: Loop %for.body: constant max backedge-taken count is 5 -; CHECK: Loop %for.body: Predicated backedge-taken count is 5 - +; +; CHECK-LABEL: 'f_0' +; CHECK-NEXT: Determining loop execution counts for: @f_0 +; CHECK-NEXT: Loop %for.body: backedge-taken count is 5 +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 5 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is 5 +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is 5 +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 6 +; entry: br label %for.body diff --git a/llvm/test/Analysis/ScalarEvolution/exponential-behavior.ll b/llvm/test/Analysis/ScalarEvolution/exponential-behavior.ll index 6632e64..adeaaf2 100644 --- a/llvm/test/Analysis/ScalarEvolution/exponential-behavior.ll +++ b/llvm/test/Analysis/ScalarEvolution/exponential-behavior.ll @@ -1,13 +1,19 @@ -; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s - -; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'f': - -; CHECK: Loop %loop: <multiple exits> Unpredictable backedge-taken count. -; CHECK: Loop %loop: constant max backedge-taken count is 0 -; CHECK: Loop %loop: Unpredictable predicated backedge-taken count. - +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s define void @f(i32 %n, ptr %ptr) { +; +; CHECK-LABEL: 'f' +; CHECK-NEXT: Determining loop execution counts for: @f +; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count. +; CHECK-NEXT: exit count for loop: 0 +; CHECK-NEXT: exit count for be: ***COULDNOTCOMPUTE*** +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 0 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 0 +; CHECK-NEXT: symbolic max exit count for loop: 0 +; CHECK-NEXT: symbolic max exit count for be: ***COULDNOTCOMPUTE*** +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop diff --git a/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll b/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll index 74d109e..dd78173 100644 --- a/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll +++ b/llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll @@ -1,13 +1,22 @@ -; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s define i32 @slt_trip_count_with_range(ptr %ptr0, ptr %ptr1) { -; CHECK-LABEL: slt_trip_count_with_range +; +; CHECK-LABEL: 'slt_trip_count_with_range' +; CHECK-NEXT: Determining loop execution counts for: @slt_trip_count_with_range +; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %limit)<nsw> +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 98 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %limit)<nsw> +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %limit)<nsw> +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %limit = load i32, ptr %ptr0, !range !0 br label %loop loop: -; CHECK: Loop %loop: constant 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 @@ -18,13 +27,21 @@ define i32 @slt_trip_count_with_range(ptr %ptr0, ptr %ptr1) { } define i32 @ult_trip_count_with_range(ptr %ptr0, ptr %ptr1) { -; CHECK-LABEL: ult_trip_count_with_range +; +; CHECK-LABEL: 'ult_trip_count_with_range' +; CHECK-NEXT: Determining loop execution counts for: @ult_trip_count_with_range +; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %limit)<nsw> +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 98 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %limit)<nsw> +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %limit)<nsw> +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %limit = load i32, ptr %ptr0, !range !0 br label %loop loop: -; CHECK: Loop %loop: constant 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 diff --git a/llvm/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll b/llvm/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll index 4376548..5af706b 100644 --- a/llvm/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll +++ b/llvm/test/Analysis/ScalarEvolution/max-trip-count-address-space.ll @@ -1,14 +1,21 @@ -; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s ; ScalarEvolution should be able to understand the loop and eliminate the casts. target datalayout = "e-p:32:32:32-p1:16:16:16-p2:8:8:8-p4:64:64:64-n16:32:64" -; CHECK: {%d,+,4}<%bb>{{ U: [^ ]+ S: [^ ]+}}{{ *}} Exits: (-4 + (4 * (trunc i32 %n to i16)) + %d) - - define void @foo(ptr addrspace(1) nocapture %d, i32 %n) nounwind { -; CHECK: @foo +; +; CHECK-LABEL: 'foo' +; CHECK-NEXT: Determining loop execution counts for: @foo +; CHECK-NEXT: Loop %bb: backedge-taken count is (-1 + %n) +; CHECK-NEXT: Loop %bb: constant max backedge-taken count is 2147483646 +; CHECK-NEXT: Loop %bb: symbolic max backedge-taken count is (-1 + %n) +; CHECK-NEXT: Loop %bb: Predicated backedge-taken count is (-1 + %n) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %bb: Trip multiple is 1 +; entry: %0 = icmp sgt i32 %n, 0 ; <i1> [#uses=1] br i1 %0, label %bb.nph, label %return @@ -39,7 +46,16 @@ return: ; preds = %bb1.return_crit_edge, %entry } define void @test(ptr addrspace(1) %a, i32 %n) nounwind { -; CHECK: @test +; +; CHECK-LABEL: 'test' +; CHECK-NEXT: Determining loop execution counts for: @test +; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (zext i32 %n to i64))<nsw> +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (zext i32 %n to i64))<nsw> +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (zext i32 %n to i64))<nsw> +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: %cmp1 = icmp sgt i32 %n, 0 br i1 %cmp1, label %for.body.lr.ph, label %for.end @@ -62,7 +78,3 @@ for.cond.for.end_crit_edge: ; preds = %for.body 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: constant max backedge-taken count is 2147483646 diff --git a/llvm/test/Analysis/ScalarEvolution/pr25369.ll b/llvm/test/Analysis/ScalarEvolution/pr25369.ll index fce008b..28ab5f8 100644 --- a/llvm/test/Analysis/ScalarEvolution/pr25369.ll +++ b/llvm/test/Analysis/ScalarEvolution/pr25369.ll @@ -1,10 +1,30 @@ -; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" define void @hoge1() { -; CHECK-LABEL: Classifying expressions for: @hoge1 +; +; CHECK-LABEL: 'hoge1' +; CHECK-NEXT: Determining loop execution counts for: @hoge1 +; CHECK-NEXT: Loop %bb13: backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6) +; CHECK-NEXT: Loop %bb13: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %bb13: symbolic max backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6) +; CHECK-NEXT: Loop %bb13: Predicated backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %bb13: Trip multiple is 1 +; CHECK-NEXT: Loop %bb4: backedge-taken count is 20 +; CHECK-NEXT: Loop %bb4: constant max backedge-taken count is 20 +; CHECK-NEXT: Loop %bb4: symbolic max backedge-taken count is 20 +; CHECK-NEXT: Loop %bb4: Predicated backedge-taken count is 20 +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %bb4: Trip multiple is 21 +; CHECK-NEXT: Loop %bb2: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable predicated backedge-taken count. +; bb: br i1 undef, label %bb4, label %bb2 @@ -26,8 +46,6 @@ bb4: ; preds = %bb4, %bb2, %bb %tmp12 = icmp eq i64 %tmp11, 64 br i1 %tmp12, label %bb3, label %bb4 -; CHECK: Loop %bb4: backedge-taken count is 20 -; CHECK: Loop %bb4: constant max backedge-taken count is 20 bb13: ; preds = %bb13, %bb3 %tmp14 = phi i64 [ 0, %bb3 ], [ %tmp15, %bb13 ] @@ -41,7 +59,24 @@ bb18: ; preds = %bb13 } define void @hoge2() { -; CHECK-LABEL: Classifying expressions for: @hoge2 +; +; CHECK-LABEL: 'hoge2' +; CHECK-NEXT: Determining loop execution counts for: @hoge2 +; CHECK-NEXT: Loop %bb13: backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6) +; CHECK-NEXT: Loop %bb13: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %bb13: symbolic max backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6) +; CHECK-NEXT: Loop %bb13: Predicated backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %bb13: Trip multiple is 1 +; CHECK-NEXT: Loop %bb4: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %bb4: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %bb4: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %bb4: Unpredictable predicated backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %bb2: Unpredictable predicated backedge-taken count. +; bb: br i1 undef, label %bb4, label %bb2 @@ -63,8 +98,6 @@ bb4: ; preds = %bb4, %bb2, %bb %tmp12 = icmp eq i64 %tmp11, 64 br i1 %tmp12, label %bb3, label %bb4 -; CHECK: Loop %bb4: Unpredictable backedge-taken count. -; CHECK: Loop %bb4: Unpredictable constant max backedge-taken count. bb13: ; preds = %bb13, %bb3 %tmp14 = phi i64 [ 0, %bb3 ], [ %tmp15, %bb13 ] diff --git a/llvm/test/Analysis/ScalarEvolution/shift-op.ll b/llvm/test/Analysis/ScalarEvolution/shift-op.ll index c4099ac..41e746c 100644 --- a/llvm/test/Analysis/ScalarEvolution/shift-op.ll +++ b/llvm/test/Analysis/ScalarEvolution/shift-op.ll @@ -1,8 +1,15 @@ -; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s define void @test0(i32 %init) { -; CHECK-LABEL: Classifying expressions for: @test0 -; CHECK: Loop %loop: constant max backedge-taken count is 32 +; +; CHECK-LABEL: 'test0' +; CHECK-NEXT: Determining loop execution counts for: @test0 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -17,8 +24,14 @@ define void @test0(i32 %init) { } define void @test1(i32 %init) { -; CHECK-LABEL: Classifying expressions for: @test1 -; CHECK: Loop %loop: constant max backedge-taken count is 32 +; +; CHECK-LABEL: 'test1' +; CHECK-NEXT: Determining loop execution counts for: @test1 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -33,11 +46,16 @@ define void @test1(i32 %init) { } define void @test2(i32 %init) { -; CHECK-LABEL: Determining loop execution counts for: @test2 -; CHECK: Loop %loop: Unpredictable constant max backedge-taken count. - +; ; Unpredictable because %iv could "stabilize" to either -1 or 0, ; depending on %init. +; CHECK-LABEL: 'test2' +; CHECK-NEXT: Determining loop execution counts for: @test2 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -52,8 +70,14 @@ define void @test2(i32 %init) { } define void @test3(ptr %init.ptr) { -; CHECK-LABEL: Determining loop execution counts for: @test3 -; CHECK: Loop %loop: constant max backedge-taken count is 32 +; +; CHECK-LABEL: 'test3' +; CHECK-NEXT: Determining loop execution counts for: @test3 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: %init = load i32, ptr %init.ptr, !range !0 br label %loop @@ -69,8 +93,14 @@ define void @test3(ptr %init.ptr) { } define void @test4(ptr %init.ptr) { -; CHECK-LABEL: Classifying expressions for: @test4 -; CHECK-LABEL: Loop %loop: constant max backedge-taken count is 32 +; +; CHECK-LABEL: 'test4' +; CHECK-NEXT: Determining loop execution counts for: @test4 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: %init = load i32, ptr %init.ptr, !range !1 br label %loop @@ -86,10 +116,15 @@ define void @test4(ptr %init.ptr) { } define void @test5(ptr %init.ptr) { -; CHECK-LABEL: Determining loop execution counts for: @test5 -; CHECK: Loop %loop: Unpredictable constant max backedge-taken count. - +; ; %iv will "stabilize" to -1, so this is an infinite loop +; CHECK-LABEL: 'test5' +; CHECK-NEXT: Determining loop execution counts for: @test5 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: %init = load i32, ptr %init.ptr, !range !1 br label %loop @@ -105,10 +140,15 @@ define void @test5(ptr %init.ptr) { } define void @test6(i32 %init, i32 %shift.amt) { -; CHECK-LABEL: Determining loop execution counts for: @test6 -; CHECK: Loop %loop: Unpredictable constant max backedge-taken count. - +; ; Potentially infinite loop, since %shift.amt could be 0 +; CHECK-LABEL: 'test6' +; CHECK-NEXT: Determining loop execution counts for: @test6 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -123,9 +163,14 @@ define void @test6(i32 %init, i32 %shift.amt) { } define void @test7(i32 %init) { -; CHECK-LABEL: Classifying expressions for: @test7 -; CHECK: Loop %loop: constant max backedge-taken count is 32 - +; +; CHECK-LABEL: 'test7' +; CHECK-NEXT: Determining loop execution counts for: @test7 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 32 +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -140,12 +185,16 @@ define void @test7(i32 %init) { } define void @test8(i32 %init) { -; CHECK-LABEL: Classifying expressions for: @test8 -; CHECK: Loop %loop: Unpredictable constant max backedge-taken count. - +; ; In this test case, %iv.test stabilizes to 127, not -1, so the loop ; is infinite. - +; CHECK-LABEL: 'test8' +; CHECK-NEXT: Determining loop execution counts for: @test8 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -161,11 +210,15 @@ define void @test8(i32 %init) { } define void @test9() { -; CHECK-LABEL: Determining loop execution counts for: @test9 -; CHECK: Loop %loop: Unpredictable constant max backedge-taken count. - +; ; This is an infinite loop, make sure that it recognized as such. - +; CHECK-LABEL: 'test9' +; CHECK-NEXT: Determining loop execution counts for: @test9 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop diff --git a/llvm/test/Analysis/ScalarEvolution/sle.ll b/llvm/test/Analysis/ScalarEvolution/sle.ll index e36333c..a1b0781 100644 --- a/llvm/test/Analysis/ScalarEvolution/sle.ll +++ b/llvm/test/Analysis/ScalarEvolution/sle.ll @@ -1,13 +1,19 @@ -; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s ; ScalarEvolution should be able to use nsw information to prove that ; this loop has a finite trip count. -; CHECK: @le -; CHECK: Loop %for.body: backedge-taken count is %n -; CHECK: Loop %for.body: constant max backedge-taken count is 9223372036854775807 - define void @le(i64 %n, ptr nocapture %p) nounwind { +; CHECK-LABEL: 'le' +; CHECK-NEXT: Determining loop execution counts for: @le +; CHECK-NEXT: Loop %for.body: backedge-taken count is %n +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 9223372036854775807 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is %n +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is %n +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: %cmp6 = icmp slt i64 %n, 0 ; <i1> [#uses=1] br i1 %cmp6, label %for.end, label %for.body diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count-pow2.ll b/llvm/test/Analysis/ScalarEvolution/trip-count-pow2.ll index 584ad28..5b75448 100644 --- a/llvm/test/Analysis/ScalarEvolution/trip-count-pow2.ll +++ b/llvm/test/Analysis/ScalarEvolution/trip-count-pow2.ll @@ -1,6 +1,16 @@ -; RUN: opt < %s "-passes=print<scalar-evolution>" -disable-output 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 -disable-output 2>&1 | FileCheck %s define void @test1(i32 %n) { +; CHECK-LABEL: 'test1' +; CHECK-NEXT: Determining loop execution counts for: @test1 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-32 + (96 * %n)) /u 32) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 134217727 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-32 + (96 * %n)) /u 32) +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-32 + (96 * %n)) /u 32) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %s = mul i32 %n, 96 br label %loop @@ -12,13 +22,19 @@ loop: exit: ret void -; CHECK-LABEL: @test1 -; CHECK: Loop %loop: backedge-taken count is ((-32 + (96 * %n)) /u 32) -; CHECK: Loop %loop: constant max backedge-taken count is 134217727 } ; PR19183 define i32 @test2(i32 %n) { +; CHECK-LABEL: 'test2' +; CHECK-NEXT: Determining loop execution counts for: @test2 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32))<nuw>) /u 32) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 134217727 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-32 + (32 * (%n /u 32))<nuw>) /u 32) +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-32 + (32 * (%n /u 32))<nuw>) /u 32) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %s = and i32 %n, -32 br label %loop @@ -30,12 +46,18 @@ loop: exit: ret i32 %i -; CHECK-LABEL: @test2 -; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32))<nuw>) /u 32) -; CHECK: Loop %loop: constant max backedge-taken count is 134217727 } define void @test3(i32 %n) { +; CHECK-LABEL: 'test3' +; CHECK-NEXT: Determining loop execution counts for: @test3 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-32 + (32 * %n)) /u 32) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 134217727 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-32 + (32 * %n)) /u 32) +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-32 + (32 * %n)) /u 32) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %s = mul i32 %n, 96 br label %loop @@ -47,12 +69,18 @@ loop: exit: ret void -; CHECK-LABEL: @test3 -; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * %n)) /u 32) -; CHECK: Loop %loop: constant max backedge-taken count is 134217727 } define void @test4(i32 %n) { +; CHECK-LABEL: 'test4' +; CHECK-NEXT: Determining loop execution counts for: @test4 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-4 + (-1431655764 * %n)) /u 4) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 1073741823 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-4 + (-1431655764 * %n)) /u 4) +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-4 + (-1431655764 * %n)) /u 4) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %s = mul i32 %n, 4 br label %loop @@ -64,12 +92,18 @@ loop: exit: ret void -; CHECK-LABEL: @test4 -; CHECK: Loop %loop: backedge-taken count is ((-4 + (-1431655764 * %n)) /u 4) -; CHECK: Loop %loop: constant max backedge-taken count is 1073741823 } define void @test5(i32 %n) { +; CHECK-LABEL: 'test5' +; CHECK-NEXT: Determining loop execution counts for: @test5 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-4 + (4 * %n)) /u 4) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 1073741823 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-4 + (4 * %n)) /u 4) +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-4 + (4 * %n)) /u 4) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %s = mul i32 %n, 4 br label %loop @@ -81,7 +115,4 @@ loop: exit: ret void -; CHECK-LABEL: @test5 -; CHECK: Loop %loop: backedge-taken count is ((-4 + (4 * %n)) /u 4) -; CHECK: Loop %loop: constant max backedge-taken count is 1073741823 } diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count-switch.ll b/llvm/test/Analysis/ScalarEvolution/trip-count-switch.ll index d2b6e1f..d5ab589 100644 --- a/llvm/test/Analysis/ScalarEvolution/trip-count-switch.ll +++ b/llvm/test/Analysis/ScalarEvolution/trip-count-switch.ll @@ -1,8 +1,19 @@ -; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s declare void @foo() define void @test1() nounwind { +; +; CHECK-LABEL: 'test1' +; CHECK-NEXT: Determining loop execution counts for: @test1 +; CHECK-NEXT: Loop %for.cond: backedge-taken count is 2 +; CHECK-NEXT: Loop %for.cond: constant max backedge-taken count is 2 +; CHECK-NEXT: Loop %for.cond: symbolic max backedge-taken count is 2 +; CHECK-NEXT: Loop %for.cond: Predicated backedge-taken count is 2 +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.cond: Trip multiple is 3 +; entry: br label %for.cond @@ -24,7 +35,4 @@ if.end: ; preds = %for.cond, %if.then for.end: ; preds = %for.cond ret void -; CHECK-LABEL: @test1 -; CHECK: Loop %for.cond: backedge-taken count is 2 -; CHECK: Loop %for.cond: constant max backedge-taken count is 2 } diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll b/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll index fb559ad..63fb99d 100644 --- a/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll +++ b/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll @@ -1,18 +1,26 @@ -; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s ; ScalarEvolution should be able to compute trip count of the loop by proving ; that this is not an infinite loop with side effects. -; CHECK-LABEL: Determining loop execution counts for: @foo1 -; CHECK: backedge-taken count is ((-1 + (%n smax %s)) /u %s) ; We should have a conservative estimate for the max backedge taken count for ; loops with unknown stride. -; CHECK: constant max backedge-taken count is -1 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" define void @foo1(ptr nocapture %A, i32 %n, i32 %s) mustprogress { +; +; CHECK-LABEL: 'foo1' +; CHECK-NEXT: Determining loop execution counts for: @foo1 +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((-1 + (%n smax %s)) /u %s) +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((-1 + (%n smax %s)) /u %s) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((-1 + (%n smax %s)) /u %s) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: %cmp4 = icmp sgt i32 %n, 0 br i1 %cmp4, label %for.body, label %for.end @@ -33,14 +41,21 @@ for.end: ; preds = %for.body, %entry ; Check that we are able to compute trip count of a loop without an entry guard. -; CHECK: Determining loop execution counts for: @foo2 -; CHECK: backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) ; We should have a conservative estimate for the max backedge taken count for ; loops with unknown stride. -; CHECK: constant max backedge-taken count is -1 define void @foo2(ptr nocapture %A, i32 %n, i32 %s) mustprogress { +; +; CHECK-LABEL: 'foo2' +; CHECK-NEXT: Determining loop execution counts for: @foo2 +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: br label %for.body @@ -60,11 +75,16 @@ for.end: ; preds = %for.body, %entry ; Check that without mustprogress we don't make assumptions about infinite ; loops being UB. -; CHECK-LABEL: Determining loop execution counts for: @foo3 -; CHECK: Loop %for.body: Unpredictable backedge-taken count. -; CHECK: Loop %for.body: Unpredictable constant max backedge-taken count. define void @foo3(ptr nocapture %A, i32 %n, i32 %s) { +; +; CHECK-LABEL: 'foo3' +; CHECK-NEXT: Determining loop execution counts for: @foo3 +; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count. +; entry: br label %for.body @@ -83,11 +103,18 @@ for.end: ; preds = %for.body, %entry } ; Same as foo2, but with mustprogress on loop, not function -; CHECK: Determining loop execution counts for: @foo4 -; CHECK: backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) -; CHECK: constant max backedge-taken count is -1 define void @foo4(ptr nocapture %A, i32 %n, i32 %s) { +; +; CHECK-LABEL: 'foo4' +; CHECK-NEXT: Determining loop execution counts for: @foo4 +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s)))) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: br label %for.body @@ -106,14 +133,21 @@ for.end: ; preds = %for.body, %entry } ; A more complex case with pre-increment compare instead of post-increment. -; CHECK-LABEL: Determining loop execution counts for: @foo5 -; CHECK: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %start) + (%n smax %start))))<nuw><nsw> + (-1 * %start) + (%n smax %start)) /u (1 umax %s)) + (1 umin ((-1 * %start) + (%n smax %start)))) ; We should have a conservative estimate for the max backedge taken count for ; loops with unknown stride. -; CHECK: constant max backedge-taken count is -1 define void @foo5(ptr nocapture %A, i32 %n, i32 %s, i32 %start) mustprogress { +; +; CHECK-LABEL: 'foo5' +; CHECK-NEXT: Determining loop execution counts for: @foo5 +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %start) + (%n smax %start))))<nuw><nsw> + (-1 * %start) + (%n smax %start)) /u (1 umax %s)) + (1 umin ((-1 * %start) + (%n smax %start)))) +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %start) + (%n smax %start))))<nuw><nsw> + (-1 * %start) + (%n smax %start)) /u (1 umax %s)) + (1 umin ((-1 * %start) + (%n smax %start)))) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((((-1 * (1 umin ((-1 * %start) + (%n smax %start))))<nuw><nsw> + (-1 * %start) + (%n smax %start)) /u (1 umax %s)) + (1 umin ((-1 * %start) + (%n smax %start)))) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: br label %for.body @@ -133,12 +167,16 @@ for.end: ; preds = %for.body, %entry ; FIXME: Currently we are more conservative for known zero stride than ; for unknown but potentially zero stride. -; CHECK-LABEL: Determining loop execution counts for: @zero_stride -; CHECK: Loop %for.body: Unpredictable backedge-taken count. -; CHECK: Loop %for.body: Unpredictable constant max backedge-taken count. -; CHECK: Loop %for.body: Unpredictable predicated backedge-taken count. ; Note that this function is well defined only when %n <=s 0 define void @zero_stride(ptr nocapture %A, i32 %n) { +; +; CHECK-LABEL: 'zero_stride' +; CHECK-NEXT: Determining loop execution counts for: @zero_stride +; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count. +; entry: br label %for.body @@ -156,13 +194,17 @@ for.end: ; preds = %for.body, %entry ret void } -; CHECK-LABEL: Determining loop execution counts for: @zero_stride_ub -; CHECK: Loop %for.body: Unpredictable backedge-taken count. -; CHECK: Loop %for.body: Unpredictable constant max backedge-taken count. -; CHECK: Loop %for.body: Unpredictable predicated backedge-taken count. ; Note that this function will always execute undefined behavior and thus ; any value is valid for a backedge taken count. define void @zero_stride_ub(ptr nocapture %A) { +; +; CHECK-LABEL: 'zero_stride_ub' +; CHECK-NEXT: Determining loop execution counts for: @zero_stride_ub +; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count. +; entry: br label %for.body @@ -181,11 +223,18 @@ for.end: ; preds = %for.body, %entry } ; When %zero = 0, this loop is only well defined if %n < 0 and thus BTC = 0. -; CHECK-LABEL: Determining loop execution counts for: @zero_stride_symbolic -; CHECK: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %zero) + (%n smax %zero))))<nuw><nsw> + (-1 * %zero) + (%n smax %zero)) /u (1 umax %zero)) + (1 umin ((-1 * %zero) + (%n smax %zero)))) -; CHECK: Loop %for.body: constant max backedge-taken count is -1 define void @zero_stride_symbolic(ptr nocapture %A, i32 %n, i32 %zero) { +; +; CHECK-LABEL: 'zero_stride_symbolic' +; CHECK-NEXT: Determining loop execution counts for: @zero_stride_symbolic +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %zero) + (%n smax %zero))))<nuw><nsw> + (-1 * %zero) + (%n smax %zero)) /u (1 umax %zero)) + (1 umin ((-1 * %zero) + (%n smax %zero)))) +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %zero) + (%n smax %zero))))<nuw><nsw> + (-1 * %zero) + (%n smax %zero)) /u (1 umax %zero)) + (1 umin ((-1 * %zero) + (%n smax %zero)))) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((((-1 * (1 umin ((-1 * %zero) + (%n smax %zero))))<nuw><nsw> + (-1 * %zero) + (%n smax %zero)) /u (1 umax %zero)) + (1 umin ((-1 * %zero) + (%n smax %zero)))) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: br label %for.body @@ -204,11 +253,16 @@ for.end: ; preds = %for.body, %entry } -; CHECK-LABEL: Determining loop execution counts for: @zero_stride_varying_rhs -; CHECK: Loop %for.body: Unpredictable backedge-taken count. -; CHECK: Loop %for.body: Unpredictable constant max backedge-taken count define void @zero_stride_varying_rhs(ptr nocapture %A, ptr %n_p, i32 %zero) { +; +; CHECK-LABEL: 'zero_stride_varying_rhs' +; CHECK-NEXT: Determining loop execution counts for: @zero_stride_varying_rhs +; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count. +; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count. +; entry: br label %for.body diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count12.ll b/llvm/test/Analysis/ScalarEvolution/trip-count12.ll index 6fc804a..9eae3cc 100644 --- a/llvm/test/Analysis/ScalarEvolution/trip-count12.ll +++ b/llvm/test/Analysis/ScalarEvolution/trip-count12.ll @@ -1,10 +1,18 @@ -; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | 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: constant max backedge-taken count is 1073741823 define zeroext i16 @test(ptr nocapture %p, i32 %len) nounwind readonly { +; +; CHECK-LABEL: 'test' +; CHECK-NEXT: Determining loop execution counts for: @test +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((-2 + %len) /u 2) +; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 1073741823 +; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((-2 + %len) /u 2) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((-2 + %len) /u 2) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %for.body: Trip multiple is 1 +; entry: %cmp2 = icmp sgt i32 %len, 1 br i1 %cmp2, label %for.body.preheader, label %for.end diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count13.ll b/llvm/test/Analysis/ScalarEvolution/trip-count13.ll index d2bd34a..9dd615a 100644 --- a/llvm/test/Analysis/ScalarEvolution/trip-count13.ll +++ b/llvm/test/Analysis/ScalarEvolution/trip-count13.ll @@ -1,7 +1,18 @@ -; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s define void @u_0(i8 %rhs) { ; E.g.: %rhs = 255, %start = 99, backedge taken 156 times +; +; CHECK-LABEL: 'u_0' +; CHECK-NEXT: Determining loop execution counts for: @u_0 +; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs)) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs)), actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs)) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %start = add i8 %rhs, 100 br label %loop @@ -12,15 +23,22 @@ loop: %iv.cmp = icmp ult i8 %iv, %rhs br i1 %iv.cmp, label %loop, label %leave -; CHECK-LABEL: Determining loop execution counts for: @u_0 -; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs)) -; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. leave: ret void } define void @u_1(i8 %start) { +; +; CHECK-LABEL: 'u_1' +; CHECK-NEXT: Determining loop execution counts for: @u_1 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start)) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start)), actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start)) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: ; E.g.: %start = 99, %rhs = 255, backedge taken 156 times %rhs = add i8 %start, -100 @@ -32,15 +50,22 @@ loop: %iv.cmp = icmp ult i8 %iv, %rhs br i1 %iv.cmp, label %loop, label %leave -; CHECK-LABEL: Determining loop execution counts for: @u_1 -; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start)) -; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. leave: ret void } define void @s_0(i8 %rhs) { +; +; CHECK-LABEL: 's_0' +; CHECK-NEXT: Determining loop execution counts for: @s_0 +; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs)) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs)), actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs)) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: ; E.g.: %rhs = 127, %start = -29, backedge taken 156 times %start = add i8 %rhs, 100 @@ -52,15 +77,22 @@ loop: %iv.cmp = icmp slt i8 %iv, %rhs br i1 %iv.cmp, label %loop, label %leave -; CHECK-LABEL: Determining loop execution counts for: @s_0 -; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs)) -; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. leave: ret void } define void @s_1(i8 %start) { +; +; CHECK-LABEL: 's_1' +; CHECK-NEXT: Determining loop execution counts for: @s_1 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start)) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start)), actual taken count either this or zero. +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start)) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: ; E.g.: start = -29, %rhs = 127, %backedge taken 156 times %rhs = add i8 %start, -100 @@ -72,15 +104,22 @@ loop: %iv.cmp = icmp slt i8 %iv, %rhs br i1 %iv.cmp, label %loop, label %leave -; CHECK-LABEL: Determining loop execution counts for: @s_1 -; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start)) -; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -100, actual taken count either this or zero. leave: ret void } define void @s_2(i8 %start) { +; +; CHECK-LABEL: 's_2' +; CHECK-NEXT: Determining loop execution counts for: @s_2 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * ((-100 + %start) smin %start)) + %start) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-1 * ((-100 + %start) smin %start)) + %start) +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-1 * ((-100 + %start) smin %start)) + %start) +; CHECK-NEXT: Predicates: +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %rhs = add i8 %start, -100 br label %loop @@ -91,9 +130,6 @@ loop: %iv.cmp = icmp sgt i8 %iv, %rhs br i1 %iv.cmp, label %loop, label %leave -; CHECK-LABEL: Determining loop execution counts for: @s_2 -; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * ((-100 + %start) smin %start)) + %start) -; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1 leave: ret void |