[Mlir-commits] [mlir] [MLIR] Make generic skip packing init operand when not used in DataLayoutPropagation (PR #146139)

Zhuoran Yin llvmlistbot at llvm.org
Mon Jun 30 11:08:21 PDT 2025


================
@@ -358,6 +358,19 @@ static GenericOp packGenericOp(RewriterBase &rewriter, GenericOp genericOp,
   return newGenericOp;
 }
 
+static bool isGenericOutsNotUsed(linalg::GenericOp genericOp) {
+  Block *block = genericOp.getBody();
+  int numBlockArgs = block->getNumArguments();
+  int numDpsOuts = genericOp.getNumDpsInits();
+  int initArgStartIndex = numBlockArgs - numDpsOuts;
+  for (int i = 0; i < numDpsOuts; ++i) {
+    int matchingInitArgIndex = initArgStartIndex + i;
+    if (!block->getArgument(matchingInitArgIndex).use_empty())
+      return false;
+  }
+  return true;
+}
----------------
jerryyin wrote:

Very cool! Learned something new today.

I need to leave a note to myself about reading the tablegen'ed interface from linalg interface and reading the functions defined in the Type itself (Opoperand type).

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


More information about the Mlir-commits mailing list