emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 05259c4 1/2: Fix `=' propagation to handle -0.0 0.0


From: Andrea Corallo
Subject: feature/native-comp 05259c4 1/2: Fix `=' propagation to handle -0.0 0.0 case
Date: Sat, 6 Mar 2021 15:02:23 -0500 (EST)

branch: feature/native-comp
commit 05259c4a238efa40fa66ac51844aa5227b9c576b
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Fix `=' propagation to handle -0.0 0.0 case
    
        * lisp/emacs-lisp/comp-cstr.el
        (comp-cstr-intersection-homogeneous): Fix indent + use `memql'.
        (comp-cstr-=): Handle 0.0 -0.0 idiosyncrasy
        * test/src/comp-tests.el (comp-tests-type-spec-tests): Add two
        tests and fix enumeration.
---
 lisp/emacs-lisp/comp-cstr.el |  8 ++++++--
 test/src/comp-tests.el       | 32 ++++++++++++++++++++++++--------
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 6a8ec52..d6423ef 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -664,7 +664,7 @@ DST is returned."
       (cl-return-from comp-cstr-intersection-homogeneous dst))
 
     (setf (neg dst) (when srcs
-                                (neg (car srcs))))
+                      (neg (car srcs))))
 
     ;; Type propagation.
     (setf (typeset dst)
@@ -682,7 +682,7 @@ DST is returned."
              ;; If (member value) is subtypep of all other sources then
              ;; is good to be colleted.
              when (cl-every (lambda (s)
-                              (or (memq val (valset s))
+                              (or (memql val (valset s))
                                   (cl-some (lambda (type)
                                              (cl-typep val type))
                                            (typeset s))))
@@ -890,6 +890,10 @@ Non memoized version of `comp-cstr-intersection-no-mem'."
                       (cl-return cstr)
                  finally (setf (valset cstr)
                                (append vals-to-add (valset cstr))))
+                (when (memql 0.0 (valset cstr))
+                  (cl-pushnew -0.0 (valset cstr)))
+                (when (memql -0.0 (valset cstr))
+                  (cl-pushnew 0.0 (valset cstr)))
                 cstr))
       (comp-cstr-intersection dst (relax-cstr op1) (relax-cstr op2)))))
 
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index dae2abc..cd1c2e0 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -1299,32 +1299,48 @@ Return a list of results."
           (error "")))
        cons)
 
-      ;; 69
+      ;; 68
       ((defun comp-tests-ret-type-spec-f (x)
         (if (and (floatp x)
-                 (= x 0))
+                 (= x 1))
              x
            (error "")))
        ;; Conservative (see cstr relax in `comp-cstr-=').
-       (or (member 0.0) (integer 0 0)))
+       (or (member 1.0) (integer 1 1)))
 
-      ;; 70
+      ;; 69
       ((defun comp-tests-ret-type-spec-f (x)
         (if (and (integer x)
-                 (= x 0))
+                 (= x 1))
              x
            (error "")))
        ;; Conservative (see cstr relax in `comp-cstr-=').
-       (or (member 0.0) (integer 0 0)))
+       (or (member 1.0) (integer 1 1)))
 
-      ;; 71
+      ;; 70
       ((defun comp-tests-ret-type-spec-f (x y)
         (if (and (floatp x)
                  (integerp y)
                  (= x y))
              x
            (error "")))
-       (or float integer))))
+       (or float integer))
+
+      ;; 71
+      ((defun comp-tests-ret-type-spec-f (x)
+         (if (= x 0.0)
+             x
+           (error "")))
+       (or (member -0.0 0.0) (integer 0 0)))
+
+      ;; 72
+      ((defun comp-tests-ret-type-spec-f (x)
+         (unless (= x 0.0)
+           (error ""))
+         (unless (eql x -0.0)
+           (error ""))
+         x)
+       float)))
 
   (defun comp-tests-define-type-spec-test (number x)
     `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) ()



reply via email to

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