@@ -67,6 +67,41 @@ func.func @fully_static_bounds() -> i32 {
67
67
68
68
// -----
69
69
70
+ // CHECK: func @fully_static_bounds_integers(
71
+ // CHECK-DAG: %[[C0:.*]] = arith.constant 0 : i32
72
+ // CHECK-DAG: %[[C1:.*]] = arith.constant 1 : i32
73
+ // CHECK-DAG: %[[C4:.*]] = arith.constant 4 : i32
74
+ // CHECK-DAG: %[[C16:.*]] = arith.constant 16 : i32
75
+ // CHECK: %[[LOOP:.*]] = scf.for %[[IV:.*]] = %[[C0]] to %[[C16]]
76
+ // CHECK-SAME: step %[[C4]] iter_args(%[[ACC:.*]] = %[[C0]]) -> (i32)
77
+ // CHECK: %[[MAP:.*]] = affine.min
78
+ // CHECK: %[[MAP_CAST:.*]] = arith.index_cast %[[MAP]]
79
+ // CHECK: %[[ADD:.*]] = arith.addi %[[ACC]], %[[MAP_CAST]] : i32
80
+ // CHECK: scf.yield %[[ADD]]
81
+ // CHECK: }
82
+ // CHECK: %[[RESULT:.*]] = arith.addi %[[LOOP]], %[[C1]] : i32
83
+ // CHECK: return %[[RESULT]]
84
+ #map = affine_map <(d0 , d1 )[s0 ] -> (s0 , d0 - d1 )>
85
+ func.func @fully_static_bounds_integers () -> i32 {
86
+ %c0_i32 = arith.constant 0 : i32
87
+ %lb = arith.constant 0 : i32
88
+ %step = arith.constant 4 : i32
89
+ %ub = arith.constant 17 : i32
90
+ %r = scf.for %iv = %lb to %ub step %step
91
+ iter_args (%arg = %c0_i32 ) -> i32 : i32 {
92
+ %ub_index = arith.index_cast %ub : i32 to index
93
+ %iv_index = arith.index_cast %iv : i32 to index
94
+ %step_index = arith.index_cast %step : i32 to index
95
+ %s = affine.min #map (%ub_index , %iv_index )[%step_index ]
96
+ %casted = arith.index_cast %s : index to i32
97
+ %0 = arith.addi %arg , %casted : i32
98
+ scf.yield %0 : i32
99
+ }
100
+ return %r : i32
101
+ }
102
+
103
+ // -----
104
+
70
105
// CHECK-DAG: #[[MAP0:.*]] = affine_map<()[s0] -> ((s0 floordiv 4) * 4)>
71
106
// CHECK-DAG: #[[MAP1:.*]] = affine_map<(d0)[s0] -> (-d0 + s0)>
72
107
// CHECK: func @dynamic_upper_bound(
0 commit comments