[PATCH] D125070: [InstCombine] Simplify chain of GEP with constant indices
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 02:02:23 PDT 2022
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.
This is a good idea, but I think the implementation approach here is too complicated and fragile. This can be handled as a combination of two transforms that are both simpler and more general:
1. Reassociate constant GEPs, either by transforming `gep (gep %p, C), %x` to `gep (gep %p, %x), C`, or the other way around. This kind of reassociation is generally useful as a canonicalization even if nothing folds for redundancy elimination reasons. (It would also be possibly to reassociate in the other direction, but I think for GEPs we prefer this one, as constant offset addressing modes are pretty much universally supported.)
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.
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