@@ -2235,136 +2235,6 @@ func.func @affine_leading_zero_no_outer_bound(%arg0: index, %arg1: index) -> ind
22352235
22362236// -----
22372237
2238- // CHECK-LABEL: func @delin_apply_cancel_exact
2239- // CHECK-SAME: (%[[ARG0:.+]]: index, %[[ARG1:.+]]: memref<?xindex>)
2240- // CHECK-COUNT-6: memref.store %[[ARG0]], %[[ARG1]][%[[ARG0]]]
2241- // CHECK-NOT: memref.store
2242- // CHECK: return
2243- func.func @delin_apply_cancel_exact (%arg0: index , %arg1: memref <?xindex >) {
2244- %a:3 = affine.delinearize_index %arg0 into (4 , 5 ) : index , index , index
2245- %b:3 = affine.delinearize_index %arg0 into (3 , 4 , 5 ) : index , index , index
2246- %c:2 = affine.delinearize_index %arg0 into (20 ) : index , index
2247-
2248- %t1 = affine.apply affine_map <()[s0 , s1 , s2 ] -> (s0 + s1 * 5 + s2 * 20 )>()[%a#2 , %a#1 , %a#0 ]
2249- memref.store %t1 , %arg1 [%t1 ] : memref <?xindex >
2250-
2251- %t2 = affine.apply affine_map <()[s0 , s1 , s2 ] -> (s0 + s2 * 20 + s1 * 5 )>()[%a#2 , %a#1 , %a#0 ]
2252- memref.store %t2 , %arg1 [%t2 ] : memref <?xindex >
2253-
2254- %t3 = affine.apply affine_map <()[s0 , s1 , s2 ] -> (s1 * 20 + s2 * 5 + s0 )>()[%a#2 , %a#0 , %a#1 ]
2255- memref.store %t3 , %arg1 [%t3 ] : memref <?xindex >
2256-
2257- %t4 = affine.apply affine_map <()[s0 , s1 , s2 ] -> (s0 + s1 * 5 + s2 * 20 )>()[%b#2 , %b#1 , %b#0 ]
2258- memref.store %t4 , %arg1 [%t4 ] : memref <?xindex >
2259-
2260- %t5 = affine.apply affine_map <()[s0 , s1 ] -> (s0 + s1 * 20 )>()[%c#1 , %c#0 ]
2261- memref.store %t5 , %arg1 [%t5 ] : memref <?xindex >
2262-
2263- %t6 = affine.apply affine_map <()[s0 , s1 ] -> (s1 * 20 + s0 )>()[%c#1 , %c#0 ]
2264- memref.store %t6 , %arg1 [%t5 ] : memref <?xindex >
2265-
2266- return
2267- }
2268-
2269- // -----
2270-
2271- // CHECK-LABEL: func @delin_apply_cancel_exact_dim
2272- // CHECK: affine.for %[[arg1:.+]] = 0 to 256
2273- // CHECK: memref.store %[[arg1]]
2274- // CHECK: return
2275- func.func @delin_apply_cancel_exact_dim (%arg0: memref <?xindex >) {
2276- affine.for %arg1 = 0 to 256 {
2277- %a:3 = affine.delinearize_index %arg1 into (2 , 2 , 64 ) : index , index , index
2278- %i = affine.apply affine_map <(d0 , d1 , d2 ) -> (d0 + d1 * 128 + d2 * 64 )>(%a#2 , %a#0 , %a#1 )
2279- memref.store %i , %arg0 [%i ] : memref <?xindex >
2280- }
2281- return
2282- }
2283-
2284- // -----
2285-
2286- // CHECK-DAG: #[[$MAP:.+]] = affine_map<()[s0] -> (s0 + 512)>
2287- // CHECK-LABEL: func @delin_apply_cancel_const_term
2288- // CHECK-SAME: (%[[ARG0:.+]]: index, %[[ARG1:.+]]: memref<?xindex>)
2289- // CHECK: affine.apply #[[$MAP]]()[%[[ARG0]]]
2290- // CHECK: return
2291- func.func @delin_apply_cancel_const_term (%arg0: index , %arg1: memref <?xindex >) {
2292- %a:3 = affine.delinearize_index %arg0 into (2 , 2 , 64 ) : index , index , index
2293-
2294- %t1 = affine.apply affine_map <()[s0 , s1 , s2 ] -> (s0 + s1 * 128 + s2 * 64 + 512 )>()[%a#2 , %a#0 , %a#1 ]
2295- memref.store %t1 , %arg1 [%t1 ] : memref <?xindex >
2296-
2297- return
2298- }
2299-
2300- // -----
2301-
2302- // CHECK-DAG: #[[$MAP:.+]] = affine_map<()[s0, s1] -> (s0 + s1 + 512)>
2303- // CHECK-LABEL: func @delin_apply_cancel_var_term
2304- // CHECK-SAME: (%[[ARG0:.+]]: index, %[[ARG1:.+]]: memref<?xindex>, %[[ARG2:.+]]: index)
2305- // CHECK: affine.apply #[[$MAP]]()[%[[ARG2]], %[[ARG0]]]
2306- // CHECK: return
2307- func.func @delin_apply_cancel_var_term (%arg0: index , %arg1: memref <?xindex >, %arg2: index ) {
2308- %a:3 = affine.delinearize_index %arg0 into (2 , 2 , 64 ) : index , index , index
2309-
2310- %t1 = affine.apply affine_map <()[s0 , s1 , s2 , s3 ] -> (s0 + s1 * 128 + s2 * 64 + s3 + 512 )>()[%a#2 , %a#0 , %a#1 , %arg2 ]
2311- memref.store %t1 , %arg1 [%t1 ] : memref <?xindex >
2312-
2313- return
2314- }
2315-
2316- // -----
2317-
2318- // CHECK-DAG: #[[$MAP:.+]] = affine_map<()[s0] -> (s0 * 2 + s0 ceildiv 4)>
2319- // CHECK-LABEL: func @delin_apply_cancel_nested_exprs
2320- // CHECK-SAME: (%[[ARG0:.+]]: index, %[[ARG1:.+]]: memref<?xindex>)
2321- // CHECK: affine.apply #[[$MAP]]()[%[[ARG0]]]
2322- // CHECK: return
2323- func.func @delin_apply_cancel_nested_exprs (%arg0: index , %arg1: memref <?xindex >) {
2324- %a:2 = affine.delinearize_index %arg0 into (20 ) : index , index
2325-
2326- %t1 = affine.apply affine_map <()[s0 , s1 ] -> ((s0 + s1 * 20 ) ceildiv 4 + (s1 * 20 + s0 ) * 2 )>()[%a#1 , %a#0 ]
2327- memref.store %t1 , %arg1 [%t1 ] : memref <?xindex >
2328-
2329- return
2330- }
2331-
2332- // -----
2333-
2334- // CHECK-DAG: #[[$MAP:.+]] = affine_map<()[s0, s1] -> (s0 + s1)>
2335- // CHECK-LABEL: func @delin_apply_cancel_preserve_rotation
2336- // CHECK-SAME: (%[[ARG0:.+]]: index, %[[ARG1:.+]]: memref<?xindex>)
2337- // CHECK: %[[A:.+]]:2 = affine.delinearize_index %[[ARG0]] into (20)
2338- // CHECK: affine.apply #[[$MAP]]()[%[[A]]#1, %[[ARG0]]]
2339- // CHECK: return
2340- func.func @delin_apply_cancel_preserve_rotation (%arg0: index , %arg1: memref <?xindex >) {
2341- %a:2 = affine.delinearize_index %arg0 into (20 ) : index , index
2342-
2343- %t1 = affine.apply affine_map <()[s0 , s1 ] -> (s0 + s1 * 20 + s0 )>()[%a#1 , %a#0 ]
2344- memref.store %t1 , %arg1 [%t1 ] : memref <?xindex >
2345-
2346- return
2347- }
2348-
2349- // -----
2350-
2351- // CHECK-DAG: #[[$MAP:.+]] = affine_map<()[s0, s1] -> (s0 + s1 * 5)>
2352- // CHECK-LABEL: func @delin_apply_dont_cancel_partial
2353- // CHECK-SAME: (%[[ARG0:.+]]: index, %[[ARG1:.+]]: memref<?xindex>)
2354- // CHECK: %[[A:.+]]:3 = affine.delinearize_index %[[ARG0]] into (3, 4, 5)
2355- // CHECK: affine.apply #[[$MAP]]()[%[[A]]#2, %[[A]]#1]
2356- // CHECK: return
2357- func.func @delin_apply_dont_cancel_partial (%arg0: index , %arg1: memref <?xindex >) {
2358- %a:3 = affine.delinearize_index %arg0 into (3 , 4 , 5 ) : index , index , index
2359-
2360- %t1 = affine.apply affine_map <()[s0 , s1 ] -> (s0 + s1 * 5 )>()[%a#2 , %a#1 ]
2361- memref.store %t1 , %arg1 [%t1 ] : memref <?xindex >
2362-
2363- return
2364- }
2365-
2366- // -----
2367-
23682238// CHECK-LABEL: @cst_value_to_cst_attr_basis_delinearize_index
23692239// CHECK-SAME: (%[[ARG0:.*]]: index)
23702240// CHECK: %[[RET:.*]]:3 = affine.delinearize_index %[[ARG0]] into (3, 4, 2) : index, index
0 commit comments