[PATCH] RegAlloc: Account for a variable entry block frequency
Manman Ren
manman.ren at gmail.com
Mon Apr 7 17:47:36 PDT 2014
unsigned calculateRegionSplitCost(LiveInterval &VirtReg,
AllocationOrder &Order,
- BlockFrequency &BestCost,
+ const BlockFrequency &AlternateCost,
unsigned RAGreedy::calculateRegionSplitCost(LiveInterval &VirtReg,
AllocationOrder &Order,
- BlockFrequency &BestCost,
+ const BlockFrequency
&AlternateCost,
unsigned &NumCands,
bool IgnoreCSR) {
+ BlockFrequency BestCost = AlternateCost;
--> The above should be separated (is there a reason for these changes?)
+ uint64_t FixedEntry = 1 << 14;
+ if (ActualEntry < FixedEntry)
+ CSRCost *= BranchProbability(ActualEntry, FixedEntry);
+ else if (ActualEntry <= FixedEntry * 16)
+ // Invert the fraction and divide.
+ CSRCost /= BranchProbability(FixedEntry, ActualEntry);
+ else
+ // Can't use BranchProbability in general, since it takes 32-bit
numbers.
+ // This path is faster anyway, albeit less precise.
+ CSRCost = CSRCost.getFrequency() * (ActualEntry >> 14);
--> Are we trying to be precise when possible with this if statement? Why a
fixed 16 in the 2nd condition?
Thanks,
Manman
On Mon, Apr 7, 2014 at 11:25 AM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:
> Until r197284, the entry frequency was constant -- i.e., set to 2^14.
> Although current ToT still has a constant entry frequency, since r197284
> that has been an implementation detail (which is soon going to change).
>
> - r204690 made the wrong assumption for the CSRCost metric. Adjust
> callee-saved register cost based on entry frequency.
>
> - r185393 made the wrong assumption (although it was valid at the
> time). Update SpillPlacement.cpp::Threshold to be relative to the
> entry frequency.
>
> Since ToT still has 2^14 entry frequency, this should have no observable
> functionality change.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140407/38a7586a/attachment.html>
More information about the llvm-commits
mailing list