[PATCH] D125070: [InstCombine] Simplify chain of GEP with constant indices
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 01:31:32 PDT 2022
nikic added a comment.
In D125070#3505105 <https://reviews.llvm.org/D125070#3505105>, @huangjd wrote:
> @nikic
>
>> 2. Combine constant GEPs. We already do this, but sometimes fail based on element type mismatch. This can be fixed either by canonicalizing all constant GEPs to `i8` (probably better) or by doing so only when it allows combining GEPs that otherwise couldn't be combined.
>
> Where are the tests located for combining constant GEP? I think currently it only work with one direction (merging the second one into the first), so I will need to make it work both ways.
There are some tests starting here:; https://github.com/llvm/llvm-project/blob/34b6f206cbab8471abf29739dab981bd8b868a65/llvm/test/Transforms/InstCombine/opaque-ptr.ll#L172 The code for this is in https://github.com/llvm/llvm-project/blob/34b6f206cbab8471abf29739dab981bd8b868a65/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L2025.
Though as already mentioned, the most general fix for this is to canonicalize all constant GEPs to use `i8` element type, which ensures that two constant GEPs can always be combined.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125070/new/
https://reviews.llvm.org/D125070
More information about the llvm-commits
mailing list