[llvm] [InstCombine] Fold pointer adding in integer to arithmetic add (PR #91596)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 20:38:54 PDT 2024


================
@@ -2073,6 +2073,20 @@ Instruction *InstCombinerImpl::visitPtrToInt(PtrToIntInst &CI) {
     return InsertElementInst::Create(Vec, NewCast, Index);
   }
 
+  // (ptrtoint (gep (inttoptr Base), Offset)) -> Base + Offset
+  Value *Base, *Offset, *GEP;
+  if (match(SrcOp, m_OneUse(m_Value(GEP))) &&
----------------
nikic wrote:

Add the `m_OneUse()` to the match below instead.

https://github.com/llvm/llvm-project/pull/91596


More information about the llvm-commits mailing list