@@ -395,6 +395,73 @@ module attributes {transform.with_named_sequence} {
395395
396396// -----
397397
398+ // CHECK-LABEL: @dead_store_through_subview
399+ // CHECK-SAME: (%[[ARG:.+]]: vector<4xf32>)
400+ // CHECK-NOT: memref.alloc()
401+ // CHECK-NOT: vector.transfer_write
402+ func.func @dead_store_through_subview (%arg: vector <4 xf32 >) {
403+ %c0 = arith.constant 0 : index
404+ %alloc = memref.alloc () {alignment = 64 : i64 } : memref <64 xf32 >
405+ %subview = memref.subview %alloc [%c0 ] [4 ] [1 ] : memref <64 xf32 > to memref <4 xf32 , affine_map <(d0 )[s0 ] -> (d0 + s0 )>>
406+ vector.transfer_write %arg , %subview [%c0 ] {in_bounds = [true ]}
407+ : vector <4 xf32 >, memref <4 xf32 , affine_map <(d0 )[s0 ] -> (d0 + s0 )>>
408+ return
409+ }
410+
411+ module attributes {transform.with_named_sequence } {
412+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
413+ %0 = transform.structured.match ops {[" func.func" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
414+ transform.memref.erase_dead_alloc_and_stores %0 : (!transform.any_op ) -> ()
415+ transform.yield
416+ }
417+ }
418+
419+ // -----
420+
421+ // CHECK-LABEL: @dead_store_through_expand
422+ // CHECK-SAME: (%[[ARG:.+]]: vector<4xf32>)
423+ // CHECK-NOT: memref.alloc()
424+ // CHECK-NOT: vector.transfer_write
425+ func.func @dead_store_through_expand (%arg: vector <4 xf32 >) {
426+ %c0 = arith.constant 0 : index
427+ %alloc = memref.alloc () {alignment = 64 : i64 } : memref <64 xf32 >
428+ %expand = memref.expand_shape %alloc [[0 , 1 ]] output_shape [16 , 4 ] : memref <64 xf32 > into memref <16 x4 xf32 >
429+ vector.transfer_write %arg , %expand [%c0 , %c0 ] {in_bounds = [true ]} : vector <4 xf32 >, memref <16 x4 xf32 >
430+ return
431+ }
432+
433+ module attributes {transform.with_named_sequence } {
434+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
435+ %0 = transform.structured.match ops {[" func.func" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
436+ transform.memref.erase_dead_alloc_and_stores %0 : (!transform.any_op ) -> ()
437+ transform.yield
438+ }
439+ }
440+
441+ // -----
442+
443+ // CHECK-LABEL: @dead_store_through_collapse
444+ // CHECK-SAME: (%[[ARG:.+]]: vector<4xf32>)
445+ // CHECK-NOT: memref.alloc()
446+ // CHECK-NOT: vector.transfer_write
447+ func.func @dead_store_through_collapse (%arg: vector <4 xf32 >) {
448+ %c0 = arith.constant 0 : index
449+ %alloc = memref.alloc () {alignment = 64 : i64 } : memref <16 x4 xf32 >
450+ %collapse = memref.collapse_shape %alloc [[0 , 1 ]] : memref <16 x4 xf32 > into memref <64 xf32 >
451+ vector.transfer_write %arg , %collapse [%c0 ] {in_bounds = [true ]} : vector <4 xf32 >, memref <64 xf32 >
452+ return
453+ }
454+
455+ module attributes {transform.with_named_sequence } {
456+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
457+ %0 = transform.structured.match ops {[" func.func" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
458+ transform.memref.erase_dead_alloc_and_stores %0 : (!transform.any_op ) -> ()
459+ transform.yield
460+ }
461+ }
462+
463+ // -----
464+
398465// CHECK-LABEL: func @lower_to_llvm
399466// CHECK-NOT: memref.alloc
400467// CHECK: llvm.call @malloc
0 commit comments