[clang] [llvm] [InstCombine] Strip leading zero indices from GEP (PR #155415)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 28 06:15:31 PDT 2025


nikic wrote:

> > The main issue I saw is that we now sometimes fail to eliminate null checks of the form `gep inbounds (p, x-1) == null`, which are converted to `gep (gep p, x), -1` now, losing flags.
> 
> I checked whether we can mitigate this by folding null checks before doing this transform, but at least in the one case I looked at, the null check only gets inlined after this fold has already happened.

I also checked whether not going this transform for constant negative offsets might make sense, but it turns out that it's pretty widely beneficial even in that case.

So I don't think there's anything we can really do about those regressions.

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


More information about the cfe-commits mailing list