1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -S -passes='print<scalar-evolution>' -disable-output < %s 2>&1 | FileCheck %s
4 ; Test non-unit strides in multiple-exit loops, and the interaction with
7 define void @test_preinc_ult(i64 %len) {
8 ; CHECK-LABEL: 'test_preinc_ult'
9 ; CHECK-NEXT: Classifying expressions for: @test_preinc_ult
10 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
11 ; CHECK-NEXT: --> {0,+,2}<nuw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
12 ; CHECK-NEXT: %iv.inc2 = add nuw i64 %iv, 2
13 ; CHECK-NEXT: --> {2,+,2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
14 ; CHECK-NEXT: Determining loop execution counts for: @test_preinc_ult
15 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
16 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
17 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
18 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
19 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
25 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
26 %cmp1 = icmp ult i64 %iv, %len
27 br i1 %cmp1, label %latch, label %exit
30 %iv.inc2 = add nuw i64 %iv, 2
31 %cmp2 = icmp ult i64 %iv.inc2, %len
32 br i1 %cmp2, label %loop, label %exit
38 define void @test_postinc_ult(i64 %len) {
39 ; CHECK-LABEL: 'test_postinc_ult'
40 ; CHECK-NEXT: Classifying expressions for: @test_postinc_ult
41 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
42 ; CHECK-NEXT: --> {0,+,2}<nuw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
43 ; CHECK-NEXT: %iv.inc = add nuw i64 %iv, 1
44 ; CHECK-NEXT: --> {1,+,2}<nuw><%loop> U: [1,0) S: [1,0) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
45 ; CHECK-NEXT: %iv.inc2 = add nuw i64 %iv, 2
46 ; CHECK-NEXT: --> {2,+,2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
47 ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_ult
48 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
49 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
50 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
51 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
52 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
58 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
59 %iv.inc = add nuw i64 %iv, 1
60 %cmp1 = icmp ult i64 %iv.inc, %len
61 br i1 %cmp1, label %latch, label %exit
64 %iv.inc2 = add nuw i64 %iv, 2
65 %cmp2 = icmp ult i64 %iv.inc2, %len
66 br i1 %cmp2, label %loop, label %exit
72 define void @test_preinc_slt(i64 %len) {
73 ; CHECK-LABEL: 'test_preinc_slt'
74 ; CHECK-NEXT: Classifying expressions for: @test_preinc_slt
75 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
76 ; CHECK-NEXT: --> {0,+,2}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
77 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, 2
78 ; CHECK-NEXT: --> {2,+,2}<nuw><%loop> U: [2,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
79 ; CHECK-NEXT: Determining loop execution counts for: @test_preinc_slt
80 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
81 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
82 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
83 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
84 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
90 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
91 %cmp1 = icmp slt i64 %iv, %len
92 br i1 %cmp1, label %latch, label %exit
95 %iv.inc2 = add nsw i64 %iv, 2
96 %cmp2 = icmp slt i64 %iv.inc2, %len
97 br i1 %cmp2, label %loop, label %exit
103 define void @test_postinc_slt(i64 %len) {
104 ; CHECK-LABEL: 'test_postinc_slt'
105 ; CHECK-NEXT: Classifying expressions for: @test_postinc_slt
106 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
107 ; CHECK-NEXT: --> {0,+,2}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
108 ; CHECK-NEXT: %iv.inc = add nsw i64 %iv, 1
109 ; CHECK-NEXT: --> {1,+,2}<nuw><nsw><%loop> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
110 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, 2
111 ; CHECK-NEXT: --> {2,+,2}<nuw><%loop> U: [2,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
112 ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_slt
113 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
114 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
115 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
116 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
117 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
123 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
124 %iv.inc = add nsw i64 %iv, 1
125 %cmp1 = icmp slt i64 %iv.inc, %len
126 br i1 %cmp1, label %latch, label %exit
129 %iv.inc2 = add nsw i64 %iv, 2
130 %cmp2 = icmp slt i64 %iv.inc2, %len
131 br i1 %cmp2, label %loop, label %exit
137 define void @test_preinc_sgt(i64 %lim) {
138 ; CHECK-LABEL: 'test_preinc_sgt'
139 ; CHECK-NEXT: Classifying expressions for: @test_preinc_sgt
140 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
141 ; CHECK-NEXT: --> {0,+,-2}<nsw><%loop> U: [0,-1) S: [-9223372036854775808,1) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
142 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, -2
143 ; CHECK-NEXT: --> {-2,+,-2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
144 ; CHECK-NEXT: Determining loop execution counts for: @test_preinc_sgt
145 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
146 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
147 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
148 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
149 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
155 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
156 %cmp1 = icmp sgt i64 %iv, %lim
157 br i1 %cmp1, label %latch, label %exit
160 %iv.inc2 = add nsw i64 %iv, -2
161 %cmp2 = icmp sgt i64 %iv.inc2, %lim
162 br i1 %cmp2, label %loop, label %exit
168 define void @test_postinc_sgt(i64 %lim) {
169 ; CHECK-LABEL: 'test_postinc_sgt'
170 ; CHECK-NEXT: Classifying expressions for: @test_postinc_sgt
171 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
172 ; CHECK-NEXT: --> {0,+,-2}<nsw><%loop> U: [0,-1) S: [-9223372036854775808,1) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
173 ; CHECK-NEXT: %iv.inc = add nsw i64 %iv, -1
174 ; CHECK-NEXT: --> {-1,+,-2}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
175 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, -2
176 ; CHECK-NEXT: --> {-2,+,-2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
177 ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_sgt
178 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
179 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
180 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
181 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
182 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
188 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
189 %iv.inc = add nsw i64 %iv, -1
190 %cmp1 = icmp sgt i64 %iv.inc, %lim
191 br i1 %cmp1, label %latch, label %exit
194 %iv.inc2 = add nsw i64 %iv, -2
195 %cmp2 = icmp sgt i64 %iv.inc2, %lim
196 br i1 %cmp2, label %loop, label %exit