[Mlir-commits] [mlir] [mlir][affine] Preserve used sibling loop results during fusion (PR #216564)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Tue Sep 22 02:15:39 PDT 2026


================
@@ -124,6 +126,168 @@ static bool canRemoveSrcNodeAfterFusion(
   return true;
 }
 
+static void replaceInits(RewriterBase &rewriter, AffineForOp forOp,
+                         ArrayRef<unsigned> initIndices, ValueRange newInits) {
+  assert(initIndices.size() == newInits.size() &&
+         "expected one replacement value per init operand index");
+
+  SmallVector<Value> inits(forOp.getInits());
+  assert(llvm::all_of(initIndices,
+                      [&](unsigned index) { return index < inits.size(); }) &&
+         "expected replacement indices to fit in affine.for init operands");
----------------
ftynse wrote:

Why do we need this complexity? Can't the caller just give an ordered list of new init values? This check is also insufficient as it doesn't guarantee that `initIndices` are unique.

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


More information about the Mlir-commits mailing list