1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Make CSE more robust

* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
  I think it's possible to get an orphan loop, with predecessors
  after successors in the original RPO.  Handle that here.
This commit is contained in:
Andy Wingo 2020-06-12 15:58:54 +02:00
parent e7398643b2
commit fc139231a6

View file

@ -551,7 +551,11 @@ false. It could be that both true and false proofs are available."
(prune-successors analysis label (term-successors term))))
((trivial-intset preds)
=> (lambda (pred)
(match (intmap-ref out pred)
(match (and (< pred label) (intmap-ref out pred))
(#f
;; Orphan loop; branch folding must have removed
;; entry. Could still be alive though.
(visit-term-normally))
(($ $kargs names' vars' ($ $continue _ _ ($ $values vals)))
;; Substitute dominating definitions, and try to elide the
;; predecessor entirely.
@ -583,7 +587,7 @@ false. It could be that both true and false proofs are available."
;; those as well.
(add-auxiliary-definitions! pred vars substs term-key)))
(visit-term-normally))
(_
((or ($ $kclause) ($ $kreceive))
(visit-term-normally)))))
(else
(visit-term-normally)))))))