]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/compiler/cfg/phi-elimination/phi-elimination.factor
compiler.cfg: change representation of ##phi nodes. The input slot of ##phi nodes...
[factor.git] / basis / compiler / cfg / phi-elimination / phi-elimination.factor
index 3ebf553a4550d0ce7236d457a7e42ee14645eb1d..9c2f0adafd90b0914b081f2793bf06d52e428898 100644 (file)
@@ -1,21 +1,17 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors compiler.cfg compiler.cfg.instructions
-compiler.cfg.rpo fry kernel sequences ;
+USING: accessors assocs fry kernel sequences
+compiler.cfg compiler.cfg.instructions compiler.cfg.rpo ;
 IN: compiler.cfg.phi-elimination
 
 : insert-copy ( predecessor input output -- )
     '[ _ _ swap ##copy ] add-instructions ;
 
-: eliminate-phi ( bb ##phi -- )
-    [ predecessors>> ] [ [ inputs>> ] [ dst>> ] bi ] bi*
-    '[ _ insert-copy ] 2each ;
+: eliminate-phi ( ##phi -- )
+    [ inputs>> ] [ dst>> ] bi '[ _ insert-copy ] assoc-each ;
 
 : eliminate-phi-step ( bb -- )
-    dup [
-        [ ##phi? ] partition
-        [ [ eliminate-phi ] with each ] dip
-    ] change-instructions drop ;
+    instructions>> [ dup ##phi? [ eliminate-phi f ] [ drop t ] if ] filter-here ;
 
 : eliminate-phis ( cfg -- cfg' )
     dup [ eliminate-phi-step ] each-basic-block ;
\ No newline at end of file