 
 M: ##copy visit-insn record-copy ;
 
-M: ##phi visit-insn inputs>> values [ resolve ] map all-equal? [ "BLAH!" print ] when ;
+M: ##phi visit-insn
+    [ dst>> ] [ inputs>> values [ resolve ] map ] bi
+    dup all-equal? [ first (record-copy) ] [ 2drop ] if ;
 
 M: insn visit-insn drop ;
 

SYMBOL: copies

: resolve ( vreg -- vreg )
    [ copies get at ] keep or ;

: record-copy ( ##copy -- )
    [ src>> resolve ] [ dst>> ] bi copies get set-at ; inline

<PRIVATE


! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel namespaces assocs accessors sequences grouping
compiler.cfg.rpo compiler.cfg.renaming compiler.cfg.instructions ;
IN: compiler.cfg.copy-prop

