[PATCH] D143641: [MemorySSA] Iteratively check if gep's pointer operand is a guaranteed loop invariant

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 15 18:19:12 PST 2023


StephenFan added a comment.

In D143641#4125313 <https://reviews.llvm.org/D143641#4125313>, @nikic wrote:

> I'm curious where this came up in practice. Constant GEP based on constant GEP gets merged by InstCombine.

TBH, The test was constructed by hand. So it may not make sense in practice since as you said it always gets merged by InstCombine. But that reminds me if it makes sense to also check whether the index operands are invariant?

> FWIW, we have a stripInBoundsConstantOffsets() method, which does //nearly// what we want here. I wonder whether it would make sense to add a new PointerStripKind for this? (I think some existing users of stripInBoundsConstantOffsets don't actually need the "inbounds" part and just end up using it because it's convenient.)

I think it makes sense. If I use the stripInBoundsConstantOffsets() here, I will not care about the inbounds flag.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143641/new/

https://reviews.llvm.org/D143641



More information about the llvm-commits mailing list