[Mlir-commits] [mlir] [mlir][vector] Simplify createReadOrMaskedRead (PR #163736)

Andrzej WarzyƄski llvmlistbot at llvm.org
Fri Nov 7 08:32:48 PST 2025


================
@@ -219,18 +219,16 @@ bool isLinearizableVector(VectorType type);
 
 /// Creates a TransferReadOp from `source`.
 ///
-/// The shape of the vector to read is specified via `inputVectorSizes`. If the
-/// shape of the output vector differs from the shape of the value being read,
-/// masking is used to avoid out-of-bounds accesses. Set
+/// If the shape of vector to read differs from the shape of the value being
+/// read, masking is used to avoid out-of-bounds accesses. Set
 /// `useInBoundsInsteadOfMasking` to `true` to use the "in_bounds" attribute
 /// instead of explicit masks.
 ///
 /// Note: all read offsets are set to 0.
 Value createReadOrMaskedRead(OpBuilder &builder, Location loc, Value source,
-                             ArrayRef<int64_t> inputVectorSizes,
+                             const VectorType &vecToReadTy,
----------------
banach-space wrote:

Thanks for the feedback!

> I mainly want to provide a data point that users will have to create VectorType when they don't care about scalable flags

My thinking here was that `createReadOrMaskedRead` always creates an instance of `VectorType`, so:
* When users _do require_ `VectorType`, we make sure that we create it only once and then sizes are easier to track (i.e. "Where are these sizes coming from?")
* When users _do not require_ `VectorType` (like in your case), my PR creates extra burden on the users, but the number of instances of `VectorType` does not change.

To make it easier for you, how about adding an overload:
```
Value createReadOrMaskedRead(OpBuilder &builder, Location loc, Value source,
                             ArrayRef<int64_t> inputVectorSizes,                              
                             std::optional<Value> padValue = std::nullopt,
                             bool useInBoundsInsteadOfMasking = false,
                             ArrayRef<bool> inputScalableVecDims = {}) {

      VectorType readVecType =
      VectorType::get(inputVectorSizes, source.getElementType(),
                      readScalableVectorFlags);
                      
      createReadOrMaskedRead(builder, loc, source, readVecType, padValue, useInBoundsInsteadOfMasking);
}
```
WDYT?

https://github.com/llvm/llvm-project/pull/163736


More information about the Mlir-commits mailing list