compiler.cfg.branch-splitting: re-enable with a better heuristic

db4
Slava Pestov 2009-07-28 08:48:05 -05:00
parent ff81b055a5
commit d394dd3c36
2 changed files with 23 additions and 5 deletions

View File

@ -54,13 +54,31 @@ UNION: irrelevant ##peek ##replace ##inc-d ##inc-r ;
: split-instructions? ( insns -- ? ) [ irrelevant? not ] count 5 <= ;
: split-branch? ( bb -- ? )
: short-tail-block? ( bb -- ? )
[ successors>> empty? ] [ instructions>> length 2 = ] bi and ;
: short-block? ( bb -- ? )
! If block is empty, always split
[ predecessors>> length ] [ instructions>> length 1 - ] bi * 10 <= ;
: cond-cond-block? ( bb -- ? )
{
[ dup successors>> [ back-edge? ] with any? not ]
[ predecessors>> length 2 4 between? ]
[ instructions>> split-instructions? ]
[ predecessors>> length 2 = ]
[ successors>> length 2 = ]
[ instructions>> length 20 <= ]
} 1&& ;
: split-branch? ( bb -- ? )
dup loop-entry? [ drop f ] [
dup predecessors>> length 1 <= [ drop f ] [
{
[ short-block? ]
[ short-tail-block? ]
[ cond-cond-block? ]
} 1||
] if
] if ;
: split-branches ( cfg -- cfg' )
dup [
dup split-branch? [ split-branch ] [ drop ] if

View File

@ -32,7 +32,7 @@ SYMBOL: check-optimizer?
optimize-tail-calls
delete-useless-conditionals
compute-predecessors
! split-branches
split-branches
join-blocks
compute-predecessors
construct-ssa