[PATCH] D53405: [Inliner] Attempt to more accurately model the cost of loops at minsize

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 18 10:35:08 PDT 2018


dmgreen created this revision.
dmgreen added reviewers: efriedma, chandlerc, zzheng, fhahn, eraman.
Herald added a reviewer: javed.absar.
Herald added subscribers: haicheng, kristof.beyls.

This is three separate things, which when applied together come to much the same effect as https://reviews.llvm.org/D52716.  They are:

- Reduce the call penalty at minsize to 15. In my testing on Arm and X86, this seemed to be the best spot for reducing codesize. It is still not 0 because of inaccuracies in the inliner cost modelling, but over time can be gradually decreased as things gets better. (I did not change the Threshold as it seemed sensible to also decrease the cost of sub-calls at minsize).
- If a block has more than one unconditional predecessor, mark each one past the first as non-free. This models the extra branch costs for loops (but can cause problems for cases where the blocks are not in the form they will appear in assembly).
- Geps that are used by phis are not free. This is attempting to capture the geps in loop IVs. (I'm not sure if there is a better way to capture that.)

All together they make us much less likely to inline small loops at minsize. The patch is https://reviews.llvm.org/D52716 is still better for total codesize in my testing, but this attempts to model things more precisely.


https://reviews.llvm.org/D53405

Files:
  include/llvm/Analysis/InlineCost.h
  lib/Analysis/InlineCost.cpp
  lib/Transforms/IPO/PartialInlining.cpp
  test/Transforms/Inline/AArch64/phi.ll
  test/Transforms/Inline/ARM/loop-add.ll
  test/Transforms/Inline/ARM/loop-memcpy.ll
  test/Transforms/Inline/ARM/loop-noinline.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53405.170102.patch
Type: text/x-patch
Size: 17251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181018/08217e86/attachment.bin>


More information about the llvm-commits mailing list