From d394dd3c36bf2a37327476484adbb328c207a214 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 28 Jul 2009 08:48:05 -0500 Subject: [PATCH] compiler.cfg.branch-splitting: re-enable with a better heuristic --- .../branch-splitting/branch-splitting.factor | 26 ++++++++++++++++--- basis/compiler/cfg/optimizer/optimizer.factor | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/basis/compiler/cfg/branch-splitting/branch-splitting.factor b/basis/compiler/cfg/branch-splitting/branch-splitting.factor index 89e3604aec..8618932e14 100644 --- a/basis/compiler/cfg/branch-splitting/branch-splitting.factor +++ b/basis/compiler/cfg/branch-splitting/branch-splitting.factor @@ -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 diff --git a/basis/compiler/cfg/optimizer/optimizer.factor b/basis/compiler/cfg/optimizer/optimizer.factor index cbccf42c34..b411c42a35 100644 --- a/basis/compiler/cfg/optimizer/optimizer.factor +++ b/basis/compiler/cfg/optimizer/optimizer.factor @@ -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