Fix loop handling in stack-analysis
parent
0375ce6bb4
commit
6ac52761c6
|
@ -28,6 +28,7 @@ IN: compiler.cfg.optimizer.tests
|
||||||
[ [ 2 fixnum* ] when 3 ]
|
[ [ 2 fixnum* ] when 3 ]
|
||||||
[ [ 2 fixnum+ ] when 3 ]
|
[ [ 2 fixnum+ ] when 3 ]
|
||||||
[ [ 2 fixnum- ] when 3 ]
|
[ [ 2 fixnum- ] when 3 ]
|
||||||
|
[ 10000 [ ] times ]
|
||||||
} [
|
} [
|
||||||
[ [ ] ] dip '[ _ test-mr first check-mr ] unit-test
|
[ [ ] ] dip '[ _ test-mr first check-mr ] unit-test
|
||||||
] each
|
] each
|
||||||
|
|
|
@ -106,7 +106,8 @@ IN: compiler.cfg.stack-analysis.tests
|
||||||
|
|
||||||
! Sync before a back-edge, not after
|
! Sync before a back-edge, not after
|
||||||
! ##peeks should be inserted before a ##loop-entry
|
! ##peeks should be inserted before a ##loop-entry
|
||||||
[ 1 ] [
|
! Don't optimize out the constants
|
||||||
|
[ 1 t ] [
|
||||||
[ 1000 [ ] times ] test-stack-analysis eliminate-dead-code linearize
|
[ 1000 [ ] times ] test-stack-analysis eliminate-dead-code linearize
|
||||||
[ ##add-imm? ] count
|
[ [ ##add-imm? ] count ] [ [ ##load-immediate? ] any? ] bi
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
|
@ -87,8 +87,7 @@ GENERIC: visit ( insn -- )
|
||||||
! Instructions which don't have any effect on the stack
|
! Instructions which don't have any effect on the stack
|
||||||
UNION: neutral-insn
|
UNION: neutral-insn
|
||||||
##flushable
|
##flushable
|
||||||
##effect
|
##effect ;
|
||||||
##loop-entry ;
|
|
||||||
|
|
||||||
M: neutral-insn visit , ;
|
M: neutral-insn visit , ;
|
||||||
|
|
||||||
|
@ -96,17 +95,23 @@ UNION: sync-if-back-edge
|
||||||
##branch
|
##branch
|
||||||
##conditional-branch
|
##conditional-branch
|
||||||
##compare-imm-branch
|
##compare-imm-branch
|
||||||
##dispatch ;
|
##dispatch
|
||||||
|
##loop-entry ;
|
||||||
|
|
||||||
SYMBOL: local-only?
|
SYMBOL: local-only?
|
||||||
|
|
||||||
t local-only? set-global
|
t local-only? set-global
|
||||||
|
|
||||||
|
: back-edge? ( from to -- ? )
|
||||||
|
[ number>> ] bi@ > ;
|
||||||
|
|
||||||
|
: sync-state? ( -- ? )
|
||||||
|
basic-block get successors>>
|
||||||
|
[ [ predecessors>> ] keep '[ _ back-edge? ] any? ] any?
|
||||||
|
local-only? get or ;
|
||||||
|
|
||||||
M: sync-if-back-edge visit
|
M: sync-if-back-edge visit
|
||||||
basic-block get [ successors>> ] [ number>> ] bi
|
sync-state? [ sync-state ] when , ;
|
||||||
'[ number>> _ < local-only? get or ] any?
|
|
||||||
[ sync-state ] when
|
|
||||||
, ;
|
|
||||||
|
|
||||||
: adjust-d ( n -- ) state get [ + ] change-ds-height drop ;
|
: adjust-d ( n -- ) state get [ + ] change-ds-height drop ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue