[PATCH] D111806: [LICM] Check the number of divergent paths from loop header to target block

JinGu Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 14 07:14:06 PDT 2021


jaykang10 created this revision.
jaykang10 added reviewers: nikic, efriedma, reames, mkazantsev.
Herald added subscribers: asbirlea, hiraditya, kristof.beyls.
jaykang10 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If the control flow is divergent too much inside loop, it could be better to avoid to move instructions outside loop.

For example, let's say there is a switch instruction with big number of cases inside loop and the instruction is located in one of the case block. In this case, it is not easy to say the instruction is executed.

This patch checks the number of divergent paths from loop header to block which has the instruction. If the number of divergent paths is bigger than threshold, LICM pass does not move the instruction.

The performance improvement from spec2017 for AArch64 is as below.

  Benchmark	improvement(%)
  500.perlbench_r	2.176103248
  502.gcc_r	-0.271585852
  505.mcf_r	0.511525241
  520.omnetpp_r	-0.008166838
  523.xalancbmk_r	0.488642971
  525.x264_r	-0.049168496
  531.deepsjeng_r	0.021372649
  541.leela_r	-0.023171636
  557.xz_r	-0.012851939


https://reviews.llvm.org/D111806

Files:
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/test/Transforms/LICM/divergent-path-in-loop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111806.379707.patch
Type: text/x-patch
Size: 37635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211014/32891f72/attachment.bin>


More information about the llvm-commits mailing list