 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs bit-arrays bit-sets fry
-hashtables hints kernel locals math namespaces sequences sets
+hashtables hints kernel locals math namespaces sequences new-sets
 compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ;
-QUALIFIED: new-sets
+FROM: namespaces => set ;
 IN: compiler.cfg.ssa.construction.tdmsc
 
 ! TDMSC-I algorithm from "A Practical and Fast Iterative Algorithm for

: compute-merge-sets ( cfg -- )
    needs-dominance

    H{ } clone visited set
    [ compute-levels ]
    [ init-merge-sets ]
    [ compute-merge-set-loop ]
    tri ;

: merge-set ( bbs -- bbs' )
     (merge-set) [ new-sets:members ] dip nths ;

: merge-set-each ( bbs quot: ( bb -- ) -- )
    [ merge-set ] dip each ; inline

    loop ;

: (merge-set) ( bbs -- flags rpo )
    merge-sets get '[ _ at ] [ union ] map-reduce
    cfg get reverse-post-order ; inline

PRIVATE>
