[llvm] [Value] Look through inttoptr (add ..) in accumulateConstantOffsets (PR #124981)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 05:03:19 PST 2025
================
@@ -775,6 +775,25 @@ const Value *Value::stripAndAccumulateConstantOffsets(
V = RV;
if (AllowInvariantGroup && Call->isLaunderOrStripInvariantGroup())
V = Call->getArgOperand(0);
+ } else if (auto *Int2Ptr = dyn_cast<Operator>(V)) {
+ // Try to accumulate across (inttoptr (add (ptrtoint p), off)).
+ if (!Int2Ptr || Int2Ptr->getOpcode() != Instruction::IntToPtr ||
+ Int2Ptr->getOperand(0)->getType()->getScalarSizeInBits() != BitWidth)
+ return V;
+ auto *Add = dyn_cast<AddOperator>(Int2Ptr->getOperand(0));
+ if (!AllowNonInbounds || !Add)
----------------
fhahn wrote:
Done, thanks
https://github.com/llvm/llvm-project/pull/124981
More information about the llvm-commits
mailing list