[PATCH] D156702: Add support for GEP of GEP instruction combining when types do not exactly match

Simeon Krastnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 08:38:02 PDT 2023


simeon created this revision.
simeon added a reviewer: nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
simeon requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

InstCombine can combine a GEP of a GEP into a single one if the type of the source pointer matches the source element type of the outer pointer. However, in certain cases the source pointer may have had one or more of its indices folded (as `CreateGEP` calls `FoldGEP`) and thus have a different resulting type than the source element type, leading to a missed optimization. This patch attempts to handle this case by "unfolding" the source GEP by incrementally appending zero indices until its type matches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156702

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/gepgep-after-fold.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156702.545671.patch
Type: text/x-patch
Size: 4936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230731/fc6f6f57/attachment.bin>


More information about the llvm-commits mailing list