@@ -116,10 +116,11 @@ func.func @transfer_read_dims_mismatch_non_zero_indices(
116116// CHECK-SAME: %[[IDX_1:.*]]: index, %[[IDX_2:.*]]: index,
117117// CHECK-SAME: %[[MEM:.*]]: memref<1x43x4x6xi32>
118118// CHECK: %[[C_0:.*]] = arith.constant 0 : i32
119- // CHECK: %[[C_0_IDX:.*]] = arith.constant 0 : index
120- // CHECK: %[[COLLAPSED_IN:.*]] = memref.collapse_shape %[[MEM]] {{\[}}[0], [1, 2, 3]] : memref<1x43x4x6xi32> into memref<1x1032xi32>
119+ // CHECK: %[[COLLAPSED_IN:.*]] = memref.collapse_shape %[[MEM]]
120+ // CHECK-SAME{LITERAL}: [[0, 1, 2, 3]]
121+ // CHECK-SAME: : memref<1x43x4x6xi32> into memref<1032xi32>
121122// CHECK: %[[COLLAPSED_IDX:.*]] = affine.apply #[[$ATTR_0]]()[%[[IDX_1]], %[[IDX_2]]]
122- // CHECK: %[[READ:.*]] = vector.transfer_read %[[COLLAPSED_IN]][%[[C_0_IDX]], %[[ COLLAPSED_IDX]]], %[[C_0]] {in_bounds = [true]} : memref<1x1032xi32 >, vector<12xi32>
123+ // CHECK: %[[READ:.*]] = vector.transfer_read %[[COLLAPSED_IN]][%[[COLLAPSED_IDX]]], %[[C_0]] {in_bounds = [true]} : memref<1032xi32 >, vector<12xi32>
123124
124125// CHECK-128B-LABEL: func @transfer_read_dims_mismatch_non_zero_indices(
125126// CHECK-128B-NOT: memref.collapse_shape
@@ -170,16 +171,18 @@ func.func @transfer_read_leading_dynamic_dims(
170171 return %res : vector <8 x4 xi8 >
171172}
172173
174+ // CHECK: #[[$MAP:.+]] = affine_map<()[s0] -> (s0 * 32)>
175+
173176// CHECK-LABEL: func @transfer_read_leading_dynamic_dims
174177// CHECK-SAME: %[[MEM:.+]]: memref<?x?x8x4xi8, {{.+}}>, %[[IDX_1:.+]]: index, %[[IDX_2:.+]]: index
175178// CHECK: %[[C0_I8:.+]] = arith.constant 0 : i8
176- // CHECK: %[[C0 :.+]] = arith.constant 0 : index
177- // CHECK: %[[COLLAPSED:.+]] = memref.collapse_shape %[[MEM]] {{\[}}[0], [1], [2, 3]{{\]}}
178- // CHECK-SAME: : memref<?x?x8x4xi8, {{.+}}> into memref<?x?x32xi8, {{.+}}>
179+ // CHECK: %[[COLLAPSED :.+]] = memref.collapse_shape %[[MEM]] {{\[}}[0], [1, 2, 3]{{\]}}
180+ // CHECK-SAME : : memref<?x?x8x4xi8, {{.+}}> into memref<?x?xi8, {{.+}}>
181+ // CHECK: %[[COLLAPSED_IDX:.+]] = affine.apply #[[$MAP]]()[%[[IDX_2]]]
179182// CHECK: %[[VEC1D:.+]] = vector.transfer_read %[[COLLAPSED]]
180- // CHECK-SAME: [%[[IDX_1]], %[[IDX_2]], %[[C0 ]]], %[[C0_I8]]
183+ // CHECK-SAME: [%[[IDX_1]], %[[COLLAPSED_IDX ]]], %[[C0_I8]]
181184// CHECK-SAME: {in_bounds = [true]}
182- // CHECK-SAME: : memref<?x?x32xi8 , {{.+}}>, vector<32xi8>
185+ // CHECK-SAME: : memref<?x?xi8 , {{.+}}>, vector<32xi8>
183186// CHECK: %[[RES:.+]] = vector.shape_cast %[[VEC1D]] : vector<32xi8> to vector<8x4xi8>
184187// CHECK: return %[[RES]] : vector<8x4xi8>
185188
@@ -210,13 +213,12 @@ func.func @transfer_read_dynamic_dim_to_flatten(
210213// CHECK-SAME: %[[IDX_2:arg1]]
211214// CHECK-SAME: %[[MEM:arg2]]
212215// CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
213- // CHECK: %[[C0:.*]] = arith.constant 0 : index
214216// CHECK: %[[COLLAPSED:.*]] = memref.collapse_shape %[[MEM]]
215- // CHECK-SAME{LITERAL}: [[0], [ 1, 2, 3]]
216- // CHECK-SAME: memref<1x?x4x6xi32> into memref<1x ?xi32>
217+ // CHECK-SAME{LITERAL}: [[0, 1, 2, 3]]
218+ // CHECK-SAME: memref<1x?x4x6xi32> into memref<?xi32>
217219// CHECK: %[[COLLAPSED_IDX:.*]] = affine.apply #[[$MAP]]()[%[[IDX_1]], %[[IDX_2]]]
218- // CHECK: %[[VEC_1D:.*]] = vector.transfer_read %[[COLLAPSED]][%[[C0]], %[[ COLLAPSED_IDX]]],
219- // CHECK-SAME: %[[C0_I32]] {in_bounds = [true]} : memref<1x ?xi32>, vector<12xi32>
220+ // CHECK: %[[VEC_1D:.*]] = vector.transfer_read %[[COLLAPSED]][%[[COLLAPSED_IDX]]],
221+ // CHECK-SAME: %[[C0_I32]] {in_bounds = [true]} : memref<?xi32>, vector<12xi32>
220222// CHECK: %[[RESULT:.*]] = vector.shape_cast %[[VEC_1D]] : vector<12xi32> to vector<1x2x6xi32>
221223// CHECK: return %[[RESULT]] : vector<1x2x6xi32>
222224
@@ -397,11 +399,10 @@ func.func @transfer_write_dims_mismatch_non_zero_indices(
397399// CHECK-SAME: %[[IDX_1:.*]]: index, %[[IDX_2:.*]]: index,
398400// CHECK-SAME: %[[MEM:.*]]: memref<1x43x4x6xi32>,
399401// CHECK-SAME: %[[VEC:.*]]: vector<1x2x6xi32>) {
400- // CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
401402// CHECK-DAG: %[[IDX:.*]] = affine.apply #[[$ATTR_0]](){{\[}}%[[IDX_1]], %[[IDX_2]]]
402- // CHECK-DAG: %[[CS:.*]] = memref.collapse_shape %[[MEM]] {{\[\[}}0], [ 1, 2, 3]] : memref<1x43x4x6xi32> into memref<1x1032xi32 >
403+ // CHECK-DAG: %[[CS:.*]] = memref.collapse_shape %[[MEM]] {{\[\[}}0, 1, 2, 3]] : memref<1x43x4x6xi32> into memref<1032xi32 >
403404// CHECK: %[[SC:.*]] = vector.shape_cast %[[VEC]] : vector<1x2x6xi32> to vector<12xi32>
404- // CHECK: vector.transfer_write %[[SC]], %[[CS]]{{\[}} %[[C0]], %[[ IDX]]] {in_bounds = [true]} : vector<12xi32>, memref<1x1032xi32 >
405+ // CHECK: vector.transfer_write %[[SC]], %[[CS]][ %[[IDX]]] {in_bounds = [true]} : vector<12xi32>, memref<1032xi32 >
405406
406407// CHECK-128B-LABEL: func @transfer_write_dims_mismatch_non_zero_indices(
407408// CHECK-128B-NOT: memref.collapse_shape
@@ -449,16 +450,18 @@ func.func @transfer_write_leading_dynamic_dims(
449450 return
450451}
451452
453+ // CHECK: #[[$MAP:.+]] = affine_map<()[s0] -> (s0 * 32)>
454+
452455// CHECK-LABEL: func @transfer_write_leading_dynamic_dims
453456// CHECK-SAME: %[[VEC:.+]]: vector<8x4xi8>, %[[MEM:.+]]: memref<?x?x8x4xi8, {{.+}}>, %[[ARG2:.+]]: index, %[[ARG3:.+]]: index
454- // CHECK: %[[C0 :.+]] = arith.constant 0 : index
455- // CHECK: %[[COLLAPSED:.+]] = memref.collapse_shape %[[MEM]] {{\[}}[0], [1], [2, 3]{{\]}}
456- // CHECK-SAME: : memref<?x?x8x4xi8, {{.+}}> into memref<?x?x32xi8, {{.+}}>
457+ // CHECK: %[[COLLAPSED :.+]] = memref.collapse_shape %[[MEM]] {{\[}}[0], [1, 2, 3]{{\]}}
458+ // CHECK-SAME : : memref<?x?x8x4xi8, {{.+}}> into memref<?x?xi8, {{.+}}>
459+ // CHECK: %[[COLLAPSED_IDX:.+]] = affine.apply #[[$MAP]]()[%[[ARG3]]]
457460// CHECK: %[[VEC1D:.+]] = vector.shape_cast %[[VEC]] : vector<8x4xi8> to vector<32xi8>
458461// CHECK: vector.transfer_write %[[VEC1D]], %[[COLLAPSED]]
459- // CHECK-SAME: [%[[ARG2]], %[[ARG3]], %[[C0 ]]]
462+ // CHECK-SAME: [%[[ARG2]], %[[COLLAPSED_IDX ]]]
460463// CHECK-SAME: {in_bounds = [true]}
461- // CHECK-SAME: : vector<32xi8>, memref<?x?x32xi8 , {{.+}}>
464+ // CHECK-SAME: : vector<32xi8>, memref<?x?xi8 , {{.+}}>
462465
463466// CHECK-128B-LABEL: func @transfer_write_leading_dynamic_dims
464467// CHECK-128B: memref.collapse_shape
@@ -488,14 +491,13 @@ func.func @transfer_write_dynamic_to_flatten(
488491// CHECK-SAME: %[[VEC:arg2]]: vector<1x2x6xi32>
489492// CHECK-SAME: %[[MEM:arg3]]: memref<1x?x4x6xi32>
490493
491- // CHECK: %[[C0:.*]] = arith.constant 0 : index
492494// CHECK: %[[COLLAPSED_MEM:.*]] = memref.collapse_shape %[[MEM]]
493- // CHECK-SAME{LITERAL}: [[0], [ 1, 2, 3]]
494- // CHECK-SAME: : memref<1x?x4x6xi32> into memref<1x ?xi32>
495+ // CHECK-SAME{LITERAL}: [[0, 1, 2, 3]]
496+ // CHECK-SAME: : memref<1x?x4x6xi32> into memref<?xi32>
495497// CHECK: %[[COLLAPSED_IDX:.*]] = affine.apply #[[$MAP]]()[%[[IDX_1]], %[[IDX_2]]]
496498// CHECK: %[[VEC_1D:.*]] = vector.shape_cast %[[VEC]] : vector<1x2x6xi32> to vector<12xi32>
497- // CHECK: vector.transfer_write %[[VEC_1D]], %[[COLLAPSED_MEM]][%[[C0]], %[[ COLLAPSED_IDX]]]
498- // CHECK-SAME: {in_bounds = [true]} : vector<12xi32>, memref<1x ?xi32>
499+ // CHECK: vector.transfer_write %[[VEC_1D]], %[[COLLAPSED_MEM]][%[[COLLAPSED_IDX]]]
500+ // CHECK-SAME: {in_bounds = [true]} : vector<12xi32>, memref<?xi32>
499501
500502// CHECK-128B-LABEL: func @transfer_write_dynamic_to_flatten
501503// CHECK-128B-NOT: memref.collapse_shape
@@ -573,8 +575,12 @@ func.func @negative_out_of_bound_transfer_read(
573575 memref <?x4 x3 x2 xi8 , strided <[24 , 6 , 2 , 1 ], offset : ?>>, vector <5 x4 x3 x2 xi8 >
574576 return %res : vector <5 x4 x3 x2 xi8 >
575577}
576- // CHECK: func.func @negative_out_of_bound_transfer_read
577- // CHECK-NOT: memref.collapse_shape
578+ // CHECK-LABEL: func.func @negative_out_of_bound_transfer_read
579+ // CHECK-NOT: memref.collapse_shape
580+
581+ // CHECK-128B-LABEL: func.func @negative_out_of_bound_transfer_read
582+ // CHECK-128B-NOT: memref.collapse_shape
583+ // CHECK-128B-NOT: vector.shape_cast
578584
579585// -----
580586
@@ -585,5 +591,47 @@ func.func @negative_out_of_bound_transfer_write(
585591 vector <1 x1 x3 x2 xi8 >, memref <?x4 x3 x2 xi8 , strided <[24 , 6 , 2 , 1 ], offset : ?>>
586592 return
587593}
588- // CHECK: func.func @negative_out_of_bound_transfer_write
589- // CHECK-NOT: memref.collapse_shape
594+ // CHECK-LABEL: func.func @negative_out_of_bound_transfer_write
595+ // CHECK-NOT: memref.collapse_shape
596+
597+ // CHECK-128B-LABEL: func.func @negative_out_of_bound_transfer_write
598+ // CHECK-128B-NOT: memref.collapse_shape
599+ // CHECK-128B-NOT: vector.shape_cast
600+
601+ // -----
602+
603+ func.func @discontig_mem_contig_slice (
604+ %mem : memref <8 x8 x8 xi32 , strided <[128 , 16 , 1 ]>>, %vec : vector <1 x1 x8 xi32 >) {
605+ %c0 = arith.constant 0 : index
606+ vector.transfer_write %vec , %mem [%c0 , %c0 , %c0 ] {in_bounds = [true , true , true ]} :
607+ vector <1 x1 x8 xi32 >, memref <8 x8 x8 xi32 , strided <[128 , 16 , 1 ]>>
608+ return
609+ }
610+
611+ // CHECK-LABEL: func.func @discontig_mem_contig_slice
612+ // CHECK-SAME: %[[MEM:.+]]: memref<8x8x8xi32, strided<[128, 16, 1]>>
613+ // CHECK-SAME: %[[VEC:.+]]: vector<1x1x8xi32>
614+ // CHECK: %[[C0:.+]] = arith.constant 0 : index
615+ // CHECK: %[[VEC_1D:.+]] = vector.shape_cast %[[VEC]] : vector<1x1x8xi32> to vector<8xi32>
616+ // CHECK: vector.transfer_write %[[VEC_1D]], %[[MEM]][%[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true]}
617+ // CHECK-SAME: : vector<8xi32>, memref<8x8x8xi32, strided<[128, 16, 1]>>
618+
619+ // CHECK-128B-LABEL: func.func @discontig_mem_contig_slice
620+ // CHECK-128B-NOT: vector.shape_cast
621+
622+ // -----
623+
624+ func.func @discontig_mem_discontig_slice (
625+ %mem : memref <8 x8 x8 xi32 , strided <[128 , 16 , 1 ]>>, %vec : vector <1 x2 x8 xi32 >) {
626+ %c0 = arith.constant 0 : index
627+ vector.transfer_write %vec , %mem [%c0 , %c0 , %c0 ] {in_bounds = [true , true , true ]} :
628+ vector <1 x2 x8 xi32 >, memref <8 x8 x8 xi32 , strided <[128 , 16 , 1 ]>>
629+ return
630+ }
631+
632+ // CHECK-LABEL: func.func @discontig_mem_discontig_slice
633+ // CHECK-NOT: vector.shape_cast
634+
635+ // CHECK-128B-LABEL: func.func @discontig_mem_discontig_slice
636+ // CHECK-128B-NOT: vector.shape_cast
637+
0 commit comments