Scheduling schedules more BBs--it was leaving out some ones that shouldn't've been. Now it's almost 30% of spills and reloads that are eliminated
parent
edae2fa2d3
commit
a6f255a985
|
@ -120,13 +120,11 @@ UNION: alien-call-insn
|
||||||
[ add-data-edges ]
|
[ add-data-edges ]
|
||||||
[ add-control-edges ]
|
[ add-control-edges ]
|
||||||
[ set-follows ]
|
[ set-follows ]
|
||||||
[ nodes set ] ! for assertions later
|
[ nodes set ]
|
||||||
[ set-roots ]
|
[ set-roots ]
|
||||||
} cleave ;
|
} cleave ;
|
||||||
|
|
||||||
! Constructing fan-in trees using the
|
|
||||||
! Sethi-Ulmann numbering
|
! Sethi-Ulmann numbering
|
||||||
|
|
||||||
:: calculate-registers ( node -- registers )
|
:: calculate-registers ( node -- registers )
|
||||||
node children>> [ 0 ] [
|
node children>> [ 0 ] [
|
||||||
[ [ calculate-registers ] map natural-sort ]
|
[ [ calculate-registers ] map natural-sort ]
|
||||||
|
@ -136,6 +134,8 @@ UNION: alien-call-insn
|
||||||
node insn>> temp-vregs length +
|
node insn>> temp-vregs length +
|
||||||
dup node (>>registers) ;
|
dup node (>>registers) ;
|
||||||
|
|
||||||
|
! Constructing fan-in trees
|
||||||
|
|
||||||
: attach-parent ( node parent -- )
|
: attach-parent ( node parent -- )
|
||||||
[ >>parent drop ]
|
[ >>parent drop ]
|
||||||
[ [ ?push ] change-children drop ] 2bi ;
|
[ [ ?push ] change-children drop ] 2bi ;
|
||||||
|
|
|
@ -122,26 +122,14 @@ ERROR: definition-after-usage vreg old-bb new-bb ;
|
||||||
! to decide whether to schedule instructions
|
! to decide whether to schedule instructions
|
||||||
: num-registers ( -- x ) int-regs machine-registers at length ;
|
: num-registers ( -- x ) int-regs machine-registers at length ;
|
||||||
|
|
||||||
: update-vregs ( insn vregs -- )
|
|
||||||
[ [ defs-vreg ] dip '[ _ delete-at ] when* ]
|
|
||||||
[ [ uses-vregs ] dip '[ _ conjoin ] each ] 2bi ;
|
|
||||||
|
|
||||||
:: (might-spill?) ( vregs insns -- ? )
|
|
||||||
insns <reversed> [
|
|
||||||
[ vregs update-vregs ]
|
|
||||||
[ temp-vregs length vregs assoc-size + num-registers > ] bi
|
|
||||||
] any? ;
|
|
||||||
|
|
||||||
: might-spill? ( bb -- ? )
|
: might-spill? ( bb -- ? )
|
||||||
! Conservative approximation testing whether a bb might spill
|
[ live-in assoc-size ]
|
||||||
! by calculating register pressure all along, assuming
|
[ instructions>> [ defs-vreg ] count ] bi
|
||||||
! everything in live-out are in registers
|
+ num-registers >= ;
|
||||||
! This is done bottom-up: a def means the register is no longer live
|
|
||||||
[ live-out H{ } assoc-clone-like ] [ instructions>> ] bi (might-spill?) ;
|
|
||||||
|
|
||||||
: schedule-instructions ( cfg -- cfg' )
|
: schedule-instructions ( cfg -- cfg' )
|
||||||
dup [
|
dup [
|
||||||
dup might-spill?
|
dup might-spill?
|
||||||
[ schedule-block ]
|
[ schedule-block ]
|
||||||
[ drop ] if
|
[ drop ] if
|
||||||
] each-basic-block ;
|
] each-basic-block ;
|
||||||
|
|
Loading…
Reference in New Issue