[PATCH] D149132: [LICM] Reassociate & hoist add expressions

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 00:56:48 PDT 2023


mkazantsev created this revision.
mkazantsev added reviewers: anna, nikic, lebedev.ri, skatkov, danilaml, aleksandr.popov.
Herald added subscribers: StephenFan, asbirlea, hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch allows LICM to reassociate and hoist following expressions:

  loop:
    %sum = add nsw %iv, %C1
    %cmp = icmp <signed pred> %sum, C2

where `C1` and `C2` are loop invariants. The reassociated version looks like

  preheader:
    %inv_sum = C2 - C1
  ...
  loop:
    %cmp = icmp <signed pred> %iv, %inv_sum

In order to prove legality, we need both initial addition and the newly created subtraction
to happen without overflow.


https://reviews.llvm.org/D149132

Files:
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/test/Transforms/LICM/hoist-add-sub.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149132.516692.patch
Type: text/x-patch
Size: 6822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230425/8f0b8365/attachment.bin>


More information about the llvm-commits mailing list