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

SYMBOL: copies

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

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

<PRIVATE


GENERIC: update-insn ( insn -- keep? )

M: ##copy update-insn drop f ;

M: ##phi update-insn
    dup dst>> copies get key? [ drop f ] [ call-next-method ] if ;

M: insn update-insn rename-insn-uses t ;

