[PATCH] D146813: [LICM] Reassociate GEPs to allow hoisting

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 07:47:43 PDT 2023


nikic created this revision.
nikic added reviewers: mkazantsev, fhahn, reames, asbirlea.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Reassociate `gep (gep ptr, idx1), idx2` to `gep (gep ptr, idx2), idx1` if this would make the inner GEP loop invariant and thus hoistable.

This is intended to replace an InstCombine fold that does this (in https://github.com/llvm/llvm-project/blob/04f61fb73dc6a994ab267d431f2fdaedc67430ff/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L2006). The problem with the InstCombine fold is that LoopInfo is an optional dependency, so it is not performed reliably.


https://reviews.llvm.org/D146813

Files:
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/test/Transforms/LICM/gep-reassociate.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146813.508087.patch
Type: text/x-patch
Size: 8824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230324/4edd54af/attachment.bin>


More information about the llvm-commits mailing list