mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Fold eqv? to eq? on exact integers according to target fixnum range
* module/language/tree-il/peval.scm (peval): Fix folding to only reduce to eq? for values within both host and target range.
This commit is contained in:
parent
feafad7958
commit
a7f4a6f1c4
1 changed files with 9 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
||||||
#:use-module (srfi srfi-9)
|
#:use-module (srfi srfi-9)
|
||||||
#:use-module (srfi srfi-11)
|
#:use-module (srfi srfi-11)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
|
#:use-module (system base target)
|
||||||
#:use-module (ice-9 control)
|
#:use-module (ice-9 control)
|
||||||
#:export (peval))
|
#:export (peval))
|
||||||
|
|
||||||
|
@ -1352,8 +1353,15 @@ top-level bindings from ENV and return the resulting expression."
|
||||||
;; Already in a reduced state.
|
;; Already in a reduced state.
|
||||||
(make-primcall src 'eq? (list a b)))
|
(make-primcall src 'eq? (list a b)))
|
||||||
((or (memq v '(#f #t () #nil)) (symbol? v) (char? v)
|
((or (memq v '(#f #t () #nil)) (symbol? v) (char? v)
|
||||||
|
;; Only fold to eq? value is a fixnum on target and
|
||||||
|
;; host, as constant folding may have us compare on host
|
||||||
|
;; as well.
|
||||||
(and (exact-integer? v)
|
(and (exact-integer? v)
|
||||||
(<= most-negative-fixnum v most-positive-fixnum)))
|
(<= (max (target-most-negative-fixnum)
|
||||||
|
most-negative-fixnum)
|
||||||
|
v
|
||||||
|
(min (target-most-positive-fixnum)
|
||||||
|
most-positive-fixnum))))
|
||||||
;; Reduce to eq?. Note that in Guile, characters are
|
;; Reduce to eq?. Note that in Guile, characters are
|
||||||
;; comparable with eq?.
|
;; comparable with eq?.
|
||||||
(make-primcall src 'eq? (list a b)))
|
(make-primcall src 'eq? (list a b)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue