[Mlir-commits] [mlir] [MLIR] Update APInt construction to correctly set isSigned/implicitTrunc (PR #110466)

Nikita Popov llvmlistbot at llvm.org
Mon Oct 7 08:01:48 PDT 2024


================
@@ -701,8 +701,10 @@ def Builtin_IntegerAttr : Builtin_Attr<"Integer", "integer",
         return $_get(type.getContext(), type, apValue);
       }
 
+      // TODO: Avoid implicit trunc?
       IntegerType intTy = ::llvm::cast<IntegerType>(type);
-      APInt apValue(intTy.getWidth(), value, intTy.isSignedInteger());
+      APInt apValue(intTy.getWidth(), value, intTy.isSignedInteger(),
+                    /*implicitTrunc=*/true);
----------------
nikic wrote:

> Or possibly the code here should be setting signed=true for signless integers, as parameter is int64_t so signed value should be the default assumption?

Tried that, and it causes other failures. Unsurprisingly, there seems to be a mix of assumptions on how to interpret a signless integer constant :)

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


More information about the Mlir-commits mailing list