[PATCH] D73722: [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model plain UDiv

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 09:39:24 PST 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: reames, mkazantsev, wmi, sanjoy.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.
lebedev.ri added a parent revision: D73718: [SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model UDiv by power-of-two as LShr.

If we don't believe this UDiv is actually a LShr in disguise, things are much worse.
First, we try to see if this UDiv actually originates from user code,
by looking for `S + 1`, and if found considering this UDiv to be free.
But otherwise, we always considered this UDiv to be high-cost.

However that is no longer the case with TTI-driven cost model:
our default budget is 4, which matches the default cost of UDiv,
so now we allow a single UDiv to not be counted as high-cost.

While that is the case, it is evident this is actually a regression
due to the fact that cost-modelling is incomplete - we did not account
for the `add`, `mul` costs yet.

Cost-modelling for UDiv also seems pretty straight-forward:
subtract cost of the UDiv itself, and recurse into both the LHS and RHS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73722

Files:
  llvm/lib/Analysis/ScalarEvolutionExpander.cpp
  llvm/test/Transforms/IndVarSimplify/exit_value_test2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73722.241489.patch
Type: text/x-patch
Size: 7215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200130/890a3b87/attachment.bin>


More information about the llvm-commits mailing list