1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 22:10:21 +02:00

Better folding of branches on $values

* module/language/cps/type-fold.scm (local-type-fold): Fold branches on
  $values, if we can.
This commit is contained in:
Andy Wingo 2016-01-03 16:17:53 +01:00
parent 39002f251e
commit 52965e03ec

View file

@ -408,6 +408,20 @@
((x y)
(or (fold-binary-branch cps label names vars k kt src name x y)
cps))))
(($ $branch kt ($ $values (arg)))
;; We might be able to fold branches on values.
(call-with-values (lambda () (lookup-pre-type types label arg))
(lambda (type min max)
(cond
((zero? (logand type (logior &false &nil)))
(with-cps cps
(setk label
($kargs names vars ($continue kt src ($values ()))))))
((zero? (logand type (lognot (logior &false &nil))))
(with-cps cps
(setk label
($kargs names vars ($continue k src ($values ()))))))
(else cps)))))
(_ cps)))
(let lp ((label start) (cps cps))
(if (<= label end)