guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 02/04: Fold eqv? to eq? on exact integers according to t


From: Andy Wingo
Subject: [Guile-commits] 02/04: Fold eqv? to eq? on exact integers according to target fixnum range
Date: Wed, 12 Aug 2020 17:32:27 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit a7f4a6f1c4395e14825e46de25064ff38b8203fb
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Tue Aug 11 23:07:05 2020 +0200

    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.
---
 module/language/tree-il/peval.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/module/language/tree-il/peval.scm 
b/module/language/tree-il/peval.scm
index dd16709..def4235 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]