diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -1423,8 +1423,10 @@ return rewriter.notifyMatchFailure( padOp, "result tensor shape must match input vector sizes"); } - if (llvm::any_of(padOp.getStaticLow(), - [](int64_t val) { return val != 0; })) { + if (llvm::any_of(padOp.getLow(), [](Value v) { + std::optional res = getConstantIntValue(v); + return !res.has_value() || res.value() != 0; + })) { LDBG("low pad must all be zero: " << padOp << "\n"); return rewriter.notifyMatchFailure(padOp, "low pad must all be zero"); } diff --git a/mlir/test/Dialect/Linalg/vectorization.mlir b/mlir/test/Dialect/Linalg/vectorization.mlir --- a/mlir/test/Dialect/Linalg/vectorization.mlir +++ b/mlir/test/Dialect/Linalg/vectorization.mlir @@ -2848,7 +2848,8 @@ // CHECK: vector.transfer_write %[[masked_read]], %[[empty]][%[[c0]], %[[c0]]] // CHECK-SAME: {in_bounds = [true, true]} : vector<2x4xf32>, tensor<2x4xf32> %cst = arith.constant 42.43 : f32 - %1 = tensor.pad %0 low[0, 0] high[%h0, %h1] { + %c0 = arith.constant 0 : index + %1 = tensor.pad %0 low[0, %c0] high[%h0, %h1] { ^bb0(%hh1: index, %hh2: index): tensor.yield %cst : f32 } : tensor to tensor<2x4xf32>