diff --git a/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll b/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll index d4fda88bd0bd..8d9806920a05 100644 --- a/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll +++ b/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll @@ -1,8 +1,29 @@ +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py ; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s ; RUN: opt -disable-output "-passes=print" < %s 2>&1 | FileCheck %s define void @f0(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f0 +; CHECK-LABEL: 'f0' +; CHECK-NEXT: Classifying expressions for: @f0 +; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0 +; CHECK-NEXT: --> %start U: [0,128) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1 +; CHECK-NEXT: --> %step U: [1,0) S: [-2,2) +; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f0 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; entry: %start = select i1 %c, i32 127, i32 0 %step = select i1 %c, i32 -1, i32 1 @@ -11,8 +32,6 @@ entry: loop: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] -; CHECK: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] -; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) %iv.next = add i32 %iv, %step %loop.iv.inc = add i32 %loop.iv, 1 %be.cond = icmp ne i32 %loop.iv.inc, 128 @@ -23,7 +42,55 @@ leave: } define void @f1(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f1 +; CHECK-LABEL: 'f1' +; CHECK-NEXT: Classifying expressions for: @f1 +; CHECK-NEXT: %start = select i1 %c, i32 120, i32 0 +; CHECK-NEXT: --> %start U: [0,121) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -8, i32 8 +; CHECK-NEXT: --> %step U: [8,-7) S: [-16,16) +; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,16) S: [0,16) Exits: 15 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,121) S: [0,121) Exits: ((15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.1 = add i32 %iv, 1 +; CHECK-NEXT: --> {(1 + %start),+,%step}<%loop> U: [1,122) S: [1,122) Exits: (1 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.2 = add i32 %iv, 2 +; CHECK-NEXT: --> {(2 + %start),+,%step}<%loop> U: [2,123) S: [2,123) Exits: (2 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.3 = add i32 %iv, 3 +; CHECK-NEXT: --> {(3 + %start),+,%step}<%loop> U: [3,124) S: [3,124) Exits: (3 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.4 = add i32 %iv, 4 +; CHECK-NEXT: --> {(4 + %start),+,%step}<%loop> U: [4,125) S: [4,125) Exits: (4 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.5 = add i32 %iv, 5 +; CHECK-NEXT: --> {(5 + %start),+,%step}<%loop> U: [5,126) S: [5,126) Exits: (5 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.6 = add i32 %iv, 6 +; CHECK-NEXT: --> {(6 + %start),+,%step}<%loop> U: [6,127) S: [6,127) Exits: (6 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.7 = add i32 %iv, 7 +; CHECK-NEXT: --> {(7 + %start),+,%step}<%loop> U: [7,128) S: [7,128) Exits: (7 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m1 = sub i32 %iv, 1 +; CHECK-NEXT: --> {(-1 + %start),+,%step}<%loop> U: [-1,120) S: [-1,120) Exits: (-1 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m2 = sub i32 %iv, 2 +; CHECK-NEXT: --> {(-2 + %start),+,%step}<%loop> U: [0,-1) S: [-2,119) Exits: (-2 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m3 = sub i32 %iv, 3 +; CHECK-NEXT: --> {(-3 + %start),+,%step}<%loop> U: [-3,118) S: [-3,118) Exits: (-3 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m4 = sub i32 %iv, 4 +; CHECK-NEXT: --> {(-4 + %start),+,%step}<%loop> U: [0,-3) S: [-4,117) Exits: (-4 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m5 = sub i32 %iv, 5 +; CHECK-NEXT: --> {(-5 + %start),+,%step}<%loop> U: [-5,116) S: [-5,116) Exits: (-5 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m6 = sub i32 %iv, 6 +; CHECK-NEXT: --> {(-6 + %start),+,%step}<%loop> U: [0,-1) S: [-6,115) Exits: (-6 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.m7 = sub i32 %iv, 7 +; CHECK-NEXT: --> {(-7 + %start),+,%step}<%loop> U: [-7,114) S: [-7,114) Exits: (-7 + (15 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [0,-7) S: [-384,368) Exits: ((16 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,17) S: [1,17) Exits: 16 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f1 +; CHECK-NEXT: Loop %loop: backedge-taken count is 15 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 15 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 15 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 16 +; entry: %start = select i1 %c, i32 120, i32 0 %step = select i1 %c, i32 -8, i32 8 @@ -33,20 +100,6 @@ loop: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] -; CHECK: %iv.1 = add i32 %iv, 1 -; CHECK-NEXT: --> {(1 + %start),+,%step}<%loop> U: [1,122) S: [1,122) -; CHECK: %iv.2 = add i32 %iv, 2 -; CHECK-NEXT: --> {(2 + %start),+,%step}<%loop> U: [2,123) S: [2,123) -; CHECK: %iv.3 = add i32 %iv, 3 -; CHECK-NEXT: --> {(3 + %start),+,%step}<%loop> U: [3,124) S: [3,124) -; CHECK: %iv.4 = add i32 %iv, 4 -; CHECK-NEXT: --> {(4 + %start),+,%step}<%loop> U: [4,125) S: [4,125) -; CHECK: %iv.5 = add i32 %iv, 5 -; CHECK-NEXT: --> {(5 + %start),+,%step}<%loop> U: [5,126) S: [5,126) -; CHECK: %iv.6 = add i32 %iv, 6 -; CHECK-NEXT: --> {(6 + %start),+,%step}<%loop> U: [6,127) S: [6,127) -; CHECK: %iv.7 = add i32 %iv, 7 -; CHECK-NEXT: --> {(7 + %start),+,%step}<%loop> U: [7,128) S: [7,128) %iv.1 = add i32 %iv, 1 %iv.2 = add i32 %iv, 2 @@ -56,20 +109,6 @@ loop: %iv.6 = add i32 %iv, 6 %iv.7 = add i32 %iv, 7 -; CHECK: %iv.m1 = sub i32 %iv, 1 -; CHECK-NEXT: --> {(-1 + %start),+,%step}<%loop> U: [-1,120) S: [-1,120) -; CHECK: %iv.m2 = sub i32 %iv, 2 -; CHECK-NEXT: --> {(-2 + %start),+,%step}<%loop> U: [0,-1) S: [-2,119) -; CHECK: %iv.m3 = sub i32 %iv, 3 -; CHECK-NEXT: --> {(-3 + %start),+,%step}<%loop> U: [-3,118) S: [-3,118) -; CHECK: %iv.m4 = sub i32 %iv, 4 -; CHECK-NEXT: --> {(-4 + %start),+,%step}<%loop> U: [0,-3) S: [-4,117) -; CHECK: %iv.m5 = sub i32 %iv, 5 -; CHECK-NEXT: --> {(-5 + %start),+,%step}<%loop> U: [-5,116) S: [-5,116) -; CHECK: %iv.m6 = sub i32 %iv, 6 -; CHECK-NEXT: --> {(-6 + %start),+,%step}<%loop> U: [0,-1) S: [-6,115) -; CHECK: %iv.m7 = sub i32 %iv, 7 -; CHECK-NEXT: --> {(-7 + %start),+,%step}<%loop> U: [-7,114) S: [-7,114) %iv.m1 = sub i32 %iv, 1 %iv.m2 = sub i32 %iv, 2 @@ -89,7 +128,29 @@ leave: } define void @f2(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f2 +; CHECK-LABEL: 'f2' +; CHECK-NEXT: Classifying expressions for: @f2 +; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0 +; CHECK-NEXT: --> %start U: [0,128) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1 +; CHECK-NEXT: --> %step U: [1,0) S: [-2,2) +; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.sext = sext i32 %iv to i64 +; CHECK-NEXT: --> {(sext i32 %start to i64),+,(sext i32 %step to i64)}<%loop> U: [0,128) S: [0,128) Exits: ((sext i32 %start to i64) + (127 * (sext i32 %step to i64))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f2 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; entry: %start = select i1 %c, i32 127, i32 0 %step = select i1 %c, i32 -1, i32 1 @@ -100,8 +161,6 @@ loop: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] %iv.sext = sext i32 %iv to i64 %iv.next = add i32 %iv, %step -; CHECK: %iv.sext = sext i32 %iv to i64 -; CHECK-NEXT: --> {(sext i32 %start to i64),+,(sext i32 %step to i64)}<%loop> U: [0,128) S: [0,128) %loop.iv.inc = add i32 %loop.iv, 1 %be.cond = icmp ne i32 %loop.iv.inc, 128 br i1 %be.cond, label %loop, label %leave @@ -111,7 +170,29 @@ leave: } define void @f3(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f3 +; CHECK-LABEL: 'f3' +; CHECK-NEXT: Classifying expressions for: @f3 +; CHECK-NEXT: %start = select i1 %c, i16 1000, i16 0 +; CHECK-NEXT: --> %start U: [0,1001) S: [-1024,1024) +; CHECK-NEXT: %step = select i1 %c, i16 1, i16 509 +; CHECK-NEXT: --> %step U: [1,510) S: [-512,512) +; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i16 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,-892) S: [0,-892) Exits: ((127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.zext = zext i16 %iv to i64 +; CHECK-NEXT: --> {(zext i16 %start to i64),+,(zext i16 %step to i64)}<%loop> U: [0,64644) S: [0,64644) Exits: ((zext i16 %start to i64) + (127 * (zext i16 %step to i64))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i16 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: full-set S: full-set Exits: ((128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i16 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f3 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; entry: ; NB! the i16 type (as opposed to i32), the choice of the constant 509 @@ -128,8 +209,6 @@ loop: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i16 [ %start, %entry ], [ %iv.next, %loop ] %iv.zext = zext i16 %iv to i64 -; CHECK: %iv.zext = zext i16 %iv to i64 -; CHECK-NEXT: --> {(zext i16 %start to i64),+,(zext i16 %step to i64)}<%loop> U: [0,64644) S: [0,64644) %iv.next = add i16 %iv, %step %loop.iv.inc = add i16 %loop.iv, 1 %be.cond = icmp ne i16 %loop.iv.inc, 128 @@ -140,7 +219,29 @@ leave: } define void @f4(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f4 +; CHECK-LABEL: 'f4' +; CHECK-NEXT: Classifying expressions for: @f4 +; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0 +; CHECK-NEXT: --> %start U: [0,128) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1 +; CHECK-NEXT: --> %step U: [1,0) S: [-2,2) +; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.trunc = trunc i32 %iv to i16 +; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: full-set S: full-set Exits: ((trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f4 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; ; @f4() demonstrates a case where SCEV is not able to compute a ; precise range for %iv.trunc, though it should be able to, in theory. @@ -156,8 +257,6 @@ loop: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] %iv.trunc = trunc i32 %iv to i16 -; CHECK: %iv.trunc = trunc i32 %iv to i16 -; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: full-set S: full-set %iv.next = add i32 %iv, %step %loop.iv.inc = add i32 %loop.iv, 1 %be.cond = icmp ne i32 %loop.iv.inc, 128 @@ -168,7 +267,29 @@ leave: } define void @f5(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f5 +; CHECK-LABEL: 'f5' +; CHECK-NEXT: Classifying expressions for: @f5 +; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0 +; CHECK-NEXT: --> %start U: [0,128) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1 +; CHECK-NEXT: --> %step U: [1,0) S: [-2,2) +; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.trunc = trunc i32 %iv to i16 +; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128) Exits: ((trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i16 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f5 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; entry: %start = select i1 %c, i32 127, i32 0 %step = select i1 %c, i32 -1, i32 1 @@ -178,8 +299,6 @@ loop: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] %iv.trunc = trunc i32 %iv to i16 -; CHECK: %iv.trunc = trunc i32 %iv to i16 -; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128) %iv.next = add i32 %iv, %step %loop.iv.inc = add i16 %loop.iv, 1 @@ -191,7 +310,31 @@ leave: } define void @f6(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f6 +; CHECK-LABEL: 'f6' +; CHECK-NEXT: Classifying expressions for: @f6 +; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0 +; CHECK-NEXT: --> %start U: [0,128) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -2, i32 0 +; CHECK-NEXT: --> %step U: [0,-1) S: [-2,2) +; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,(1 + %step)}<%loop> U: [0,128) S: [0,128) Exits: (127 + (127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %step.plus.one = add i32 %step, 1 +; CHECK-NEXT: --> (1 + %step) U: [1,0) S: [-1,3) Exits: (1 + %step) LoopDispositions: { %loop: Invariant } +; CHECK-NEXT: %iv.next = add i32 %iv, %step.plus.one +; CHECK-NEXT: --> {(1 + %step + %start),+,(1 + %step)}<%loop> U: [-256,384) S: [-256,384) Exits: (128 + (128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.sext = sext i32 %iv to i64 +; CHECK-NEXT: --> {(sext i32 %start to i64),+,(1 + (sext i32 %step to i64))}<%loop> U: [0,128) S: [0,128) Exits: (127 + (sext i32 %start to i64) + (127 * (sext i32 %step to i64))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i16 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f6 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; entry: %start = select i1 %c, i32 127, i32 0 %step = select i1 %c, i32 -2, i32 0 @@ -200,14 +343,10 @@ entry: loop: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] -; CHECK: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] -; CHECK-NEXT: --> {%start,+,(1 + %step)}<%loop> U: [0,128) S: [0,128) %step.plus.one = add i32 %step, 1 %iv.next = add i32 %iv, %step.plus.one %iv.sext = sext i32 %iv to i64 -; CHECK: %iv.sext = sext i32 %iv to i64 -; CHECK-NEXT: --> {(sext i32 %start to i64),+,(1 + (sext i32 %step to i64))}<%loop> U: [0,128) S: [0,128) %loop.iv.inc = add i16 %loop.iv, 1 %be.cond = icmp ne i16 %loop.iv.inc, 128 br i1 %be.cond, label %loop, label %leave @@ -217,7 +356,33 @@ leave: } define void @f7(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f7 +; CHECK-LABEL: 'f7' +; CHECK-NEXT: Classifying expressions for: @f7 +; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0 +; CHECK-NEXT: --> %start U: [0,128) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1 +; CHECK-NEXT: --> %step U: [1,0) S: [-2,2) +; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.trunc = trunc i32 %iv to i16 +; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128) Exits: ((trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.trunc.plus.one = add i16 %iv.trunc, 1 +; CHECK-NEXT: --> {(1 + (trunc i32 %start to i16)),+,(trunc i32 %step to i16)}<%loop> U: [1,129) S: [1,129) Exits: (1 + (trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.trunc.plus.two = add i16 %iv.trunc, 2 +; CHECK-NEXT: --> {(2 + (trunc i32 %start to i16)),+,(trunc i32 %step to i16)}<%loop> U: [2,130) S: [2,130) Exits: (2 + (trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %loop.iv.inc = add i16 %loop.iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f7 +; CHECK-NEXT: Loop %loop: backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 127 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 127 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 128 +; entry: %start = select i1 %c, i32 127, i32 0 %step = select i1 %c, i32 -1, i32 1 @@ -227,17 +392,11 @@ loop: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ] %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ] %iv.trunc = trunc i32 %iv to i16 -; CHECK: %iv.trunc = trunc i32 %iv to i16 -; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128) %iv.next = add i32 %iv, %step %iv.trunc.plus.one = add i16 %iv.trunc, 1 -; CHECK: %iv.trunc.plus.one = add i16 %iv.trunc, 1 -; CHECK-NEXT: --> {(1 + (trunc i32 %start to i16)),+,(trunc i32 %step to i16)}<%loop> U: [1,129) S: [1,129) %iv.trunc.plus.two = add i16 %iv.trunc, 2 -; CHECK: %iv.trunc.plus.two = add i16 %iv.trunc, 2 -; CHECK-NEXT: --> {(2 + (trunc i32 %start to i16)),+,(trunc i32 %step to i16)}<%loop> U: [2,130) S: [2,130) %loop.iv.inc = add i16 %loop.iv, 1 %be.cond = icmp ne i16 %loop.iv.inc, 128 diff --git a/llvm/test/Analysis/ScalarEvolution/max-be-count-not-constant.ll b/llvm/test/Analysis/ScalarEvolution/max-be-count-not-constant.ll index f05d4ff0f2f1..12bd0d954bfa 100644 --- a/llvm/test/Analysis/ScalarEvolution/max-be-count-not-constant.ll +++ b/llvm/test/Analysis/ScalarEvolution/max-be-count-not-constant.ll @@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py ; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s ; RUN: opt < %s -disable-output "-passes=print" 2>&1 | FileCheck %s @@ -9,8 +10,23 @@ target triple = "x86_64-unknown-linux-gnu" ; asserts in SCEV. define void @pluto(i32 %arg) { -; CHECK-LABEL: Classifying expressions for: @pluto -; CHECK: Loop %bb2: max backedge-taken count is 2 +; CHECK-LABEL: 'pluto' +; CHECK-NEXT: Classifying expressions for: @pluto +; CHECK-NEXT: %tmp = ashr i32 %arg, 31 +; CHECK-NEXT: --> %tmp U: full-set S: [-1,1) +; CHECK-NEXT: %tmp1 = add nsw i32 %tmp, 2 +; CHECK-NEXT: --> (2 + %tmp) U: [-2147483646,-2147483648) S: [1,3) +; CHECK-NEXT: %tmp3 = phi i32 [ 0, %bb ], [ %tmp4, %bb2 ] +; CHECK-NEXT: --> {0,+,(2 + %tmp)}<%bb2> U: [0,5) S: [0,5) Exits: ((2 + %tmp) * (1 /u (2 + %tmp))) LoopDispositions: { %bb2: Computable } +; CHECK-NEXT: %tmp4 = add nuw nsw i32 %tmp1, %tmp3 +; CHECK-NEXT: --> {(2 + %tmp),+,(2 + %tmp)}<%bb2> U: [1,7) S: [1,7) Exits: (2 + ((2 + %tmp) * (1 /u (2 + %tmp))) + %tmp) LoopDispositions: { %bb2: Computable } +; CHECK-NEXT: Determining loop execution counts for: @pluto +; CHECK-NEXT: Loop %bb2: backedge-taken count is (1 /u (2 + %tmp)) +; CHECK-NEXT: Loop %bb2: max backedge-taken count is 2 +; CHECK-NEXT: Loop %bb2: Predicated backedge-taken count is (1 /u (2 + %tmp)) +; CHECK-NEXT: Predicates: +; CHECK: Loop %bb2: Trip multiple is 1 +; bb: %tmp = ashr i32 %arg, 31 %tmp1 = add nsw i32 %tmp, 2 diff --git a/llvm/test/Analysis/ScalarEvolution/sext-to-zext.ll b/llvm/test/Analysis/ScalarEvolution/sext-to-zext.ll index 4cda4c7497e3..5bfb7162a5a9 100644 --- a/llvm/test/Analysis/ScalarEvolution/sext-to-zext.ll +++ b/llvm/test/Analysis/ScalarEvolution/sext-to-zext.ll @@ -1,8 +1,31 @@ +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py ; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s ; RUN: opt -disable-output "-passes=print" < %s 2>&1 | FileCheck %s define void @f(i1 %c) { -; CHECK-LABEL: Classifying expressions for: @f +; CHECK-LABEL: 'f' +; CHECK-NEXT: Classifying expressions for: @f +; CHECK-NEXT: %start = select i1 %c, i32 100, i32 0 +; CHECK-NEXT: --> %start U: [0,101) S: [-128,128) +; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1 +; CHECK-NEXT: --> %step U: [1,0) S: [-2,2) +; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.dec, %loop ] +; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,101) S: [0,101) Exits: ((99 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.tc = phi i32 [ 0, %entry ], [ %iv.tc.inc, %loop ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,100) S: [0,100) Exits: 99 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.tc.inc = add i32 %iv.tc, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,101) S: [1,101) Exits: 100 LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.dec = add nsw i32 %iv, %step +; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-328,228) S: [-328,228) Exits: ((100 * %step) + %start) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.sext = sext i32 %iv to i64 +; CHECK-NEXT: --> {(sext i32 %start to i64),+,(sext i32 %step to i64)}<%loop> U: [0,101) S: [0,101) Exits: ((sext i32 %start to i64) + (99 * (sext i32 %step to i64))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @f +; CHECK-NEXT: Loop %loop: backedge-taken count is 99 +; CHECK-NEXT: Loop %loop: max backedge-taken count is 99 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 99 +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 100 +; entry: %start = select i1 %c, i32 100, i32 0 %step = select i1 %c, i32 -1, i32 1 @@ -14,8 +37,6 @@ loop: %iv.tc.inc = add i32 %iv.tc, 1 %iv.dec = add nsw i32 %iv, %step %iv.sext = sext i32 %iv to i64 -; CHECK: %iv.sext = sext i32 %iv to i64 -; CHECK-NEXT: --> {(sext i32 %start to i64),+,(sext i32 %step to i64)}<%loop> %be = icmp ne i32 %iv.tc.inc, 100 br i1 %be, label %loop, label %leave