1; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
2; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
3
4define i32 @slt_trip_count_with_range(i32 *%ptr0, i32 *%ptr1) {
5; CHECK-LABEL: slt_trip_count_with_range
6 entry:
7  %limit = load i32, i32* %ptr0, !range !0
8  br label %loop
9
10 loop:
11; CHECK: Loop %loop: max backedge-taken count is 98
12  %index = phi i32 [ 0, %entry ], [ %index.inc, %loop ]
13  %index.inc = add i32 %index, 1
14  %continue = icmp slt i32 %index.inc, %limit
15  br i1 %continue, label %loop, label %loop.exit
16
17 loop.exit:
18  ret i32 0
19}
20
21define i32 @ult_trip_count_with_range(i32 *%ptr0, i32 *%ptr1) {
22; CHECK-LABEL: ult_trip_count_with_range
23 entry:
24  %limit = load i32, i32* %ptr0, !range !0
25  br label %loop
26
27 loop:
28; CHECK: Loop %loop: max backedge-taken count is 98
29  %index = phi i32 [ 0, %entry ], [ %index.inc, %loop ]
30  %index.inc = add i32 %index, 1
31  %continue = icmp ult i32 %index.inc, %limit
32  br i1 %continue, label %loop, label %loop.exit
33
34 loop.exit:
35  ret i32 0
36}
37
38!0 = !{i32 1, i32 100}
39