mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-26 21:20:30 +02:00
Optimize Equality Primitives
* module/language/tree-il/primitives.scm: add equality-primitive?, which is true for eq?, eqv?, and equal? * module/language/tree-il/peval.scm: if an equality primitive is applied to the same variable twice, fold it to #t * test-suite/tests/tree-il.test: add tests for pevaling equality primitives
This commit is contained in:
parent
6978c67339
commit
3c65e3fda5
3 changed files with 31 additions and 1 deletions
|
@ -1498,6 +1498,16 @@
|
|||
;; Constant folding: cdr+list, impure
|
||||
(cdr (list (bar) 0))
|
||||
(seq (call (toplevel bar)) (primcall list (const 0))))
|
||||
|
||||
(pass-if-peval
|
||||
;; Equality primitive: same lexical
|
||||
(let ((x (random))) (eq? x x))
|
||||
(seq (call (toplevel random)) (const #t)))
|
||||
|
||||
(pass-if-peval
|
||||
;; Equality primitive: merge lexical identities
|
||||
(let* ((x (random)) (y x)) (eq? x y))
|
||||
(seq (call (toplevel random)) (const #t)))
|
||||
|
||||
(pass-if-peval
|
||||
;; Non-constant guards get lexical bindings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue