[Mlir-commits] [mlir] 79fdef2 - [mlir][ods] Document and test DefaultValuedProp elision in prop-dict format (#189045)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Mar 27 09:31:17 PDT 2026


Author: Mehdi Amini
Date: 2026-03-27T16:31:09Z
New Revision: 79fdef22d628c926995082b1c052298f47aea283

URL: https://github.com/llvm/llvm-project/commit/79fdef22d628c926995082b1c052298f47aea283
DIFF: https://github.com/llvm/llvm-project/commit/79fdef22d628c926995082b1c052298f47aea283.diff

LOG: [mlir][ods] Document and test DefaultValuedProp elision in prop-dict format (#189045)

Issue #152743 reports that DefaultValuedProp is printed even when the
property value equals the default, unlike DefaultValuedAttr which is not
printed in that case.

The fix for this was already present in the codebase since commit
8955e285e1ac ("[mlir] Add property combinators, initial ODS support"),
which added elision of default-valued properties in the
genPropDictPrinter
function in OpFormatGen.cpp.

This commit adds:
- Documentation in Operations.md clarifying that DefaultValuedProp is
  also elided from prop-dict output when the value equals the default,
  consistent with the existing documentation for DefaultValuedAttr.
- An explicit test in properties.mlir verifying that DefaultValuedProp
  with value equal to default is elided from prop-dict output, and that
  DefaultValuedProp with a non-default value is still printed.

Fixes #152743

Assisted-by: Claude Code

Added: 
    

Modified: 
    mlir/docs/DefiningDialects/Operations.md
    mlir/test/IR/properties.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md
index 08fb08998437e..b64bffdf72ae3 100644
--- a/mlir/docs/DefiningDialects/Operations.md
+++ b/mlir/docs/DefiningDialects/Operations.md
@@ -349,6 +349,10 @@ for example, in the case of array properties (which are stored as `SmallVector`s
 but use `ArrayRef` as an interface type), add the storage-type equivalent
 of the default value as the third argument.
 
+When using the `prop-dict` directive in an assembly format, the generated
+operation printing function will not print default-valued properties when the
+property value is equal to the default.
+
 To declare an optional property, use `OptionalProp<...>`.
 This wraps the underlying property in an `std::optional` and gives it a
 default value of `std::nullopt`.

diff  --git a/mlir/test/IR/properties.mlir b/mlir/test/IR/properties.mlir
index b541447e85c7b..4dbb8ebfa5db3 100644
--- a/mlir/test/IR/properties.mlir
+++ b/mlir/test/IR/properties.mlir
@@ -97,3 +97,27 @@ test.with_optional_properties nested = some<none>
 // CHECK-SAME: ints = [1, 2] strings = ["a", "b"] nested = {{\[}}[1, 2], [3, 4]] opt = [-1, -2] explicitOptions = [none, 0] explicitUnits = [unit, unit_absent]
 // GENERIC: "test.with_array_properties"()
 test.with_array_properties ints = [1, 2] strings = ["a", "b"] nested = [[1, 2], [3, 4]] opt = [-1, -2] explicitOptions = [none, 0] explicitUnits = [unit, unit_absent] [] thats_has_default
+
+// Tests that DefaultValuedProp is elided from prop-dict when value equals default.
+// CHECK: test.op_with_property_predicates
+// CHECK-SAME: <{array = [], more_constrained = 1 : i64, non_empty_constrained = [1], non_empty_unconstrained = [1], scalar = 1 : i64, unconstrained = 0 : i64}>
+// CHECK-NOT: defaulted
+test.op_with_property_predicates <{
+  scalar = 1 : i64,
+  more_constrained = 1 : i64,
+  array = [],
+  non_empty_unconstrained = [1],
+  non_empty_constrained = [1],
+  unconstrained = 0 : i64}>
+
+// Tests that DefaultValuedProp is printed when value 
diff ers from default.
+// CHECK: test.op_with_property_predicates
+// CHECK-SAME: defaulted = 3
+test.op_with_property_predicates <{
+  scalar = 1 : i64,
+  defaulted = 3 : i64,
+  more_constrained = 1 : i64,
+  array = [],
+  non_empty_unconstrained = [1],
+  non_empty_constrained = [1],
+  unconstrained = 0 : i64}>


        


More information about the Mlir-commits mailing list