[Mlir-commits] [mlir] [MLIR] support dynamic indexing of `vector.maskedload` in `VectorEmulateNarrowTypes` (PR #115070)
Han-Chung Wang
llvmlistbot at llvm.org
Mon Nov 11 16:17:48 PST 2024
================
@@ -185,6 +188,25 @@ static Value dynamicallyExtractSubVector(OpBuilder &rewriter, Location loc,
return dest;
}
+/// Inserts a 1-D subvector into a 1-D `dest` vector at index `offset`.
+static Value dynamicallyInsertSubVector(RewriterBase &rewriter, Location loc,
+ TypedValue<VectorType> source,
+ Value dest, OpFoldResult destOffsetVar,
+ int64_t length) {
+ assert(length > 0 && "length must be greater than 0");
+ for (int i = 0; i < length; ++i) {
+ Value insertLoc =
+ i == 0
+ ? destOffsetVar.dyn_cast<Value>()
----------------
hanhanW wrote:
You're assuming that the `destOffsetVar` always has Value type in the implementation, but it could be an attribute. I understand that why you pass it with `OpFoldResult` type, and I think we can still do so. How about we declare a `Value` variable and use `getValueOrCreateConstantIndexOp()` method at the start of the function? (We already assert that the length should be greater than one, so we won't create unused operation. So the approach looks okay to me.)
```
Value destOffsetVal = getValueOrCreateConstantIndexOp(rewriter, loc, destOffsetVar);
// and replace all the `destOffsetVar.dyn_cast<Value>()` with `destOffsetVal`.
```
https://github.com/llvm/llvm-project/pull/115070
More information about the Mlir-commits
mailing list