@@ -123,3 +123,68 @@ loop:
123
123
exit:
124
124
ret void
125
125
}
126
+
127
+ declare void @use.i64 (i64 )
128
+
129
+ define void @dividend_not_known_multiple_of_divisor (i64 %x ) {
130
+ ; CHECK-LABEL: 'dividend_not_known_multiple_of_divisor'
131
+ ; CHECK-NEXT: Classifying expressions for: @dividend_not_known_multiple_of_divisor
132
+ ; CHECK-NEXT: %mul.2 = shl i64 %x, 1
133
+ ; CHECK-NEXT: --> (2 * %x) U: [0,-1) S: [-9223372036854775808,9223372036854775807)
134
+ ; CHECK-NEXT: %div.16 = lshr exact i64 %mul.2, 4
135
+ ; CHECK-NEXT: --> ((2 * %x) /u 16) U: [0,1152921504606846976) S: [0,1152921504606846976)
136
+ ; CHECK-NEXT: %m2 = and i64 %div.16, 1152921504606846974
137
+ ; CHECK-NEXT: --> (2 * ((2 * %x) /u 32))<nuw><nsw> U: [0,1152921504606846975) S: [0,1152921504606846975)
138
+ ; CHECK-NEXT: %m3 = mul i64 %div.16, 2
139
+ ; CHECK-NEXT: --> (2 * ((2 * %x) /u 16))<nuw><nsw> U: [0,2305843009213693951) S: [0,2305843009213693951)
140
+ ; CHECK-NEXT: %m4 = udiv i64 %m3, 4
141
+ ; CHECK-NEXT: --> ((2 * ((2 * %x) /u 16))<nuw><nsw> /u 4) U: [0,576460752303423488) S: [0,576460752303423488)
142
+ ; CHECK-NEXT: Determining loop execution counts for: @dividend_not_known_multiple_of_divisor
143
+ ;
144
+ entry:
145
+ %mul.2 = shl i64 %x , 1
146
+ %div.16 = lshr exact i64 %mul.2 , 4
147
+ %m2 = and i64 %div.16 , 1152921504606846974
148
+ call void @use.i64 (i64 %m2 )
149
+
150
+ %m3 = mul i64 %div.16 , 2
151
+ %m4 = udiv i64 %m3 , 4
152
+ call void @use.i64 (i64 %m4 )
153
+ ret void
154
+ }
155
+
156
+ define void @btc_depends_on_div_mul (i64 %x ) {
157
+ ; CHECK-LABEL: 'btc_depends_on_div_mul'
158
+ ; CHECK-NEXT: Classifying expressions for: @btc_depends_on_div_mul
159
+ ; CHECK-NEXT: %mul.2 = shl i64 %x, 1
160
+ ; CHECK-NEXT: --> (2 * %x) U: [0,-1) S: [-9223372036854775808,9223372036854775807)
161
+ ; CHECK-NEXT: %div.16 = lshr exact i64 %mul.2, 4
162
+ ; CHECK-NEXT: --> ((2 * %x) /u 16) U: [0,1152921504606846976) S: [0,1152921504606846976)
163
+ ; CHECK-NEXT: %masked = and i64 %div.16, 1152921504606846974
164
+ ; CHECK-NEXT: --> (2 * ((2 * %x) /u 32))<nuw><nsw> U: [0,1152921504606846975) S: [0,1152921504606846975)
165
+ ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
166
+ ; CHECK-NEXT: --> {0,+,2}<%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: (-2 + (2 * ((2 * %x) /u 32))<nuw><nsw>)<nsw> LoopDispositions: { %loop: Computable }
167
+ ; CHECK-NEXT: %iv.next = add i64 %iv, 2
168
+ ; CHECK-NEXT: --> {2,+,2}<%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: (2 * ((2 * %x) /u 32))<nuw><nsw> LoopDispositions: { %loop: Computable }
169
+ ; CHECK-NEXT: Determining loop execution counts for: @btc_depends_on_div_mul
170
+ ; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + (2 * ((2 * %x) /u 32))<nuw><nsw>)<nsw> /u 2)
171
+ ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 9223372036854775807
172
+ ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-2 + (2 * ((2 * %x) /u 32))<nuw><nsw>)<nsw> /u 2)
173
+ ; CHECK-NEXT: Loop %loop: Trip multiple is 1
174
+ ;
175
+ entry:
176
+ %mul.2 = shl i64 %x , 1
177
+ %div.16 = lshr exact i64 %mul.2 , 4
178
+ %masked = and i64 %div.16 , 1152921504606846974
179
+ br label %loop
180
+
181
+ loop:
182
+ %iv = phi i64 [ 0 , %entry ], [ %iv.next , %loop ]
183
+ call void @use.i64 (i64 %iv )
184
+ %iv.next = add i64 %iv , 2
185
+ %ec = icmp eq i64 %iv.next , %masked
186
+ br i1 %ec , label %exit , label %loop
187
+
188
+ exit:
189
+ ret void
190
+ }
0 commit comments