[PATCH] D11687: Make cost estimation in RewriteLoopExitValues smarter
Igor Laevsky
igor at azulsystems.com
Fri Jul 31 11:50:20 PDT 2015
igor-laevsky created this revision.
igor-laevsky added reviewers: sanjoy, atrick, hfinkel.
igor-laevsky added a subscriber: llvm-commits.
In the recent change (http://reviews.llvm.org/D10782) Sanjoy updated cost estimation for the RewriteLoopExitValues to consider complicated SCEV expressions as cheap if there already exists llvm-ir expression which computes same value.
However if such expression is wrapped in a several other expressions we will still consider it as high cost.
For example this is considered high cost:
```
{-2,+,1} + (zext (<expr>)), where <expr> is high cost expression already defined in the IR.
```
In this change I updated cost estimation to evaluate such nested expressions as cheap. Turns out it is fairly important on one of our benchmarks (~20% performance).
In order to do that I have added new method "TryToGetValueForSCEVAt" into SCEVExpander, which tries to look for pre-existing llvm ir value. This method is used inside "ExpandSCEVIfNeeded" and inside "isHighCostExpansionHelper"
It would be natural to add "InsertedExpressions" lookup into this method, but I am not sure if there is really need for this. Also it is possible to use this method during "SCEVExpander::expand", but I am worried about having to much impact on the unrelated areas with no good reason.
http://reviews.llvm.org/D11687
Files:
include/llvm/Analysis/ScalarEvolutionExpander.h
lib/Analysis/ScalarEvolutionExpander.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11687.31146.patch
Type: text/x-patch
Size: 7804 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150731/b05f3217/attachment.bin>
More information about the llvm-commits
mailing list