[llvm] [SeparateConstOffsetFromGEP] propagate const offset through GEP chains (PR #143470)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 09:53:00 PDT 2025


AlexMaclean wrote:

> This looks plausible, but I also feel like this is something we should be doing in InstCombine? (That is, trying to combine multiple constant offset GEPs into one, even if there are intermediate GEPs, as long as use-constraints allow.)

As things are currently divided I think it makes a lot of sense to keep this logic here. This pass isn't run by most targets and it's behavior is very dependent on TTI.isLegalAddressingMode. Since we assume that the constant offsets we're generating will be used in the addressing of some memory instruction we're also less concerned about use constrains then we would be in InstCombine. While I agree there are likely some limited ways to do similar transformations in IC, here I think its safe to be a bit more aggressive and rely on target-specific information.   

https://github.com/llvm/llvm-project/pull/143470


More information about the llvm-commits mailing list