[Mlir-commits] [mlir] [mlir][Affine] Account for eliminated stores in fusion cost (PR #220711)

Uday Bondhugula llvmlistbot at llvm.org
Sat Sep 12 13:03:24 PDT 2026


================
@@ -596,15 +596,12 @@ bool mlir::affine::getFusionComputeCost(AffineForOp srcForOp,
   if (storeLoadFwdGuaranteed) {
     // Subtract from operation count the loads/store we expect load/store
     // forwarding to remove.
-    unsigned storeCount = 0;
     llvm::SmallDenseSet<Value, 4> storeMemrefs;
     srcForOp.walk([&](AffineWriteOpInterface storeOp) {
       storeMemrefs.insert(storeOp.getMemRef());
-      ++storeCount;
+      if (auto forOp = dyn_cast_or_null<AffineForOp>(storeOp->getParentOp()))
----------------
bondhugula wrote:

To be accurate, `forOp` here should be the closest surrounding affine.for of `storeOp` as opposed to its parent op, but this is a pre-existing inaccuracy that should also be fixed at L616 - I can do that in another PR.

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


More information about the Mlir-commits mailing list