================
@@ -1592,6 +1592,13 @@ Constant *llvm::ConstantFoldCastOperand(unsigned Opcode,
Constant *C,
: DestTy->getPointerAddressSpace();
if (DL.isNullPointerAllZeroes(AS))
return Constant::getNullValue(DestTy, &DL);
+ // Non-zero null: ptrtoint(ConstantPointerNull) folds to the actual
+ // null integer value for this address space.
+ if (isa<ConstantPointerNull>(C)) {
+ const APInt &NullVal = DL.getNullPtrValue(AS);
+ return ConstantInt::get(
+ DestTy, NullVal.zextOrTrunc(DestTy->getIntegerBitWidth()));
----------------
arsenm wrote:
Why zext or trunc? I'd expect a -1 pointer to be sign extended to -1
https://github.com/llvm/llvm-project/pull/183215
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits