[Mlir-commits] [mlir] [mlir][Interfaces] Track and infer no-overflow flags in integer ranges (PR #191777)

Hocky Yudhiono llvmlistbot at llvm.org
Wed Apr 15 03:12:36 PDT 2026


================
@@ -3356,10 +3356,11 @@ def TestReflectBoundsOp : TEST_Op<"reflect_bounds",
                        OptionalAttr<APIntAttr>:$umin,
                        OptionalAttr<APIntAttr>:$umax,
                        OptionalAttr<APIntAttr>:$smin,
-                       OptionalAttr<APIntAttr>:$smax);
+                       OptionalAttr<APIntAttr>:$smax,
+                       OptionalAttr<UI32Attr>:$overflow);
   let results = (outs InferIntRangeType:$result);
 
-  let assemblyFormat = "attr-dict $value `:` type($result)";
+  let hasCustomAssemblyFormat = 1;
----------------
hockyy wrote:

> Aren't changing them anyway right now? Whether the flag is at the beginning or the end, the line changes...

Yes, after looking at it, it's unavoidable.

> OK, but that's not answering why you need a custom parser instead of doing this in the assembly format?

The overflow attributes in testDefOps was in UI32Attr. I don't know how to represent it in a readable way, because it would appear as {overflow : 3 ...} to represent `nsw, nuw`. So I write a custom printer, and thus to parse it, I wrote the custom parser.

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


More information about the Mlir-commits mailing list