 
 : dead-store ( insn# -- ) dead-stores get adjoin ;
 
+ERROR: vreg-not-new vreg ;
+
 :: set-ac ( vreg ac -- )
     #! Set alias class of newly-seen vreg.
-    H{ } clone vreg recent-stores get set-at
-    H{ } clone vreg live-slots get set-at
+    vreg vregs>acs get key? [ vreg vreg-not-new ] when
     ac vreg vregs>acs get set-at
     vreg ac acs>vregs get push-at ;
 

    ! inserted yet.
    dup [
        { int-rep tagged-rep } member?
        [ set-heap-ac ] [ set-new-ac ] if
    ] each-def-rep ;

M: vreg-insn analyze-aliases
    def-acs ;

M: ##phi analyze-aliases
    dup dst>> set-heap-ac ;

M: ##allocation analyze-aliases
    #! A freshly allocated object is distinct from any other

: next-ac ( -- n )
    ac-counter [ dup 1 + ] change ;

: set-new-ac ( vreg -- ) next-ac set-ac ;

: kill-constant-set-slot ( slot# vreg -- )
    [ live-slots get at delete-at ] with each-alias ;

: recent-stores-of ( vreg -- assoc )
    recent-stores get [ drop H{ } clone ] cache ;

:: record-constant-set-slot ( insn# slot# vreg -- )
    vreg recent-stores-of :> recent-stores
    slot# recent-stores at [ dead-store ] when*
    insn# slot# recent-stores set-at ;

