1 ; RUN: opt < %s -scalar-evolution -analyze -enable-new-pm=0 | FileCheck %s
2 ; RUN: opt < %s "-passes=print<scalar-evolution>" -disable-output 2>&1 | FileCheck %s
4 define void @test1(i32 %n) {
9 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
10 %i.next = add i32 %i, 32
11 %t = icmp ne i32 %i.next, %s
12 br i1 %t, label %loop, label %exit
17 ; CHECK: Loop %loop: backedge-taken count is ((-32 + (96 * %n)) /u 32)
18 ; CHECK: Loop %loop: max backedge-taken count is 134217727
22 define i32 @test2(i32 %n) {
27 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
28 %i.next = add i32 %i, 32
29 %t = icmp ne i32 %i.next, %s
30 br i1 %t, label %loop, label %exit
35 ; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32))<nuw>) /u 32)
36 ; CHECK: Loop %loop: max backedge-taken count is 134217727
39 define void @test3(i32 %n) {
44 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
45 %i.next = add i32 %i, 96
46 %t = icmp ne i32 %i.next, %s
47 br i1 %t, label %loop, label %exit
52 ; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * %n)) /u 32)
53 ; CHECK: Loop %loop: max backedge-taken count is 134217727
56 define void @test4(i32 %n) {
61 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
62 %i.next = add i32 %i, 12
63 %t = icmp ne i32 %i.next, %s
64 br i1 %t, label %loop, label %exit
69 ; CHECK: Loop %loop: backedge-taken count is ((-4 + (-1431655764 * %n)) /u 4)
70 ; CHECK: Loop %loop: max backedge-taken count is 1073741823
73 define void @test5(i32 %n) {
78 %i = phi i32 [ %s, %entry ], [ %i.next, %loop ]
79 %i.next = add i32 %i, -4
80 %t = icmp ne i32 %i.next, 0
81 br i1 %t, label %loop, label %exit
86 ; CHECK: Loop %loop: backedge-taken count is ((-4 + (4 * %n)) /u 4)
87 ; CHECK: Loop %loop: max backedge-taken count is 1073741823