mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-25 20:50:31 +02:00
Reduce call-with-values to let for singly-valued producers
* module/language/tree-il/peval.scm (singly-valued-expression?): Add support for conditionals. In the future we should add more expressions here. (peval): Don't inline values into the body of a dynwind, as that could cause the consumer to run in the wrong dynamic context. If the producer is singly-valued and the consumer just has a rest arg, reduce to "let" and cons up a list in the consumer. This may reduce further. * test-suite/tests/peval.test ("partial evaluation"): Add a test.
This commit is contained in:
parent
b34b66b346
commit
e6450062a1
2 changed files with 29 additions and 4 deletions
|
@ -983,6 +983,15 @@
|
|||
(apply list args)))
|
||||
(primcall list (const 1) (const 2)))
|
||||
|
||||
(pass-if-peval
|
||||
;; When we can't inline let-values but can prove that the producer
|
||||
;; has just one value, reduce to "let" (which can then fold
|
||||
;; further).
|
||||
(call-with-values (lambda () (if foo 1 2))
|
||||
(lambda args
|
||||
(apply values args)))
|
||||
(if (toplevel foo) (const 1) (const 2)))
|
||||
|
||||
(pass-if-peval
|
||||
;; Constant folding: cons of #nil does not make list
|
||||
(cons 1 #nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue