[Mlir-commits] [mlir] [mlir][Vector] Support `xfer_read(vector.extract))` folding with dynamic indices (PR #143269)

Andrzej Warzyński llvmlistbot at llvm.org
Mon Jun 9 10:28:34 PDT 2025


================
@@ -886,12 +886,26 @@ class RewriteScalarExtractOfTransferRead
     SmallVector<Value> newIndices(xferOp.getIndices().begin(),
                                   xferOp.getIndices().end());
     for (auto [i, pos] : llvm::enumerate(extractOp.getMixedPosition())) {
-      assert(isa<Attribute>(pos) && "Unexpected non-constant index");
-      int64_t offset = cast<IntegerAttr>(cast<Attribute>(pos)).getInt();
       int64_t idx = newIndices.size() - extractOp.getNumIndices() + i;
-      OpFoldResult ofr = affine::makeComposedFoldedAffineApply(
-          rewriter, extractOp.getLoc(),
-          rewriter.getAffineSymbolExpr(0) + offset, {newIndices[idx]});
+
+      // Compute affine expression `newIndices[idx] + pos` where `pos` can be
+      // either a constant or a value.
+      OpFoldResult ofr;
----------------
banach-space wrote:

[nit] Would you mind using this opportunity to replace `ofr` with something more descriptive? `ofr` is a bit like `int64_t i64;` 😅  

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


More information about the Mlir-commits mailing list