• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -analyze -scalar-evolution < %s | FileCheck %s
2
3define void @u_0(i8 %rhs) {
4; E.g.: %rhs = 255, %start = 99, backedge taken 156 times
5entry:
6  %start = add i8 %rhs, 100
7  br label %loop
8
9loop:
10  %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
11  %iv.inc = add nuw i8 %iv, 1  ;; Note: this never unsigned-wraps
12  %iv.cmp = icmp ult i8 %iv, %rhs
13  br i1 %iv.cmp, label %loop, label %leave
14
15; CHECK-LABEL: Determining loop execution counts for: @u_0
16; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs))
17; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
18
19leave:
20  ret void
21}
22
23define void @u_1(i8 %start) {
24entry:
25; E.g.: %start = 99, %rhs = 255, backedge taken 156 times
26  %rhs = add i8 %start, -100
27  br label %loop
28
29loop:
30  %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
31  %iv.inc = add nuw i8 %iv, 1  ;; Note: this never unsigned-wraps
32  %iv.cmp = icmp ult i8 %iv, %rhs
33  br i1 %iv.cmp, label %loop, label %leave
34
35; CHECK-LABEL: Determining loop execution counts for: @u_1
36; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start))
37; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
38
39leave:
40  ret void
41}
42
43define void @s_0(i8 %rhs) {
44entry:
45; E.g.: %rhs = 127, %start = -29, backedge taken 156 times
46  %start = add i8 %rhs, 100
47  br label %loop
48
49loop:
50  %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
51  %iv.inc = add nsw i8 %iv, 1  ;; Note: this never signed-wraps
52  %iv.cmp = icmp slt i8 %iv, %rhs
53  br i1 %iv.cmp, label %loop, label %leave
54
55; CHECK-LABEL: Determining loop execution counts for: @s_0
56; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs))
57; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
58
59leave:
60  ret void
61}
62
63define void @s_1(i8 %start) {
64entry:
65; E.g.: start = -29, %rhs = 127, %backedge taken 156 times
66  %rhs = add i8 %start, -100
67  br label %loop
68
69loop:
70  %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
71  %iv.inc = add nsw i8 %iv, 1
72  %iv.cmp = icmp slt i8 %iv, %rhs
73  br i1 %iv.cmp, label %loop, label %leave
74
75; CHECK-LABEL: Determining loop execution counts for: @s_1
76; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start))
77; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
78
79leave:
80  ret void
81}
82