@@ -163,8 +163,8 @@ func.func @compare_maps(%a: index, %b: index) {
163163// CHECK-DAG: #[[$map3:.+]] = affine_map<()[s0] -> (s0 mod 5)>
164164// CHECK-LABEL: func.func @delinearize_static
165165// CHECK-SAME: (%[[arg0:.+]]: index)
166- // CHECK-DAG: %[[v1:.+]] = affine.apply #[[$map1]](} [%[[arg0]]]
167- // CHECK-DAG: %[[v2:.+]] = affine.apply #[[$map2]](} [%[[arg0]]]
166+ // CHECK-DAG: %[[v1:.+]] = affine.apply #[[$map1]]() [%[[arg0]]]
167+ // CHECK-DAG: %[[v2:.+]] = affine.apply #[[$map2]]() [%[[arg0]]]
168168// CHECK-DAG: %[[v3:.+]] = affine.apply #[[$map3]]()[%[[arg0]]]
169169// CHECK: return %[[v1]], %[[v2]], %[[v3]]
170170func.func @delinearize_static (%arg0: index ) -> (index , index , index ) {
@@ -174,7 +174,31 @@ func.func @delinearize_static(%arg0: index) -> (index, index, index) {
174174 %1 = " test.reify_bound" (%0#0 ) {type = " EQ" } : (index ) -> (index )
175175 %2 = " test.reify_bound" (%0#1 ) {type = " EQ" } : (index ) -> (index )
176176 %3 = " test.reify_bound" (%0#2 ) {type = " EQ" } : (index ) -> (index )
177- // TODO: why doesn't this return true? I'm setting the bound.
177+ // expected-remark @below{{true}}
178+ " test.compare" (%0#0 , %c2 ) {cmp = " LT" } : (index , index ) -> ()
179+ // expected-remark @below{{true}}
180+ " test.compare" (%0#1 , %c3 ) {cmp = " LT" } : (index , index ) -> ()
181+ return %1 , %2 , %3 : index , index , index
182+ }
183+
184+ // -----
185+
186+ // CHECK-DAG: #[[$map1:.+]] = affine_map<()[s0] -> (s0 floordiv 15)>
187+ // CHECK-DAG: #[[$map2:.+]] = affine_map<()[s0] -> ((s0 mod 15) floordiv 5)>
188+ // CHECK-DAG: #[[$map3:.+]] = affine_map<()[s0] -> (s0 mod 5)>
189+ // CHECK-LABEL: func.func @delinearize_static_no_outer_bound
190+ // CHECK-SAME: (%[[arg0:.+]]: index)
191+ // CHECK-DAG: %[[v1:.+]] = affine.apply #[[$map1]]()[%[[arg0]]]
192+ // CHECK-DAG: %[[v2:.+]] = affine.apply #[[$map2]]()[%[[arg0]]]
193+ // CHECK-DAG: %[[v3:.+]] = affine.apply #[[$map3]]()[%[[arg0]]]
194+ // CHECK: return %[[v1]], %[[v2]], %[[v3]]
195+ func.func @delinearize_static_no_outer_bound (%arg0: index ) -> (index , index , index ) {
196+ %c2 = arith.constant 2 : index
197+ %c3 = arith.constant 3 : index
198+ %0:3 = affine.delinearize_index %arg0 into (3 , 5 ) : index , index , index
199+ %1 = " test.reify_bound" (%0#0 ) {type = " EQ" } : (index ) -> (index )
200+ %2 = " test.reify_bound" (%0#1 ) {type = " EQ" } : (index ) -> (index )
201+ %3 = " test.reify_bound" (%0#2 ) {type = " EQ" } : (index ) -> (index )
178202 " test.compaare" (%0#0 , %c2 ) {cmp = " LT" } : (index , index ) -> ()
179203 // expected-remark @below{{true}}
180204 " test.compare" (%0#1 , %c3 ) {cmp = " LT" } : (index , index ) -> ()
@@ -186,10 +210,29 @@ func.func @delinearize_static(%arg0: index) -> (index, index, index) {
186210// CHECK: #[[$map:.+]] = affine_map<()[s0, s1] -> (s0 + s1 * 3)>
187211// CHECK-LABEL: func.func @linearize_static
188212// CHECK-SAME: (%[[arg0:.+]]: index, %[[arg1:.+]]: index)
189- // CHECK: %[[v1:.+]] = affine.apply #[[$map]]()[%[[arg0 ]], %[[arg1 ]]]
213+ // CHECK: %[[v1:.+]] = affine.apply #[[$map]]()[%[[arg1 ]], %[[arg0 ]]]
190214// CHECK: return %[[v1]]
191215func.func @linearize_static (%arg0: index , %arg1: index ) -> index {
216+ %c6 = arith.constant 6 : index
192217 %0 = affine.linearize_index disjoint [%arg0 , %arg1 ] by (2 , 3 ) : index
193218 %1 = " test.reify_bound" (%0 ) {type = " EQ" } : (index ) -> (index )
219+ // expected-remark @below{{true}}
220+ " test.compare" (%0 , %c6 ) {cmp = " LT" } : (index , index ) -> ()
221+ return %1 : index
222+ }
223+
224+ // -----
225+
226+ // CHECK: #[[$map:.+]] = affine_map<()[s0, s1] -> (s0 + s1 * 3)>
227+ // CHECK-LABEL: func.func @linearize_static_no_outer_bound
228+ // CHECK-SAME: (%[[arg0:.+]]: index, %[[arg1:.+]]: index)
229+ // CHECK: %[[v1:.+]] = affine.apply #[[$map]]()[%[[arg1]], %[[arg0]]]
230+ // CHECK: return %[[v1]]
231+ func.func @linearize_static_no_outer_bound (%arg0: index , %arg1: index ) -> index {
232+ %c6 = arith.constant 6 : index
233+ %0 = affine.linearize_index disjoint [%arg0 , %arg1 ] by (3 ) : index
234+ %1 = " test.reify_bound" (%0 ) {type = " EQ" } : (index ) -> (index )
235+ // expected-error @below{{unknown}}
236+ " test.compare" (%0 , %c6 ) {cmp = " LT" } : (index , index ) -> ()
194237 return %1 : index
195238}
0 commit comments