[llvm] [InstComb] Try to convert inttoptr (add (ptrtoint %B), %O) to GEP. (PR #153421)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 13 13:36:24 PDT 2025
================
@@ -2073,6 +2073,22 @@ Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {
return new IntToPtrInst(P, CI.getType());
}
+ // Replace (inttoptr (add (ptrtoint %Base), %Offset)) with
+ //(getelementptr i8, %Base, %Offset) if all users are ICmps.
+ Value *Base;
+ Value *Offset;
+ if (match(CI.getOperand(0),
+ m_Add(m_PtrToInt(m_Value(Base)), m_Value(Offset))) &&
----------------
fhahn wrote:
Updated to use `m_PtrToIntSameSize` and removed the size check below, thanks!
https://github.com/llvm/llvm-project/pull/153421
More information about the llvm-commits
mailing list