summaryrefslogtreecommitdiff
path: root/module/language
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2020-08-11 23:07:05 +0200
committerAndy Wingo <wingo@pobox.com>2020-08-12 23:30:08 +0200
commita7f4a6f1c4395e14825e46de25064ff38b8203fb (patch)
treee959457ec20529452dff169cfb997301eb36165d /module/language
parentfeafad7958ca4e35fdb398d229c49223612a6158 (diff)
downloadguile-a7f4a6f1c4395e14825e46de25064ff38b8203fb.tar.gz
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.
Diffstat (limited to 'module/language')
-rw-r--r--module/language/tree-il/peval.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm
index dd16709fd..def423518 100644
--- a/module/language/tree-il/peval.scm
+++ b/module/language/tree-il/peval.scm
@@ -26,6 +26,7 @@
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
+ #:use-module (system base target)
#:use-module (ice-9 control)
#:export (peval))
@@ -1352,8 +1353,15 @@ top-level bindings from ENV and return the resulting expression."
;; Already in a reduced state.
(make-primcall src 'eq? (list a b)))
((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)
- (<= 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
;; comparable with eq?.
(make-primcall src 'eq? (list a b)))