diff options
author | Magnus Lång <[email protected]> | 2016-09-01 20:10:12 +0200 |
---|---|---|
committer | Magnus Lång <[email protected]> | 2016-09-05 15:02:03 +0200 |
commit | 69e338f4a85f47ad2d8c1b63adb761006dc4a979 (patch) | |
tree | 2dcb2152fa3257e3fe37b9090ecfdd85d02f86fb | |
parent | 904caa71a3754e3ee7f681cc7d4106d4a9979f1f (diff) | |
download | otp-69e338f4a85f47ad2d8c1b63adb761006dc4a979.tar.gz otp-69e338f4a85f47ad2d8c1b63adb761006dc4a979.tar.bz2 otp-69e338f4a85f47ad2d8c1b63adb761006dc4a979.zip |
hipe_regalloc_prepass: Change splitting heuristic
The division into an initial pass that may introduce temps, and
following passes that must not forces us to make the same heuristic
decision during each of these passes. Thus, the splitting heuristic
can't be based on the number of temporaries -- at least without
excluding temporaries above SpillLimit.
-rw-r--r-- | lib/hipe/regalloc/hipe_regalloc_prepass.erl | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/hipe/regalloc/hipe_regalloc_prepass.erl b/lib/hipe/regalloc/hipe_regalloc_prepass.erl index 5a52e5ad51..c2531bc451 100644 --- a/lib/hipe/regalloc/hipe_regalloc_prepass.erl +++ b/lib/hipe/regalloc/hipe_regalloc_prepass.erl @@ -60,8 +60,8 @@ -define(TUNE_TOO_FEW_BBS, 256). %% Ignore the ra_partitioned option (and do whole function RA instead) when -%% there are fewer than ?TUNE_MIN_SPLIT_PSEUDOS non-spilled used pseudos. --define(TUNE_MIN_SPLIT_PSEUDOS, 1024). +%% there are fewer than ?TUNE_MIN_SPLIT_BBS basic blocks. +-define(TUNE_MIN_SPLIT_BBS, 384). %% We present a "pseudo-target" to the register allocator we wrap. %% Note: all arities are +1 as we're currently using the parameterised module @@ -145,7 +145,12 @@ regalloc(RegAllocMod, CFG, SpillIndex0, SpillLimit, Target, Options) -> Liveness), {Coloring, SpillIndex, Liveness}. -%% regalloc_initial/6 is allowed to introduce new temporaries, unlike regalloc/6 +%% regalloc_initial/6 is allowed to introduce new temporaries, unlike +%% regalloc/6. +%% In order for regalloc/6 to never introduce temporaries, regalloc/6 must never +%% choose to do split allocation unless regalloc_initial/6 does. This is the +%% reason that the splitting heuristic is solely based on the number of basic +%% blocks, which does not change during the register allocation loop. -spec regalloc_initial(module(), target_cfg(), spillno(), spillno(), module(), proplists:proplist()) -> {hipe_map(), spillno(), target_cfg(), @@ -169,12 +174,11 @@ regalloc_1(RegAllocMod, CFG0, SpillIndex0, SpillLimit, Target, Options, {ScanBBs, Seen, SpillMap, SpillIndex1} = scan_cfg(CFG0, Liveness, SpillIndex0, Target), - AllPrecoloured = Target:all_precoloured(), - {PartColoring, SpillIndex, NewCFG} = - case proplists:get_bool(ra_partitioned, Options) of - true when map_size(Seen) - map_size(SpillMap) - length(AllPrecoloured) - > ?TUNE_MIN_SPLIT_PSEUDOS -> + case proplists:get_bool(ra_partitioned, Options) + andalso length(Target:labels(CFG0)) > ?TUNE_MIN_SPLIT_BBS + of + true -> regalloc_partitioned(SpillMap, SpillIndex1, SpillLimit, ScanBBs, CFG0, Target, RegAllocMod, Options); _ -> @@ -186,6 +190,7 @@ regalloc_1(RegAllocMod, CFG0, SpillIndex0, SpillLimit, Target, Options, Coloring = SpillColors ++ PartColoring, ?ASSERT(begin + AllPrecoloured = Target:all_precoloured(), MaxPhys = lists:max(AllPrecoloured) + 1, Unused = unused(live_pseudos(Seen, SpillMap, MaxPhys), SpillMap, CFG0, Target), |