compiler.cfg.gvn.comparisons: fix premature cfg modifications
parent
d6641eddb3
commit
3787f64422
|
@ -98,9 +98,10 @@ UNION: general-compare-insn scalar-compare-insn ##test-vector ;
|
|||
} cond ;
|
||||
|
||||
: fold-branch ( ? -- insn )
|
||||
drop
|
||||
! 0 1 ?
|
||||
! basic-block get [ nth 1vector ] change-successors drop
|
||||
final-iteration? get [
|
||||
0 1 ?
|
||||
basic-block get [ nth 1vector ] change-successors drop
|
||||
] [ drop ] if
|
||||
\ ##branch new-insn ;
|
||||
|
||||
: fold-compare-imm-branch ( insn -- insn/f )
|
||||
|
@ -257,10 +258,10 @@ M: ##compare-integer-imm rewrite
|
|||
[ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline
|
||||
|
||||
: simplify-test ( insn -- insn )
|
||||
dup (simplify-test) drop [ >>src1 ] [ >>src2 ] bi* ; inline
|
||||
[ dst>> ] [ (simplify-test) ] [ temp>> ] tri \ ##test new-insn ; inline
|
||||
|
||||
: simplify-test-branch ( insn -- insn )
|
||||
dup (simplify-test) drop [ >>src1 ] [ >>src2 ] bi* ; inline
|
||||
(simplify-test) \ ##test-branch new-insn ; inline
|
||||
|
||||
: (simplify-test-imm) ( insn -- src1 src2 cc )
|
||||
[ src1>> vreg>insn [ src1>> ] [ src2>> ] bi ] [ cc>> ] bi ; inline
|
||||
|
|
|
@ -51,13 +51,14 @@ M: array process-instruction
|
|||
|
||||
! FIXME there's going to be trouble with certain rewrites that
|
||||
! modify the cfg / instructions destructively; namely those in
|
||||
! comparisons.factor, alien.factor, and slots.factor
|
||||
! alien.factor and slots.factor
|
||||
|
||||
: value-numbering-iteration ( cfg -- )
|
||||
clear-exprs
|
||||
[ value-numbering-step drop ] simple-analysis ;
|
||||
|
||||
: identify-redundancies ( cfg -- )
|
||||
final-iteration? off
|
||||
init-value-graph
|
||||
'[
|
||||
changed? off
|
||||
|
@ -66,6 +67,7 @@ M: array process-instruction
|
|||
] loop ;
|
||||
|
||||
: eliminate-redundancies ( cfg -- )
|
||||
final-iteration? on
|
||||
clear-exprs
|
||||
[ value-numbering-step ] simple-optimization ;
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@ GENERIC: rewrite ( insn -- insn/f )
|
|||
|
||||
M: insn rewrite drop f ;
|
||||
|
||||
! Boolean to track when it's safe to alter the CFG in a rewrite
|
||||
! method (i.e., after we've already iterated till fixpoint)
|
||||
SYMBOL: final-iteration?
|
||||
|
||||
! Utilities
|
||||
GENERIC: insn>integer ( insn -- n )
|
||||
|
||||
|
|
Loading…
Reference in New Issue