@@ -370,6 +370,39 @@ module attributes {transform.with_named_sequence} {
370370
371371// -----
372372
373+ // CHECK-LABEL: func.func @no_hoisting_possibly_zero_trip_loop_eq_lb_and_ub
374+ func.func @no_hoisting_possibly_zero_trip_loop_eq_lb_and_ub (%memref0: memref <20 xi32 >, %lb: index , %ub: index ) {
375+ %c0_i32 = arith.constant 0 : i32
376+ %c0 = arith.constant 0 : index
377+ %c1 = arith.constant 1 : index
378+
379+ // %lb_0 is in range [%lb, 8], and %ub_0 is in range [8, %ub].
380+ // Since %lb_0 could be equal to %ub_0, do not hoist.
381+ %lb_0 = affine.min affine_map <(d0 ) -> (d0 , 8 )>(%lb )
382+ %ub_0 = affine.max affine_map <(d0 ) -> (d0 , 8 )>(%ub )
383+
384+ // CHECK: scf.for {{.*}} {
385+ // CHECK-NEXT: vector.transfer_read
386+ // CHECK-NEXT: "test.some_use"
387+ scf.for %arg2 = %lb_0 to %ub_0 step %c1 {
388+ %read = vector.transfer_read %memref0 [%c0 ], %c0_i32 {in_bounds = [true ]} : memref <20 xi32 >, vector <4 xi32 >
389+ " test.some_use" (%read ) : (vector <4 xi32 >) ->()
390+ }
391+ return
392+ }
393+
394+ module attributes {transform.with_named_sequence } {
395+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
396+ %0 = transform.structured.match ops {[" func.func" ]} in %arg1
397+ : (!transform.any_op ) -> !transform.any_op
398+ transform.structured.hoist_redundant_vector_transfers %0 { verify_non_zero_trip }
399+ : (!transform.any_op ) -> !transform.any_op
400+ transform.yield
401+ }
402+ }
403+
404+ // -----
405+
373406// CHECK-LABEL: func.func @hoisting_non_zero_trip_loop
374407func.func @hoisting_non_zero_trip_loop (%memref0: memref <20 xi32 >, %lb: index , %ub: index ) {
375408 %c0_i32 = arith.constant 0 : i32
0 commit comments