]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/critical-edges/critical-edges.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / compiler / cfg / critical-edges / critical-edges.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math accessors sequences
4 compiler.cfg compiler.cfg.rpo compiler.cfg.utilities ;
5 IN: compiler.cfg.critical-edges
6
7 : critical-edge? ( from to -- ? )
8     [ successors>> length 1 > ] [ predecessors>> length 1 > ] bi* and ;
9
10 : split-critical-edge ( from to -- )
11     f <simple-block> insert-basic-block ;
12
13 : split-critical-edges ( cfg -- )
14     dup [
15         dup successors>> [
16             2dup critical-edge?
17             [ split-critical-edge ] [ 2drop ] if
18         ] with each
19     ] each-basic-block
20     cfg-changed
21     drop ;