[PATCH] D34583: [LSR] Narrow search space by filtering non-optimal formulae with the same ScaledReg and Scale.

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 17:02:02 PDT 2017


wmi created this revision.
Herald added subscribers: mzolotukhin, sanjoy, MatzeB.

When the formulae search space is huge, LSR uses a series of heuristic to keep pruning the search space until the number of possible solutions are within certain limit.

The big hammer of the series of heuristics is NarrowSearchSpaceByPickingWinnerRegs, which picks the register which is used by the most LSRUses and deletes the other formulae which don't use the register. This is a effective way to prune the search space, but quite often not a good way to keep the best solution. We saw cases before that the heuristic pruned the best formula candidate out of search space.

To relieve the problem, we introduce a new heuristic called NarrowSearchSpaceByFilterFormulaWithSameScaledReg. The basic idea is in order to reduce the search space while keeping the best formula, we want to keep as many formula with different Scale and ScaledReg as possible. That is because the central idea of LSR is to choose a group of loop induction variables and use those induction variables to represent LSRUses. An induction variable candidate is often represented by the Scale and ScaledReg in a formula. If we have more formulae with different ScaledReg and Scale to choose, we have better opportunity to find the best solution. That is why we believe pruning search space by only keeping the best formula with the same Scale and ScaledReg should be more effective than PickingWinnerReg. And we use two criteria to choose the best formula with the same Scale and ScaledReg. The first criteria is to select the formula using less non shared registers, and the second criteria is to select the formula with less cost got from RateFormula. The patch implements the heuristic before NarrowSearchSpaceByPickingWinnerRegs, which is the last resort.

Testing shows we get 1.8% and 2% on two internal benchmarks on x86. llvm nightly testsuite performance is neutral.  We also tried lsr-exp-narrow and it didn't help on the two improved internal cases we saw.


Repository:
  rL LLVM

https://reviews.llvm.org/D34583

Files:
  lib/Transforms/Scalar/LoopStrengthReduce.cpp
  test/CodeGen/X86/regalloc-reconcile-broken-hints.ll
  test/Transforms/LoopStrengthReduce/2013-01-14-ReuseCast.ll
  test/Transforms/LoopStrengthReduce/X86/lsr-filtering-scaledreg.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34583.103799.patch
Type: text/x-patch
Size: 16541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170624/6e267ac2/attachment.bin>


More information about the llvm-commits mailing list