compiler.cfg.gvn: preparing for avail-based redundancy elimination

db4
Alex Vondrak 2011-06-23 17:39:46 -07:00 committed by John Benediktsson
parent cce1f9d859
commit 454c2f245b
2 changed files with 18 additions and 5 deletions

View File

@ -15,6 +15,10 @@ SYMBOL: exprs>vns
! assoc mapping value numbers to instructions
SYMBOL: vns>insns
! assoc mapping basic blocks to the set of value numbers that
! are defined in the block
SYMBOL: bbs>defns
! boolean to track whether vregs>vns changes
SYMBOL: changed?
@ -27,12 +31,16 @@ SYMBOL: changed?
: vreg>insn ( vreg -- insn ) vreg>vn vn>insn ;
: defined ( bb -- vns ) bbs>defns get at ;
: clear-exprs ( -- )
exprs>vns get clear-assoc
vns>insns get clear-assoc ;
vns>insns get clear-assoc
bbs>defns get clear-assoc ;
: init-value-graph ( -- )
0 input-expr-counter set
H{ } clone vregs>vns set
H{ } clone exprs>vns set
H{ } clone vns>insns set ;
H{ } clone vns>insns set
H{ } clone bbs>defns set ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces arrays assocs kernel accessors fry grouping
sorting sets sequences locals
USING: namespaces arrays assocs hashtables kernel accessors fry
grouping sorting sets sequences locals
cpu.architecture
sequences.deep
compiler.cfg
@ -29,6 +29,7 @@ GENERIC: process-instruction ( insn -- insn' )
vn vn set-vn
vn expr exprs>vns get set-at
insn vn vns>insns get set-at
vn vn basic-block get bbs>defns get [ ?set-at ] change-at
insn ;
: check-redundancy ( insn -- insn' )
@ -62,6 +63,10 @@ M: array process-instruction
changed? get
] loop ;
! FIXME can't just do a pass through the cfg to rewrite---not
! all canonical leaders are necessarily available in a
! particular rewrite
: eliminate-redundancies ( cfg -- )
final-iteration? on
clear-exprs
@ -69,5 +74,5 @@ M: array process-instruction
: value-numbering ( cfg -- cfg )
dup identify-redundancies
dup eliminate-redundancies
! dup eliminate-redundancies
cfg-changed predecessors-changed ;