[Mlir-commits] [mlir] [mlir][Linalg] Preserve discardable/user-defined attributes during generalization (PR #178599)

Mehdi Amini llvmlistbot at llvm.org
Thu Jan 29 05:20:46 PST 2026


================
@@ -64,6 +64,14 @@ FailureOr<GenericOp> mlir::linalg::generalizeNamedOp(RewriterBase &rewriter,
                         outputs, indexingMaps, iterators);
   rewriter.inlineRegionBefore(linalgOp->getRegion(0), genericOp.getRegion(),
                               genericOp.getRegion().begin());
+
+  // Discardable attributes carry user-defined metadata (e.g., annotations for
+  // downstream passes). Generalization is a semantics-preserving
+  // transformation, so dropping this metadata would be unexpected. This is safe
+  // because discardable attributes are by definition independent of op
+  // semantics.
----------------
joker-eph wrote:

> Generalization is a semantics-preserving transformation, so dropping this metadata would be unexpected.

Almost all transformations are semantics preserving, including lowering down to LLVM.

> This is safe because discardable attributes are by definition independent of op semantics.

I'm not sure what you mean here: discardable attributes can be used by some to add semantic information to operation, for example to indicate that two memrefs operands won't alias. A transformation that would add (or remove) operands for example could lead to incorrect annotations.

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


More information about the Mlir-commits mailing list