[PATCH] D106352: [InstCombine] Fold (select C, (gep (gep Ptr, Idx0), Idx1), (gep Ptr, Idx0)) -> (gep Ptr, (select C, Idx0+Idx1, Idx0)) (PR51069)

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 20 10:24:49 PDT 2021


reames added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/select-gep.ll:111-112
 ;
   %gep1 = getelementptr inbounds i32, i32* %p, i64 %x
   %gep2 = getelementptr inbounds i32, i32* %gep1, i64 6
   %icmp = icmp ugt i64 %x, %y
----------------
lebedev.ri wrote:
> @reames if we look at this test, clearly we can't fold `%gep2` into `%p + (%x + 6)`,
> because that results in two instructions, but `%gep1` sticks around since it's used in `select`,
> so we can't actually do this in instcombine.
Roman, I think you're looking at the wrong IR.  The interesting IR is the result of running the current transforms, not the input to exercise the current transform.  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106352/new/

https://reviews.llvm.org/D106352



More information about the llvm-commits mailing list