mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Simplify live variable computation for graphs without loops
* module/language/cps/slot-allocation.scm (compute-reverse-control-flow-order): For graphs without back-edges, use a simplified computation of reverse control flow order.
This commit is contained in:
parent
b077e807c0
commit
39520f879a
1 changed files with 29 additions and 11 deletions
|
@ -23,6 +23,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(define-module (language cps slot-allocation)
|
(define-module (language cps slot-allocation)
|
||||||
|
#:use-module (ice-9 control)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-9)
|
#:use-module (srfi srfi-9)
|
||||||
|
@ -171,17 +172,34 @@ by a label, respectively."
|
||||||
|
|
||||||
(define (compute-reverse-control-flow-order preds)
|
(define (compute-reverse-control-flow-order preds)
|
||||||
"Return a LABEL->ORDER bijection where ORDER is a contiguous set of
|
"Return a LABEL->ORDER bijection where ORDER is a contiguous set of
|
||||||
integers starting from 0 and incrementing in sort order."
|
integers starting from 0 and incrementing in sort order. There is a
|
||||||
;; This is more involved than forward control flow because not all
|
precondition that labels in PREDS are already renumbered in reverse post
|
||||||
;; live labels are reachable from the tail.
|
order."
|
||||||
(persistent-intmap
|
(define (has-back-edge? preds)
|
||||||
(fold2 (lambda (component order n)
|
(let/ec return
|
||||||
(intset-fold (lambda (label order n)
|
(intmap-fold (lambda (label labels)
|
||||||
(values (intmap-add! order label n)
|
(intset-fold (lambda (pred)
|
||||||
(1+ n)))
|
(if (<= label pred)
|
||||||
component order n))
|
(return #t)
|
||||||
(reverse (compute-sorted-strongly-connected-components preds))
|
(values)))
|
||||||
empty-intmap 0)))
|
labels)
|
||||||
|
(values))
|
||||||
|
preds)
|
||||||
|
#f))
|
||||||
|
(if (has-back-edge? preds)
|
||||||
|
;; This is more involved than forward control flow because not all
|
||||||
|
;; live labels are reachable from the tail.
|
||||||
|
(persistent-intmap
|
||||||
|
(fold2 (lambda (component order n)
|
||||||
|
(intset-fold (lambda (label order n)
|
||||||
|
(values (intmap-add! order label n)
|
||||||
|
(1+ n)))
|
||||||
|
component order n))
|
||||||
|
(reverse (compute-sorted-strongly-connected-components preds))
|
||||||
|
empty-intmap 0))
|
||||||
|
;; Just reverse forward control flow.
|
||||||
|
(let ((max (intmap-prev preds)))
|
||||||
|
(intmap-map (lambda (label labels) (- max label)) preds))))
|
||||||
|
|
||||||
(define* (add-prompt-control-flow-edges conts succs #:key complete?)
|
(define* (add-prompt-control-flow-edges conts succs #:key complete?)
|
||||||
"For all prompts in DFG in the range [MIN-LABEL, MIN-LABEL +
|
"For all prompts in DFG in the range [MIN-LABEL, MIN-LABEL +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue