Skip to content

Commit b44d16b

Browse files
committed
address comments
Signed-off-by: Max Dawkins <[email protected]>
1 parent 0ea1156 commit b44d16b

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,15 @@ void mlir::linalg::hoistRedundantVectorTransfers(Operation *root,
232232
ValueBoundsConstraintSet::computeConstantBound(
233233
presburger::BoundType::UB, lb,
234234
/*stopCondition=*/nullptr, /*closedUB=*/true);
235-
if (failed(maxLb)) {
235+
if (failed(maxLb))
236236
return;
237-
}
238237
FailureOr<int64_t> minUb =
239238
ValueBoundsConstraintSet::computeConstantBound(
240239
presburger::BoundType::LB, ub);
241-
if (failed(minUb)) {
240+
if (failed(minUb))
242241
return;
243-
}
244-
if (minUb.value() <= maxLb.value()) {
242+
if (minUb.value() <= maxLb.value())
245243
return;
246-
}
247244
definiteNonZeroTripCountLoops.insert(loopLike);
248245
}
249246
});

mlir/test/Dialect/Linalg/hoisting.mlir

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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<20xi32>, %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<20xi32>, vector<4xi32>
389+
"test.some_use"(%read) : (vector<4xi32>) ->()
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
374407
func.func @hoisting_non_zero_trip_loop(%memref0: memref<20xi32>, %lb: index, %ub: index) {
375408
%c0_i32 = arith.constant 0 : i32

0 commit comments

Comments
 (0)