@@ -267,3 +267,70 @@ func.func @compare_scf_for(%a: index, %b: index, %c: index) {
267
267
}
268
268
return
269
269
}
270
+
271
+ // -----
272
+
273
+ func.func @scf_for_result_infer () {
274
+ %c0 = arith.constant 0 : index
275
+ %c1 = arith.constant 1 : index
276
+ %c10 = arith.constant 10 : index
277
+ %0 = scf.for %iv = %c0 to %c10 step %c1 iter_args (%arg = %c0 ) -> index {
278
+ %2 = " test.some_use" () : () -> (i1 )
279
+ %3 = scf.if %2 -> (index ) {
280
+ %5 = arith.addi %arg , %c1 : index
281
+ scf.yield %5 : index
282
+ } else {
283
+ scf.yield %arg : index
284
+ }
285
+ scf.yield %3 : index
286
+ }
287
+ // expected-remark @below{{true}}
288
+ " test.compare" (%0 , %c10 ) {cmp = " LE" } : (index , index ) -> ()
289
+ return
290
+ }
291
+
292
+ // -----
293
+
294
+ func.func @scf_for_result_infer_dynamic_init (%i : index ) {
295
+ %c0 = arith.constant 0 : index
296
+ %c1 = arith.constant 1 : index
297
+ %c10 = arith.constant 10 : index
298
+ %0 = scf.for %iv = %c0 to %c10 step %c1 iter_args (%arg = %i ) -> index {
299
+ %2 = " test.some_use" () : () -> (i1 )
300
+ %3 = scf.if %2 -> (index ) {
301
+ %5 = arith.addi %arg , %c1 : index
302
+ scf.yield %5 : index
303
+ } else {
304
+ scf.yield %arg : index
305
+ }
306
+ scf.yield %3 : index
307
+ }
308
+ %6 = arith.addi %i , %c10 : index
309
+ // expected-remark @below{{true}}
310
+ " test.compare" (%0 , %6 ) {cmp = " LE" } : (index , index ) -> ()
311
+ return
312
+ }
313
+
314
+ // -----
315
+
316
+ func.func @scf_for_result_infer_dynamic_init_big_step (%i : index ) {
317
+ %c0 = arith.constant 0 : index
318
+ %c1 = arith.constant 1 : index
319
+ %c2 = arith.constant 2 : index
320
+ %c5 = arith.constant 5 : index
321
+ %c10 = arith.constant 10 : index
322
+ %0 = scf.for %iv = %c0 to %c10 step %c2 iter_args (%arg = %i ) -> index {
323
+ %2 = " test.some_use" () : () -> (i1 )
324
+ %3 = scf.if %2 -> (index ) {
325
+ %5 = arith.addi %arg , %c1 : index
326
+ scf.yield %5 : index
327
+ } else {
328
+ scf.yield %arg : index
329
+ }
330
+ scf.yield %3 : index
331
+ }
332
+ %6 = arith.addi %i , %c5 : index
333
+ // expected-remark @below{{true}}
334
+ " test.compare" (%0 , %6 ) {cmp = " LE" } : (index , index ) -> ()
335
+ return
336
+ }
0 commit comments