[llvm] [ConstantFolding] Support ptrtoaddr in cast folds (PR #162480)
Hongyu Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 08:50:44 PDT 2025
================
@@ -1528,7 +1528,8 @@ Constant *llvm::ConstantFoldCastOperand(unsigned Opcode, Constant *C,
Sub->getOpcode() == Instruction::Sub &&
Sub->getOperand(0)->isNullValue())
FoldedValue = ConstantExpr::getSub(
- ConstantExpr::getPtrToInt(Ptr, IntIdxTy), Sub->getOperand(1));
+ ConstantExpr::getCast(Opcode, Ptr, IntIdxTy),
+ Sub->getOperand(1));
}
}
}
----------------
XChy wrote:
The comment below:
> // Do a zext or trunc to get to the ptrtoint dest size.
->
> // Do a zext or trunc to get to the ptrtoint/ptrtoaddr dest size.
https://github.com/llvm/llvm-project/pull/162480
More information about the llvm-commits
mailing list