1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
4 define i32 @f0(i32 %x, i32 %y) {
6 ; CHECK-NEXT: Classifying expressions for: @f0
7 ; CHECK-NEXT: %sum = add i32 %x, %y
8 ; CHECK-NEXT: --> (%x + %y) U: full-set S: full-set
9 ; CHECK-NEXT: %v = phi i32 [ %sum, %add ], [ %x, %entry ]
10 ; CHECK-NEXT: --> ((0 smax %y) + %x) U: full-set S: full-set
11 ; CHECK-NEXT: Determining loop execution counts for: @f0
14 %c = icmp sgt i32 %y, 0
15 br i1 %c, label %add, label %merge
22 %v = phi i32 [ %sum, %add ], [ %x, %entry ]
26 define i32 @f1(i32 %x, i32 %y) {
28 ; CHECK-NEXT: Classifying expressions for: @f1
29 ; CHECK-NEXT: %sum = add i32 %x, %y
30 ; CHECK-NEXT: --> (%x + %y) U: full-set S: full-set
31 ; CHECK-NEXT: %v = phi i32 [ %sum, %add ], [ %x, %entry ]
32 ; CHECK-NEXT: --> ((0 smax %y) + %x) U: full-set S: full-set
33 ; CHECK-NEXT: Determining loop execution counts for: @f1
36 %c = icmp sge i32 %y, 0
37 br i1 %c, label %add, label %merge
44 %v = phi i32 [ %sum, %add ], [ %x, %entry ]
48 define i32 @f2(i32 %x, i32 %y, ptr %ptr) {
50 ; CHECK-NEXT: Classifying expressions for: @f2
51 ; CHECK-NEXT: %lv = load i32, ptr %ptr, align 4
52 ; CHECK-NEXT: --> %lv U: full-set S: full-set
53 ; CHECK-NEXT: %v = phi i32 [ %lv, %add ], [ %x, %entry ]
54 ; CHECK-NEXT: --> %v U: full-set S: full-set
55 ; CHECK-NEXT: Determining loop execution counts for: @f2
58 %c = icmp sge i32 %y, 0
59 br i1 %c, label %add, label %merge
62 %lv = load i32, ptr %ptr
66 %v = phi i32 [ %lv, %add ], [ %x, %entry ]
70 define i32 @f3(i32 %x, i32 %init, i32 %lim) {
72 ; CHECK-NEXT: Classifying expressions for: @f3
73 ; CHECK-NEXT: %iv = phi i32 [ %init, %entry ], [ %iv.inc, %merge ]
74 ; CHECK-NEXT: --> {%init,+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
75 ; CHECK-NEXT: %iv.inc = add i32 %iv, 1
76 ; CHECK-NEXT: --> {(1 + %init),+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
77 ; CHECK-NEXT: %sum = add i32 %x, %iv
78 ; CHECK-NEXT: --> {(%x + %init),+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
79 ; CHECK-NEXT: %v = phi i32 [ %sum, %add ], [ %x, %loop ]
80 ; CHECK-NEXT: --> ((0 smax {%init,+,1}<%loop>) + %x) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
81 ; CHECK-NEXT: Determining loop execution counts for: @f3
82 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
83 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
84 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
85 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
91 %iv = phi i32 [ %init, %entry ], [ %iv.inc, %merge ]
92 %iv.inc = add i32 %iv, 1
93 %c = icmp sge i32 %iv, 0
94 br i1 %c, label %add, label %merge
97 %sum = add i32 %x, %iv
101 %v = phi i32 [ %sum, %add ], [ %x, %loop ]
102 %be.cond = icmp eq i32 %iv.inc, %lim
103 br i1 %be.cond, label %loop, label %leave
109 define i32 @f4(i32 %x, i32 %init, i32 %lim) {
111 ; CHECK-NEXT: Classifying expressions for: @f4
112 ; CHECK-NEXT: %iv = phi i32 [ %init, %add ], [ %iv.inc, %loop ]
113 ; CHECK-NEXT: --> {%init,+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
114 ; CHECK-NEXT: %iv.inc = add i32 %iv, 1
115 ; CHECK-NEXT: --> {(1 + %init),+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
116 ; CHECK-NEXT: %sum = add i32 %x, %iv
117 ; CHECK-NEXT: --> {(%x + %init),+,1}<%loop> U: full-set S: full-set
118 ; CHECK-NEXT: %v = phi i32 [ %sum, %add.cont ], [ %x, %entry ]
119 ; CHECK-NEXT: --> %v U: full-set S: full-set
120 ; CHECK-NEXT: Determining loop execution counts for: @f4
121 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
122 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
123 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
124 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
127 %c = icmp sge i32 %init, 0
128 br i1 %c, label %add, label %merge
134 %iv = phi i32 [ %init, %add ], [ %iv.inc, %loop ]
135 %iv.inc = add i32 %iv, 1
136 %be.cond = icmp eq i32 %iv.inc, %lim
137 br i1 %be.cond, label %loop, label %add.cont
140 %sum = add i32 %x, %iv
144 %v = phi i32 [ %sum, %add.cont ], [ %x, %entry ]
148 ; It's okay to match "through" %init, as SCEV expressions don't preserve LCSSA.
149 define i32 @f5(ptr %val) {
151 ; CHECK-NEXT: Classifying expressions for: @f5
152 ; CHECK-NEXT: %inc = load i32, ptr %val, align 4
153 ; CHECK-NEXT: --> %inc U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.end: Variant }
154 ; CHECK-NEXT: %init = phi i32 [ 0, %for.condt ], [ %inc, %for.end ]
155 ; CHECK-NEXT: --> %inc U: full-set S: full-set
156 ; CHECK-NEXT: Determining loop execution counts for: @f5
157 ; CHECK-NEXT: Loop %for.end: <multiple exits> backedge-taken count is false
158 ; CHECK-NEXT: exit count for for.end: false
159 ; CHECK-NEXT: exit count for for.condt: false
160 ; CHECK-NEXT: Loop %for.end: constant max backedge-taken count is false
161 ; CHECK-NEXT: Loop %for.end: symbolic max backedge-taken count is false
162 ; CHECK-NEXT: symbolic max exit count for for.end: false
163 ; CHECK-NEXT: symbolic max exit count for for.condt: false
164 ; CHECK-NEXT: Loop %for.end: Predicated backedge-taken count is false
165 ; CHECK-NEXT: Predicates:
166 ; CHECK-NEXT: Loop %for.end: Trip multiple is 1
172 br i1 true, label %for.cond.0, label %for.end
175 %inc = load i32, ptr %val
176 br i1 false, label %for.condt, label %for.cond.0
179 %init = phi i32 [ 0, %for.condt ], [ %inc, %for.end ]
183 ; Do the right thing for unreachable code:
184 define i32 @f6(i32 %x, i32 %y) {
186 ; CHECK-NEXT: Classifying expressions for: @f6
187 ; CHECK-NEXT: %sum = add i32 %x, %y
188 ; CHECK-NEXT: --> (%x + %y) U: full-set S: full-set
189 ; CHECK-NEXT: %v0 = phi i32 [ %sum, %entry ], [ %v1, %unreachable ]
190 ; CHECK-NEXT: --> %v0 U: full-set S: full-set
191 ; CHECK-NEXT: %v1 = phi i32 [ %v0, %merge ], [ 0, %leave_0_cond ]
192 ; CHECK-NEXT: --> %v1 U: full-set S: full-set
193 ; CHECK-NEXT: Determining loop execution counts for: @f6
196 %c0 = icmp sgt i32 %y, 0
197 %sum = add i32 %x, %y
198 br i1 %c0, label %merge, label %leave_1
201 %v0 = phi i32 [ %sum, %entry ], [ %v1, %unreachable ]
202 %c1 = icmp slt i32 %y, 0
203 br i1 %c1, label %leave_0, label %leave_0_cond
209 %v1 = phi i32 [ %v0, %merge ], [ 0, %leave_0_cond ]