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

Nikita Popov llvmlistbot at llvm.org
Mon Oct 7 07:42:18 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:

Yes, places marked with TODO *probably* shouldn't be using implicitTrunc. Here are the failures if we drop it: https://gist.github.com/nikic/d69e30cf1d28ef5988363dc11e203159

I'm guessing the main problem is https://github.com/llvm/llvm-project/blob/0e8555d4dbfdfeddc01dc2ecf9a9b6e804f7b645/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp#L120 trying to construct -1 of either an unsigned or signless integer type.



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


More information about the Mlir-commits mailing list