================
@@ -588,10 +588,17 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
   }
   // For integer types, we allow a mismatch in sizes as the index type in
   // MLIR might have a different size than the index type in the LLVM module.
-  if (auto intAttr = dyn_cast<IntegerAttr>(attr))
-    return llvm::ConstantInt::get(
-        llvmType,
-        intAttr.getValue().sextOrTrunc(llvmType->getIntegerBitWidth()));
+  if (auto intAttr = dyn_cast<IntegerAttr>(attr)) {
+    // If the attribute is an unsigned integer or a 1-bit integer, zero-extend
+    // the value to the bit width of the LLVM type. Otherwise, sign-extend.
+    auto intTy = mlir::dyn_cast<IntegerType>(intAttr.getType());
----------------
andykaylor wrote:

I had this as a `cast` originally, and it does fail sometimes. This can also be 
`IndexType`, I think.

https://github.com/llvm/llvm-project/pull/169751
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [clang] [... Andy Kaylor via cfe-commits
    • [cla... via cfe-commits
    • [cla... via cfe-commits
    • [cla... via cfe-commits
    • [cla... Andy Kaylor via cfe-commits
    • [cla... Andy Kaylor via cfe-commits
    • [cla... Valentin Clement バレンタイン クレメン via cfe-commits
    • [cla... Andy Kaylor via cfe-commits
    • [cla... Andy Kaylor via cfe-commits
    • [cla... Andy Kaylor via cfe-commits

Reply via email to