[PATCH] D127726: [SimplifyCFG] Don't sink common code if PHI node with some GEPs is created

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 4 02:26:40 PDT 2022


nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

I don't think this hack is acceptable. The actual problem here seems to be that the `phi (gep(p, c1), gep(p, c2))` doesn't get converted into `gep p, phi(c1, c2)` afterwards, which is what would give you the best of both worlds: The store is sunk, but we still make use of the common base.

The reason why this doesn't happen is once again our dumb structural GEP representation. In this case, the difference is in a struct index, and struct indices cannot be variable, so we can't have a gep of phi over a struct index. If this weren't a struct GEP, then everything would fold as expected.

The probably easiest way to fix this is to canonicalize constant GEPs to byte GEPs in InstCombine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127726



More information about the llvm-commits mailing list