[Mlir-commits] [mlir] [mlir][vector] Fix vector.gather lowering for strided memrefs. (PR #184706)
Ian Wood
llvmlistbot at llvm.org
Wed Mar 4 17:00:24 PST 2026
================
@@ -210,8 +255,20 @@ struct Gather1DToConditionalLoads : OpRewritePattern<vector::GatherOp> {
Value condition =
vector::ExtractOp::create(rewriter, loc, condMask, thisIdx);
Value index = vector::ExtractOp::create(rewriter, loc, indexVec, thisIdx);
- baseOffsets.back() =
- rewriter.createOrFold<arith::AddIOp>(loc, lastBaseOffset, index);
+
+ if (needsDelinearization) {
+ // The gather offset was linearized using dense row-major order:
+ // offset = idx[0] * dim[1] * ... * dim[n] + ... + idx[n]
+ // Recover the N-D indices by delinearizing with the memref shape.
----------------
IanWood1 wrote:
Per the comment on https://github.com/iree-org/iree/issues/23637#issuecomment-4000238560, its undefined behavior for `vector.gather`'s indices to overflow the inner dim. Do you plan on making this well-defined?
https://github.com/llvm/llvm-project/pull/184706
More information about the Mlir-commits
mailing list