[llvm] [InstCombine] Canonicalize `gep T, (gep i8, base, C1), (Index +nsw C2)` into `gep T, (gep i8, base, C1 + C2 * sizeof(T)), Index` (PR #76177)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 21 12:21:59 PST 2023


https://github.com/nikic commented:

> Note: I found that gep T, base, (Index +nsw C) will be expanded into gep T, (gep T, ptr, Index), C. Thus we can canonicalize the GEP of GEP by moving the constant-indexed GEP to the front/[back](https://reviews.llvm.org/D138950). But in these regressions, the add inst is likely to be used by multiple users. So I think it is worth handling this pattern.

I think we should first make sure that the GEP of GEP representation folds, before implementing this for the less-canonical GEP of add representation.

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


More information about the llvm-commits mailing list