[Mlir-commits] [mlir] [MLIR] Folding unpack and pack sequence in data layout propagation from padded domain (PR #138332)

Han-Chung Wang llvmlistbot at llvm.org
Mon May 5 14:24:15 PDT 2025


================
@@ -298,20 +298,60 @@ getOrCreatePackedViewOfOperand(OpBuilder &b, Location loc, PackInfo packInfo,
   return std::make_tuple(packedOperand, indexingMap);
 }
 
+static bool isGenericOutsNotUsed(linalg::GenericOp genericOp) {
+  int numDpsOuts = genericOp.getNumDpsInits();
+  Block *block = genericOp.getBody();
+  int numBlockArgs = block->getNumArguments();
+  int initArgStartIndex = numBlockArgs - numDpsOuts;
+  for (int i = 0; i < numDpsOuts; ++i) {
+    int matchingInitArgIndex = initArgStartIndex + i;
+    return block->getArgument(matchingInitArgIndex).use_empty();
+  }
+  return true;
+}
+
 /// Pack a genericOp and return it.
 static GenericOp packGenericOp(RewriterBase &rewriter, GenericOp genericOp,
                                Value dest, AffineMap packedOutIndexingMap,
-                               const PackInfo &packInfo) {
+                               const PackInfo &packInfo,
+                               bool canUnpackPackFold) {
----------------
hanhanW wrote:

optional nit: I'd rename it as isFoldableUnpackPack.

nit: sorry for having unclear comment in the first place, can you help update the comment since you're touching the code? I can help with it if needed.

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


More information about the Mlir-commits mailing list