1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators.short-circuit compiler.cfg
4 compiler.cfg.instructions compiler.cfg.rpo
5 compiler.cfg.utilities kernel sequences vectors ;
6 IN: compiler.cfg.useless-conditionals
8 : delete-conditional? ( bb -- ? )
13 [ ##compare-imm-branch? ]
14 [ ##compare-integer-branch? ]
15 [ ##compare-integer-imm-branch? ]
16 [ ##compare-float-ordered-branch? ]
17 [ ##compare-float-unordered-branch? ]
20 [ successors>> first2 [ skip-empty-blocks ] bi@ eq? ]
23 : delete-conditional ( bb -- )
24 [ first skip-empty-blocks 1vector ] change-successors
25 instructions>> [ pop* ] [ [ ##branch new-insn ] dip push ] bi ;
27 : delete-useless-conditionals ( cfg -- )
30 dup delete-conditional? [ delete-conditional ] [ drop ] if
33 [ cfg-changed ] [ predecessors-changed ] tri ;