mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
RTL slot allocation: Don't kill variables that flow into loops
* module/language/cps/dfg.scm (dead-after-use?): Don't kill a variable if it was defined outside the current loop. (dead-after-branch?): Likewise, but I don't think this helper is correct yet :/
This commit is contained in:
parent
0e2446d4db
commit
b8da548fba
1 changed files with 25 additions and 16 deletions
|
@ -708,17 +708,22 @@
|
||||||
(($ $use-map sym def uses)
|
(($ $use-map sym def uses)
|
||||||
(null? uses))))))
|
(null? uses))))))
|
||||||
|
|
||||||
|
(define (lookup-loop-header k blocks)
|
||||||
|
(block-loop-header (lookup-block k blocks)))
|
||||||
|
|
||||||
(define (dead-after-use? sym use-k dfg)
|
(define (dead-after-use? sym use-k dfg)
|
||||||
(match dfg
|
(match dfg
|
||||||
(($ $dfg conts blocks use-maps)
|
(($ $dfg conts blocks use-maps)
|
||||||
(match (lookup-use-map sym use-maps)
|
(match (lookup-use-map sym use-maps)
|
||||||
(($ $use-map sym def uses)
|
(($ $use-map sym def uses)
|
||||||
;; If all other uses dominate this use, it is now dead. There
|
;; If all other uses dominate this use, and the variable was not
|
||||||
;; are other ways for it to be dead, but this is an
|
;; defined outside the current loop, it is now dead. There are
|
||||||
;; approximation. A better check would be if all successors
|
;; other ways for it to be dead, but this is an approximation.
|
||||||
;; post-dominate all uses.
|
;; A better check would be if all successors post-dominate all
|
||||||
(and-map (cut dominates? <> use-k blocks)
|
;; uses.
|
||||||
uses))))))
|
(and (eqv? (lookup-loop-header use-k blocks)
|
||||||
|
(lookup-loop-header def blocks))
|
||||||
|
(and-map (cut dominates? <> use-k blocks) uses)))))))
|
||||||
|
|
||||||
;; A continuation is a "branch" if all of its predecessors are $kif
|
;; A continuation is a "branch" if all of its predecessors are $kif
|
||||||
;; continuations.
|
;; continuations.
|
||||||
|
@ -746,6 +751,10 @@
|
||||||
(($ $dfg conts blocks use-maps)
|
(($ $dfg conts blocks use-maps)
|
||||||
(match (lookup-use-map sym use-maps)
|
(match (lookup-use-map sym use-maps)
|
||||||
(($ $use-map sym def uses)
|
(($ $use-map sym def uses)
|
||||||
|
;; As in dead-after-use?, we don't kill the variable if it was
|
||||||
|
;; defined outside the current loop.
|
||||||
|
(and (eqv? (lookup-loop-header branch blocks)
|
||||||
|
(lookup-loop-header def blocks))
|
||||||
(and-map
|
(and-map
|
||||||
(lambda (use-k)
|
(lambda (use-k)
|
||||||
;; A symbol is dead after a branch if at least one of the
|
;; A symbol is dead after a branch if at least one of the
|
||||||
|
@ -755,7 +764,7 @@
|
||||||
other-branches)
|
other-branches)
|
||||||
(not (dominates? branch use-k blocks))
|
(not (dominates? branch use-k blocks))
|
||||||
(dominates? use-k branch blocks)))
|
(dominates? use-k branch blocks)))
|
||||||
uses))))))
|
uses)))))))
|
||||||
|
|
||||||
(define (lookup-bound-syms k dfg)
|
(define (lookup-bound-syms k dfg)
|
||||||
(match dfg
|
(match dfg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue