[llvm] [ConstantFolding] Support ptrtoaddr in ConstantFoldCompareInstOperands (PR #162653)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 9 09:46:45 PDT 2025
================
@@ -1225,7 +1225,8 @@ Constant *llvm::ConstantFoldCompareInstOperands(
// Only do this transformation if the int is intptrty in size, otherwise
// there is a truncation or extension that we aren't modeling.
- if (CE0->getOpcode() == Instruction::PtrToInt) {
+ if (CE0->getOpcode() == Instruction::PtrToInt ||
+ CE0->getOpcode() == Instruction::PtrToAddr) {
Type *IntPtrTy = DL.getIntPtrType(CE0->getOperand(0)->getType());
----------------
arichardson wrote:
Since we seem to be aligned on using address width only for `icmp ptr`, I believe all of these DL.getIntPtrType() should be DL.getAddressType()? This change probably won't be caught by existing tests since we won't have many for index size != pointer size.
https://github.com/llvm/llvm-project/pull/162653
More information about the llvm-commits
mailing list