[llvm] [ConstantFolding] Support ptrtoaddr in cast folds (PR #162480)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 11:45:56 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),
----------------
arichardson wrote:
I am not sure these folds are valid for unstable GC pointers, but since this has been like this for a long time and I have no detailed knowledge of GC pointer support I imagine it's fine.
https://github.com/llvm/llvm-project/pull/162480
More information about the llvm-commits
mailing list