]> gitweb.factorcode.org Git - factor.git/blob - unfinished/compiler/machine.bluesky/simplifier/simplifier.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / unfinished / compiler / machine.bluesky / simplifier / simplifier.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors namespaces sequences.next compiler.lvops ;
4 IN: compiler.machine.simplifier
5
6 : useless-branch? ( next insn -- ? )
7     2dup [ _label? ] [ _b? ] bi* and
8     [ [ label>> ] bi@ = ] [ 2drop f ] if ;
9
10 : simplify-mr ( insns -- insns )
11     #! Remove unconditional branches to labels immediately
12     #! following.
13     [
14         [
15             tuck useless-branch?
16             [ drop ] [ , ] if
17         ] each-next
18     ] { } make ;