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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 20 04:31:22 PDT 2021


lebedev.ri added a comment.

In D106352#2890021 <https://reviews.llvm.org/D106352#2890021>, @lebedev.ri wrote:

> I feel like `gep (gep Ptr, Idx0), Idx1  --> gep Ptr, Idx0+Idx1` is obviously a standalone fold that should be elsewhere in instcombine.

... and while we clearly don't have that fold (https://godbolt.org/z/56asoz3ch),
i realize it wouldn't help here, since `%gep1` has extra use in `select`.



================
Comment at: llvm/test/Transforms/InstCombine/select-gep.ll:132
   ret i32* %sel
 }
 
----------------
Please add test where `%gep1` has other uses (e.g. `call void @use(i32* %gep1)`)


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