[Mlir-commits] [mlir] [mlir][quant] Print actual quant storage type when signed (PR #187300)
German Gambon
llvmlistbot at llvm.org
Fri Apr 10 02:03:50 PDT 2026
================
----------------
ggambon wrote:
>From here https://github.com/ggambon/llvm-project/blob/77b74dd667dd83d3fd812a2dcd15d657a5cad2b9/mlir/include/mlir/IR/BuiltinTypes.td#L609
* `si` is signed
* `ui` is unsigned
* `i` is signless
* `u` not mentioned
`u` in a quant type is parsed in branch https://github.com/ggambon/llvm-project/blob/77b74dd667dd83d3fd812a2dcd15d657a5cad2b9/mlir/lib/Dialect/Quant/IR/TypeParser.cpp#L43, so stays signless since `parser.getBuilder().getIntegerType(storageTypeWidth);` returns a signless type. `u` looks like syntactic sugar for an unsigned signless type.
The other branch of the function correctly parses the other types and keeps their signedness.
However in the printer https://github.com/ggambon/llvm-project/blob/77b74dd667dd83d3fd812a2dcd15d657a5cad2b9/mlir/lib/Dialect/Quant/IR/TypeParser.cpp#L501 which translates to `QuantStorageTypeInterface::getStorageTypeName`, only `i`/`u` types are dumped, which are always signless. Non-signless types are ignored before the fix. This breaks round trips.
Clearly the duplication of sign semantics in the quant type flags and in the underlying type is very confusing, but something is needed to distinguish between those four possible representations.
https://github.com/llvm/llvm-project/pull/187300
More information about the Mlir-commits
mailing list