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

Constant-folding eq? and eqv? uses deduplication

* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/language/tree-il/peval.scm (peval): Constant-fold eq? and eqv?
  using equal?, anticipating deduplication.
This commit is contained in:
Andy Wingo 2016-06-24 17:35:55 +02:00
parent ef2943e806
commit 45b80a1fa8
2 changed files with 18 additions and 2 deletions

View file

@ -479,7 +479,15 @@ top-level bindings from ENV and return the resulting expression."
(lambda ()
(call-with-values
(lambda ()
(apply (module-ref the-scm-module name) args))
(case name
((eq? eqv?)
;; Constants will be deduplicated later, but eq?
;; folding can happen now. Anticipate the
;; deduplication by using equal? instead of eq?.
;; Same for eqv?.
(apply equal? args))
(else
(apply (module-ref the-scm-module name) args))))
(lambda results
(values #t results))))
(lambda _

View file

@ -1321,4 +1321,12 @@
(if (apply (primitive pair?) (toplevel arg))
(set! (lexical l _) (toplevel arg))
(void))
(apply (primitive @apply) (toplevel f) (lexical l _))))))
(apply (primitive @apply) (toplevel f) (lexical l _)))))
(pass-if-peval
(eq? '(a b) '(a b))
(const #t))
(pass-if-peval
(eqv? '(a b) '(a b))
(const #t)))