mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +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:
parent
39002f251e
commit
52965e03ec
1 changed files with 14 additions and 0 deletions
|
@ -408,6 +408,20 @@
|
||||||
((x y)
|
((x y)
|
||||||
(or (fold-binary-branch cps label names vars k kt src name x y)
|
(or (fold-binary-branch cps label names vars k kt src name x y)
|
||||||
cps))))
|
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)))
|
(_ cps)))
|
||||||
(let lp ((label start) (cps cps))
|
(let lp ((label start) (cps cps))
|
||||||
(if (<= label end)
|
(if (<= label end)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue