[llvm] cf2e828 - SCEV: regen some tests with UTC (#123050)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 06:19:26 PST 2025


Author: Ramkumar Ramachandra
Date: 2025-01-15T14:19:23Z
New Revision: cf2e828925dc8c9656e800387820b49be03109d6

URL: https://github.com/llvm/llvm-project/commit/cf2e828925dc8c9656e800387820b49be03109d6
DIFF: https://github.com/llvm/llvm-project/commit/cf2e828925dc8c9656e800387820b49be03109d6.diff

LOG: SCEV: regen some tests with UTC (#123050)

While at it, move a test that calls the IndVarSimplify pass into the
IndVarSimplify directory.

Added: 
    llvm/test/Transforms/IndVarSimplify/implied-via-addition.ll

Modified: 
    llvm/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
    llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
    llvm/test/Analysis/ScalarEvolution/infer-prestart-no-wrap.ll

Removed: 
    llvm/test/Analysis/ScalarEvolution/implied-via-addition.ll


################################################################################
diff  --git a/llvm/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll b/llvm/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
index 22404b102a73f0..26f60c00ae1bff 100644
--- a/llvm/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
+++ b/llvm/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll
@@ -1,32 +1,39 @@
-; 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 5
+; RUN: opt < %s -passes="print<scalar-evolution>" -disable-output \
+; RUN:   -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
 ; PR1597
 
-; CHECK: Loop %bb: backedge-taken count is (-1 + (-1 * %x) + %y)
-
 define i32 @f(i32 %x, i32 %y) {
+; CHECK-LABEL: 'f'
+; CHECK-NEXT:  Determining loop execution counts for: @f
+; CHECK-NEXT:  Loop %bb: backedge-taken count is (-1 + (-1 * %x) + %y)
+; CHECK-NEXT:  Loop %bb: constant max backedge-taken count is i32 -1
+; CHECK-NEXT:  Loop %bb: symbolic max backedge-taken count is (-1 + (-1 * %x) + %y)
+; CHECK-NEXT:  Loop %bb: Trip multiple is 1
+;
 entry:
-        %tmp63 = icmp ult i32 %x, %y            ; <i1> [#uses=1]
-        br i1 %tmp63, label %bb.preheader, label %bb8
+  %tmp63 = icmp ult i32 %x, %y            ; <i1> [#uses=1]
+  br i1 %tmp63, label %bb.preheader, label %bb8
 
 bb.preheader:           ; preds = %entry
-        br label %bb
+  br label %bb
 
 bb:             ; preds = %bb3, %bb.preheader
-        %x_addr.0 = phi i32 [ %tmp2, %bb3 ], [ %x, %bb.preheader ]              ; <i32> [#uses=1]
-        %tmp2 = add i32 %x_addr.0, 1            ; <i32> [#uses=3]
-        br label %bb3
+  %x_addr.0 = phi i32 [ %tmp2, %bb3 ], [ %x, %bb.preheader ]              ; <i32> [#uses=1]
+  %tmp2 = add i32 %x_addr.0, 1            ; <i32> [#uses=3]
+  br label %bb3
 
 bb3:            ; preds = %bb
-        %tmp6 = icmp ult i32 %tmp2, %y          ; <i1> [#uses=1]
-        br i1 %tmp6, label %bb, label %bb8.loopexit
+  %tmp6 = icmp ult i32 %tmp2, %y          ; <i1> [#uses=1]
+  br i1 %tmp6, label %bb, label %bb8.loopexit
 
 bb8.loopexit:           ; preds = %bb3
-        br label %bb8
+  br label %bb8
 
 bb8:            ; preds = %bb8.loopexit, %entry
-        %x_addr.1 = phi i32 [ %x, %entry ], [ %tmp2, %bb8.loopexit ]            ; <i32> [#uses=1]
-        br label %return
+  %x_addr.1 = phi i32 [ %x, %entry ], [ %tmp2, %bb8.loopexit ]            ; <i32> [#uses=1]
+  br label %return
 
 return:         ; preds = %bb8
-        ret i32 %x_addr.1
+  ret i32 %x_addr.1
 }

diff  --git a/llvm/test/Analysis/ScalarEvolution/implied-via-addition.ll b/llvm/test/Analysis/ScalarEvolution/implied-via-addition.ll
deleted file mode 100644
index 4a0ebf810568e0..00000000000000
--- a/llvm/test/Analysis/ScalarEvolution/implied-via-addition.ll
+++ /dev/null
@@ -1,50 +0,0 @@
-; RUN: opt -passes=indvars -S < %s | FileCheck %s
-
-declare void @use(i1)
-
-declare void @llvm.experimental.guard(i1, ...)
-
-define void @test_01(i8 %t) {
-; CHECK-LABEL: test_01
- entry:
-  %st = sext i8 %t to i16
-  %cmp1 = icmp slt i16 %st, 42
-  call void(i1, ...) @llvm.experimental.guard(i1 %cmp1) [ "deopt"() ]
-  br label %loop
-
- loop:
-; CHECK-LABEL: loop
-  %idx = phi i8 [ %t, %entry ], [ %idx.inc, %loop ]
-  %idx.inc = add i8 %idx, 1
-  %c = icmp slt i8 %idx, 42
-; CHECK: call void @use(i1 true)
-  call void @use(i1 %c)
-  %be = icmp slt i8 %idx.inc, 42
-  br i1 %be, label %loop, label %exit
-
- exit:
-  ret void
-}
-
-define void @test_02(i8 %t) {
-; CHECK-LABEL: test_02
- entry:
-  %t.ptr = inttoptr i8 %t to ptr
-  %p.42 = inttoptr i8 42 to ptr
-  %cmp1 = icmp slt ptr %t.ptr, %p.42
-  call void(i1, ...) @llvm.experimental.guard(i1 %cmp1) [ "deopt"() ]
-  br label %loop
-
- loop:
-; CHECK-LABEL: loop
-  %idx = phi ptr [ %t.ptr, %entry ], [ %snext, %loop ]
-  %snext = getelementptr inbounds i8, ptr %idx, i64 1
-  %c = icmp slt ptr %idx, %p.42
-; CHECK: call void @use(i1 true)
-  call void @use(i1 %c)
-  %be = icmp slt ptr %snext, %p.42
-  br i1 %be, label %loop, label %exit
-
- exit:
-  ret void
-}

diff  --git a/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll b/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
index 6d38f510c4997b..fbe69b4b188977 100644
--- a/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
+++ b/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
@@ -1,11 +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 5
+; RUN: opt < %s -disable-output -passes="print<scalar-evolution>" \
+; RUN:   -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
 
 declare void @llvm.experimental.guard(i1, ...)
 
 define void @test_1(i32 %n) nounwind {
 ; Prove that (n > 1) ===> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_1
-; CHECK:         Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
+; CHECK-LABEL: 'test_1'
+; CHECK-NEXT:  Determining loop execution counts for: @test_1
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, 1
   %n.div.2 = sdiv i32 %n, 2
@@ -24,8 +31,13 @@ exit:
 
 define void @test_1neg(i32 %n) nounwind {
 ; Prove that (n > 0) =\=> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_1neg
-; CHECK:         Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
+; CHECK-LABEL: 'test_1neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_1neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, 0
   %n.div.2 = sdiv i32 %n, 2
@@ -44,8 +56,13 @@ exit:
 
 define void @test_2(i32 %n) nounwind {
 ; Prove that (n >= 2) ===> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_2
-; CHECK:         Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
+; CHECK-LABEL: 'test_2'
+; CHECK-NEXT:  Determining loop execution counts for: @test_2
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, 2
   %n.div.2 = sdiv i32 %n, 2
@@ -64,8 +81,13 @@ exit:
 
 define void @test_2neg(i32 %n) nounwind {
 ; Prove that (n >= 1) =\=> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_2neg
-; CHECK:         Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
+; CHECK-LABEL: 'test_2neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_2neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, 1
   %n.div.2 = sdiv i32 %n, 2
@@ -84,8 +106,13 @@ exit:
 
 define void @test_3(i32 %n) nounwind {
 ; Prove that (n > -2) ===> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_3
-; CHECK:         Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-LABEL: 'test_3'
+; CHECK-NEXT:  Determining loop execution counts for: @test_3
+; CHECK-NEXT:  Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, -2
   %n.div.2 = sdiv i32 %n, 2
@@ -104,8 +131,13 @@ exit:
 
 define void @test_3neg(i32 %n) nounwind {
 ; Prove that (n > -3) =\=> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_3neg
-; CHECK:         Loop %header: backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
+; CHECK-LABEL: 'test_3neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_3neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, -3
   %n.div.2 = sdiv i32 %n, 2
@@ -124,8 +156,13 @@ exit:
 
 define void @test_4(i32 %n) nounwind {
 ; Prove that (n >= -1) ===> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_4
-; CHECK:         Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-LABEL: 'test_4'
+; CHECK-NEXT:  Determining loop execution counts for: @test_4
+; CHECK-NEXT:  Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, -1
   %n.div.2 = sdiv i32 %n, 2
@@ -144,8 +181,13 @@ exit:
 
 define void @test_4neg(i32 %n) nounwind {
 ; Prove that (n >= -2) =\=> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_4neg
-; CHECK:         Loop %header: backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
+; CHECK-LABEL: 'test_4neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_4neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i32 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, -2
   %n.div.2 = sdiv i32 %n, 2
@@ -164,8 +206,13 @@ exit:
 
 define void @test_ext_01(i32 %n) nounwind {
 ; Prove that (n > 1) ===> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_ext_01
-; CHECK:         Loop %header: backedge-taken count is (-1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-LABEL: 'test_ext_01'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_01
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, 1
   %n.div.2 = sdiv i32 %n, 2
@@ -185,8 +232,13 @@ exit:
 
 define void @test_ext_01neg(i32 %n) nounwind {
 ; Prove that (n > 0) =\=> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_ext_01neg
-; CHECK:         Loop %header: backedge-taken count is (-1 + (1 smax (sext i32 %n.div.2 to i64)))<nsw>
+; CHECK-LABEL: 'test_ext_01neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_01neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + (1 smax (sext i32 %n.div.2 to i64)))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + (1 smax (sext i32 %n.div.2 to i64)))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, 0
   %n.div.2 = sdiv i32 %n, 2
@@ -206,8 +258,13 @@ exit:
 
 define void @test_ext_02(i32 %n) nounwind {
 ; Prove that (n >= 2) ===> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_ext_02
-; CHECK:         Loop %header: backedge-taken count is (-1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-LABEL: 'test_ext_02'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_02
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, 2
   %n.div.2 = sdiv i32 %n, 2
@@ -227,8 +284,13 @@ exit:
 
 define void @test_ext_02neg(i32 %n) nounwind {
 ; Prove that (n >= 1) =\=> (n / 2 > 0).
-; CHECK:         Determining loop execution counts for: @test_ext_02neg
-; CHECK:         Loop %header: backedge-taken count is (-1 + (1 smax (sext i32 %n.div.2 to i64)))<nsw>
+; CHECK-LABEL: 'test_ext_02neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_02neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (-1 + (1 smax (sext i32 %n.div.2 to i64)))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741822
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (-1 + (1 smax (sext i32 %n.div.2 to i64)))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, 1
   %n.div.2 = sdiv i32 %n, 2
@@ -248,8 +310,13 @@ exit:
 
 define void @test_ext_03(i32 %n) nounwind {
 ; Prove that (n > -2) ===> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_ext_03
-; CHECK:         Loop %header: backedge-taken count is (1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-LABEL: 'test_ext_03'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_03
+; CHECK-NEXT:  Loop %header: backedge-taken count is (1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, -2
   %n.div.2 = sdiv i32 %n, 2
@@ -269,8 +336,13 @@ exit:
 
 define void @test_ext_03neg(i32 %n) nounwind {
 ; Prove that (n > -3) =\=> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_ext_03neg
-; CHECK:         Loop %header: backedge-taken count is (0 smax (1 + (sext i32 %n.div.2 to i64))<nsw>)
+; CHECK-LABEL: 'test_ext_03neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_03neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (0 smax (1 + (sext i32 %n.div.2 to i64))<nsw>)
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (0 smax (1 + (sext i32 %n.div.2 to i64))<nsw>)
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sgt i32 %n, -3
   %n.div.2 = sdiv i32 %n, 2
@@ -290,8 +362,13 @@ exit:
 
 define void @test_ext_04(i32 %n) nounwind {
 ; Prove that (n >= -1) ===> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_ext_04
-; CHECK:         Loop %header: backedge-taken count is (1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-LABEL: 'test_ext_04'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_04
+; CHECK-NEXT:  Loop %header: backedge-taken count is (1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (1 + (sext i32 %n.div.2 to i64))<nsw>
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, -1
   %n.div.2 = sdiv i32 %n, 2
@@ -311,8 +388,13 @@ exit:
 
 define void @test_ext_04neg(i32 %n) nounwind {
 ; Prove that (n >= -2) =\=> (n / 2 >= 0).
-; CHECK:         Determining loop execution counts for: @test_ext_04neg
-; CHECK:         Loop %header: backedge-taken count is (0 smax (1 + (sext i32 %n.div.2 to i64))<nsw>)
+; CHECK-LABEL: 'test_ext_04neg'
+; CHECK-NEXT:  Determining loop execution counts for: @test_ext_04neg
+; CHECK-NEXT:  Loop %header: backedge-taken count is (0 smax (1 + (sext i32 %n.div.2 to i64))<nsw>)
+; CHECK-NEXT:  Loop %header: constant max backedge-taken count is i64 1073741824
+; CHECK-NEXT:  Loop %header: symbolic max backedge-taken count is (0 smax (1 + (sext i32 %n.div.2 to i64))<nsw>)
+; CHECK-NEXT:  Loop %header: Trip multiple is 1
+;
 entry:
   %cmp1 = icmp sge i32 %n, -2
   %n.div.2 = sdiv i32 %n, 2

diff  --git a/llvm/test/Analysis/ScalarEvolution/infer-prestart-no-wrap.ll b/llvm/test/Analysis/ScalarEvolution/infer-prestart-no-wrap.ll
index a8b891b5afb232..677463ee632257 100644
--- a/llvm/test/Analysis/ScalarEvolution/infer-prestart-no-wrap.ll
+++ b/llvm/test/Analysis/ScalarEvolution/infer-prestart-no-wrap.ll
@@ -1,7 +1,29 @@
-; ; 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 5
+; RUN: opt -disable-output -passes="print<scalar-evolution>" < %s 2>&1 | FileCheck %s
 
 define void @infer.sext.0(ptr %c, i32 %start, ptr %buf) {
-; CHECK-LABEL: Classifying expressions for: @infer.sext.0
+; CHECK-LABEL: 'infer.sext.0'
+; CHECK-NEXT:  Classifying expressions for: @infer.sext.0
+; CHECK-NEXT:    %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
+; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,2) S: [0,2) Exits: 1 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT:    --> {%start,+,1}<nsw><%loop> U: full-set S: full-set Exits: (1 + %start) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc = add nsw i32 %idx, 1
+; CHECK-NEXT:    --> {(1 + %start)<nsw>,+,1}<nsw><%loop> U: full-set S: full-set Exits: (2 + %start) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc.sext = sext i32 %idx.inc to i64
+; CHECK-NEXT:    --> {(1 + (sext i32 %start to i64))<nsw>,+,1}<nsw><%loop> U: [-2147483647,2147483650) S: [-2147483647,2147483650) Exits: (2 + (sext i32 %start to i64))<nsw> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc
+; CHECK-NEXT:    --> {(4 + (4 * (sext i32 %start to i64))<nsw> + %buf),+,4}<nw><%loop> U: full-set S: full-set Exits: (8 + (4 * (sext i32 %start to i64))<nsw> + %buf) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %val = load i32, ptr %buf.gep, align 4
+; CHECK-NEXT:    --> %val U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:    %counter.inc = add i32 %counter, 1
+; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,3) S: [1,3) Exits: 2 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:  Determining loop execution counts for: @infer.sext.0
+; CHECK-NEXT:  Loop %loop: backedge-taken count is i32 1
+; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 1
+; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 1
+; CHECK-NEXT:  Loop %loop: Trip multiple is 2
+;
  entry:
   br label %loop
 
@@ -10,8 +32,6 @@ define void @infer.sext.0(ptr %c, i32 %start, ptr %buf) {
   %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
   %idx.inc = add nsw i32 %idx, 1
   %idx.inc.sext = sext i32 %idx.inc to i64
-; CHECK: %idx.inc.sext = sext i32 %idx.inc to i64
-; CHECK-NEXT: -->  {(1 + (sext i32 %start to i64))<nsw>,+,1}<nsw><%loop>
 
   %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc
   %val = load i32, ptr %buf.gep
@@ -25,7 +45,28 @@ define void @infer.sext.0(ptr %c, i32 %start, ptr %buf) {
 }
 
 define void @infer.zext.0(ptr %c, i32 %start, ptr %buf) {
-; CHECK-LABEL: Classifying expressions for: @infer.zext.0
+; CHECK-LABEL: 'infer.zext.0'
+; CHECK-NEXT:  Classifying expressions for: @infer.zext.0
+; CHECK-NEXT:    %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
+; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,2) S: [0,2) Exits: 1 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT:    --> {%start,+,1}<nuw><%loop> U: full-set S: full-set Exits: (1 + %start) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc = add nuw i32 %idx, 1
+; CHECK-NEXT:    --> {(1 + %start)<nuw>,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: (2 + %start) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc.sext = zext i32 %idx.inc to i64
+; CHECK-NEXT:    --> {(1 + (zext i32 %start to i64))<nuw><nsw>,+,1}<nuw><%loop> U: [1,4294967298) S: [1,4294967298) Exits: (2 + (zext i32 %start to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc
+; CHECK-NEXT:    --> ((4 * (sext i32 {(1 + %start)<nuw>,+,1}<nuw><%loop> to i64))<nsw> + %buf) U: full-set S: full-set Exits: ((4 * (sext i32 (2 + %start) to i64))<nsw> + %buf) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %val = load i32, ptr %buf.gep, align 4
+; CHECK-NEXT:    --> %val U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:    %counter.inc = add i32 %counter, 1
+; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,3) S: [1,3) Exits: 2 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:  Determining loop execution counts for: @infer.zext.0
+; CHECK-NEXT:  Loop %loop: backedge-taken count is i32 1
+; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 1
+; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 1
+; CHECK-NEXT:  Loop %loop: Trip multiple is 2
+;
  entry:
   br label %loop
 
@@ -34,8 +75,6 @@ define void @infer.zext.0(ptr %c, i32 %start, ptr %buf) {
   %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
   %idx.inc = add nuw i32 %idx, 1
   %idx.inc.sext = zext i32 %idx.inc to i64
-; CHECK: %idx.inc.sext = zext i32 %idx.inc to i64
-; CHECK-NEXT: -->  {(1 + (zext i32 %start to i64))<nuw><nsw>,+,1}<nuw><%loop>
 
   %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc
   %val = load i32, ptr %buf.gep
@@ -49,7 +88,25 @@ define void @infer.zext.0(ptr %c, i32 %start, ptr %buf) {
 }
 
 define void @infer.sext.1(i32 %start, ptr %c) {
-; CHECK-LABEL: Classifying expressions for: @infer.sext.1
+; CHECK-LABEL: 'infer.sext.1'
+; CHECK-NEXT:  Classifying expressions for: @infer.sext.1
+; CHECK-NEXT:    %start.mul = mul i32 %start, 4
+; CHECK-NEXT:    --> (4 * %start) U: [0,-3) S: [-2147483648,2147483645)
+; CHECK-NEXT:    %start.real = add i32 %start.mul, 2
+; CHECK-NEXT:    --> (2 + (4 * %start))<nuw><nsw> U: [2,-1) S: [-2147483646,2147483647)
+; CHECK-NEXT:    %idx = phi i32 [ %start.real, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT:    --> {(2 + (4 * %start))<nuw><nsw>,+,2}<nsw><%loop> U: [0,-1) S: [-2147483646,2147483647) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.sext = sext i32 %idx to i64
+; CHECK-NEXT:    --> {(2 + (sext i32 (4 * %start) to i64))<nuw><nsw>,+,2}<nsw><%loop> U: [0,-1) S: [-2147483646,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc = add nsw i32 %idx, 2
+; CHECK-NEXT:    --> {(4 + (4 * %start)),+,2}<nw><%loop> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %condition = load i1, ptr %c, align 1
+; CHECK-NEXT:    --> %condition U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:  Determining loop execution counts for: @infer.sext.1
+; 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.
+;
  entry:
   %start.mul = mul i32 %start, 4
   %start.real = add i32 %start.mul, 2
@@ -58,8 +115,6 @@ define void @infer.sext.1(i32 %start, ptr %c) {
  loop:
   %idx = phi i32 [ %start.real, %entry ], [ %idx.inc, %loop ]
   %idx.sext = sext i32 %idx to i64
-; CHECK: %idx.sext = sext i32 %idx to i64
-; CHECK-NEXT:  -->  {(2 + (sext i32 (4 * %start) to i64))<nuw><nsw>,+,2}<nsw><%loop>
   %idx.inc = add nsw i32 %idx, 2
   %condition = load i1, ptr %c
   br i1 %condition, label %exit, label %loop
@@ -69,7 +124,23 @@ define void @infer.sext.1(i32 %start, ptr %c) {
 }
 
 define void @infer.sext.2(ptr %c, i8 %start) {
-; CHECK-LABEL: Classifying expressions for: @infer.sext.2
+; CHECK-LABEL: 'infer.sext.2'
+; CHECK-NEXT:  Classifying expressions for: @infer.sext.2
+; CHECK-NEXT:    %start.inc = add i8 %start, 1
+; CHECK-NEXT:    --> (1 + %start) U: full-set S: full-set
+; CHECK-NEXT:    %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT:    --> {(1 + %start),+,1}<nsw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.sext = sext i8 %idx to i16
+; CHECK-NEXT:    --> {(1 + (sext i8 %start to i16))<nsw>,+,1}<nsw><%loop> U: [-127,-32768) S: [-127,-32768) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc = add nsw i8 %idx, 1
+; CHECK-NEXT:    --> {(2 + %start),+,1}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %condition = load volatile i1, ptr %c, align 1
+; CHECK-NEXT:    --> %condition U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:  Determining loop execution counts for: @infer.sext.2
+; 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.
+;
  entry:
   %start.inc = add i8 %start, 1
   %entry.condition = icmp slt i8 %start, 127
@@ -78,8 +149,6 @@ define void @infer.sext.2(ptr %c, i8 %start) {
  loop:
   %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ]
   %idx.sext = sext i8 %idx to i16
-; CHECK: %idx.sext = sext i8 %idx to i16
-; CHECK-NEXT: -->  {(1 + (sext i8 %start to i16))<nsw>,+,1}<nsw><%loop>
   %idx.inc = add nsw i8 %idx, 1
   %condition = load volatile i1, ptr %c
   br i1 %condition, label %exit, label %loop
@@ -89,7 +158,23 @@ define void @infer.sext.2(ptr %c, i8 %start) {
 }
 
 define void @infer.zext.1(ptr %c, i8 %start) {
-; CHECK-LABEL: Classifying expressions for: @infer.zext.1
+; CHECK-LABEL: 'infer.zext.1'
+; CHECK-NEXT:  Classifying expressions for: @infer.zext.1
+; CHECK-NEXT:    %start.inc = add i8 %start, 1
+; CHECK-NEXT:    --> (1 + %start) U: full-set S: full-set
+; CHECK-NEXT:    %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT:    --> {(1 + %start),+,1}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.zext = zext i8 %idx to i16
+; CHECK-NEXT:    --> {(1 + (zext i8 %start to i16))<nuw><nsw>,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %idx.inc = add nuw i8 %idx, 1
+; CHECK-NEXT:    --> {(2 + %start),+,1}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %condition = load volatile i1, ptr %c, align 1
+; CHECK-NEXT:    --> %condition U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT:  Determining loop execution counts for: @infer.zext.1
+; 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.
+;
  entry:
   %start.inc = add i8 %start, 1
   %entry.condition = icmp ult i8 %start, 255
@@ -98,8 +183,6 @@ define void @infer.zext.1(ptr %c, i8 %start) {
  loop:
   %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ]
   %idx.zext = zext i8 %idx to i16
-; CHECK: %idx.zext = zext i8 %idx to i16
-; CHECK-NEXT: -->  {(1 + (zext i8 %start to i16))<nuw><nsw>,+,1}<nuw><%loop>
   %idx.inc = add nuw i8 %idx, 1
   %condition = load volatile i1, ptr %c
   br i1 %condition, label %exit, label %loop

diff  --git a/llvm/test/Transforms/IndVarSimplify/implied-via-addition.ll b/llvm/test/Transforms/IndVarSimplify/implied-via-addition.ll
new file mode 100644
index 00000000000000..865c10e3913aad
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/implied-via-addition.ll
@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes=indvars -S < %s | FileCheck %s
+
+declare void @use(i1)
+
+declare void @llvm.experimental.guard(i1, ...)
+
+define void @test_01(i8 %t) {
+; CHECK-LABEL: define void @test_01(
+; CHECK-SAME: i8 [[T:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:    [[ST:%.*]] = sext i8 [[T]] to i16
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp slt i16 [[ST]], 42
+; CHECK-NEXT:    call void (i1, ...) @llvm.experimental.guard(i1 [[CMP1]]) [ "deopt"() ]
+; CHECK-NEXT:    br label %[[LOOP:.*]]
+; CHECK:       [[LOOP]]:
+; CHECK-NEXT:    [[IDX:%.*]] = phi i8 [ [[T]], %[[ENTRY]] ], [ [[IDX_INC:%.*]], %[[LOOP]] ]
+; CHECK-NEXT:    [[IDX_INC]] = add nsw i8 [[IDX]], 1
+; CHECK-NEXT:    call void @use(i1 true)
+; CHECK-NEXT:    [[BE:%.*]] = icmp slt i8 [[IDX_INC]], 42
+; CHECK-NEXT:    br i1 [[BE]], label %[[LOOP]], label %[[EXIT:.*]]
+; CHECK:       [[EXIT]]:
+; CHECK-NEXT:    ret void
+;
+  entry:
+  %st = sext i8 %t to i16
+  %cmp1 = icmp slt i16 %st, 42
+  call void(i1, ...) @llvm.experimental.guard(i1 %cmp1) [ "deopt"() ]
+  br label %loop
+
+  loop:
+  %idx = phi i8 [ %t, %entry ], [ %idx.inc, %loop ]
+  %idx.inc = add i8 %idx, 1
+  %c = icmp slt i8 %idx, 42
+  call void @use(i1 %c)
+  %be = icmp slt i8 %idx.inc, 42
+  br i1 %be, label %loop, label %exit
+
+  exit:
+  ret void
+}
+
+define void @test_02(i8 %t) {
+; CHECK-LABEL: define void @test_02(
+; CHECK-SAME: i8 [[T:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:    [[T_PTR:%.*]] = inttoptr i8 [[T]] to ptr
+; CHECK-NEXT:    [[P_42:%.*]] = inttoptr i8 42 to ptr
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp slt ptr [[T_PTR]], [[P_42]]
+; CHECK-NEXT:    call void (i1, ...) @llvm.experimental.guard(i1 [[CMP1]]) [ "deopt"() ]
+; CHECK-NEXT:    br label %[[LOOP:.*]]
+; CHECK:       [[LOOP]]:
+; CHECK-NEXT:    [[IDX:%.*]] = phi ptr [ [[T_PTR]], %[[ENTRY]] ], [ [[SNEXT:%.*]], %[[LOOP]] ]
+; CHECK-NEXT:    [[SNEXT]] = getelementptr inbounds i8, ptr [[IDX]], i64 1
+; CHECK-NEXT:    call void @use(i1 true)
+; CHECK-NEXT:    [[BE:%.*]] = icmp ult ptr [[SNEXT]], [[P_42]]
+; CHECK-NEXT:    br i1 [[BE]], label %[[LOOP]], label %[[EXIT:.*]]
+; CHECK:       [[EXIT]]:
+; CHECK-NEXT:    ret void
+;
+  entry:
+  %t.ptr = inttoptr i8 %t to ptr
+  %p.42 = inttoptr i8 42 to ptr
+  %cmp1 = icmp slt ptr %t.ptr, %p.42
+  call void(i1, ...) @llvm.experimental.guard(i1 %cmp1) [ "deopt"() ]
+  br label %loop
+
+  loop:
+  %idx = phi ptr [ %t.ptr, %entry ], [ %snext, %loop ]
+  %snext = getelementptr inbounds i8, ptr %idx, i64 1
+  %c = icmp slt ptr %idx, %p.42
+  call void @use(i1 %c)
+  %be = icmp slt ptr %snext, %p.42
+  br i1 %be, label %loop, label %exit
+
+  exit:
+  ret void
+}


        


More information about the llvm-commits mailing list