[Mlir-commits] [mlir] [MLIR] support dynamic indexing in `VectorEmulateNarrowTypes` (PR #114169)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 31 20:06:35 PDT 2024
================
@@ -149,6 +152,48 @@ static Value insertSubvectorInto(RewriterBase &rewriter, Location loc,
dest, offsets, strides);
}
+/// Extracts `lengthSubvec` elements from `srcVec` into `destVec` starting at
+/// the offset specified by `srcOffsetVar`. Use this function when
+/// `srcOffsetVar` is not a constant, making it impossible to use
+/// vector.extract_strided_slice, as it requires constant offsets.
+static Value dynamicallyExtractSubVector(RewriterBase &rewriter, Location loc,
+ TypedValue<VectorType> srcVec,
+ Value destVec,
+ OpFoldResult srcOffsetVar,
+ int64_t lengthSubvec) {
+ for (int i = 0; i < lengthSubvec; ++i) {
+ Value extractLoc;
+ if (i == 0) {
+ extractLoc = srcOffsetVar.dyn_cast<Value>();
+ } else {
+ extractLoc = rewriter.create<arith::AddIOp>(
+ loc, rewriter.getIndexType(), srcOffsetVar.dyn_cast<Value>(),
+ rewriter.create<arith::ConstantIndexOp>(loc, i));
+ }
----------------
lialan wrote:
thanks :-)
https://github.com/llvm/llvm-project/pull/114169
More information about the Mlir-commits
mailing list