0.8.7.34:
authorAlexey Dejneka <adejneka@comail.ru>
Sat, 31 Jan 2004 17:04:13 +0000 (17:04 +0000)
committerAlexey Dejneka <adejneka@comail.ru>
Sat, 31 Jan 2004 17:04:13 +0000 (17:04 +0000)
        * Make transforms and optimizers for MAX and MIN consistent
          with their definitions.

NEWS
src/code/numbers.lisp
src/compiler/sparc/float.lisp
src/compiler/srctran.lisp
tests/compiler.pure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 5402e4b..77290ed 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2262,6 +2262,8 @@ changes in sbcl-0.8.8 relative to sbcl-0.8.7:
   * optimization: SEARCH on simple-base-strings can now be open-coded.
     (see also contrib/compiler-extras.lisp for inspiration for
     teaching the compiler about the Boyer-Moore algorithm).
+  * value, returned by MAX (and MIN) called with several EQUALP, but
+    not EQL, arguments now does not depend on compiler settings.
   * fixed some bugs revealed by Paul Dietz' test suite:
     ** in stack analysis liveness information is propagated from
        non-local entry points.
index a18b5b9..72e8761 100644 (file)
 
 (defun max (number &rest more-numbers)
   #!+sb-doc
-  "Return the greatest of its arguments."
+  "Return the greatest of its arguments; among EQUALP greatest, return
+the first."
   (do ((nlist more-numbers (cdr nlist))
        (result number))
       ((null nlist) (return result))
 
 (defun min (number &rest more-numbers)
   #!+sb-doc
-  "Return the least of its arguments."
+  "Return the least of its arguments; among EQUALP least, return
+the first."
   (do ((nlist more-numbers (cdr nlist))
        (result number))
       ((null nlist) (return result))
index 5ae9ef2..b96cecc 100644 (file)
 (defun %%min (x y)
   (declare (type (or (unsigned-byte 32) (signed-byte 32)
                     single-float double-float) x y))
-  (if (< x y)
+  (if (<= x y)
       x y))
 
 #+nil
 (defun %%max (x y)
   (declare (type (or (unsigned-byte 32) (signed-byte 32)
                     single-float double-float) x y))
-  (if (> x y)
+  (if (>= x y)
       x y))
 #+nil  
 (macrolet
                                            (lvar-type y)))))))
 
 (defoptimizer (min derive-type) ((x y))
-  (multiple-value-bind (definitely-< definitely->=)
-      (ir1-transform-<-helper x y)
-    (cond (definitely-<
+  (multiple-value-bind (definitely-> definitely-<=)
+      (ir1-transform-<-helper y x)
+    (cond (definitely-<=
              (lvar-type x))
-         (definitely->=
+         (definitely->
              (lvar-type y))
          (t
           (make-canonical-union-type (list (lvar-type x)
                 (arg2 (gensym)))
             `(let ((,arg1 x)
                    (,arg2 y))
-              (if (> ,arg1 ,arg2)
+              (if (>= ,arg1 ,arg2)
                   ,arg1 ,arg2)))))))
 
 (deftransform min ((x y) (real real) *)
                 (arg2 (gensym)))
             `(let ((,arg1 x)
                    (,arg2 y))
-               (if (< ,arg1 ,arg2)
+               (if (<= ,arg1 ,arg2)
                    ,arg1 ,arg2)))))))
 
 ) ; PROGN
index 67c8956..6ba54f8 100644 (file)
     (if (null rest)
        `(values (the real ,arg0))
        `(let ((maxrest (max ,@rest)))
-         (if (> ,arg0 maxrest) ,arg0 maxrest)))))
+         (if (>= ,arg0 maxrest) ,arg0 maxrest)))))
 (define-source-transform min (arg0 &rest rest)
   (once-only ((arg0 arg0))
     (if (null rest)
        `(values (the real ,arg0))
        `(let ((minrest (min ,@rest)))
-         (if (< ,arg0 minrest) ,arg0 minrest)))))
+         (if (<= ,arg0 minrest) ,arg0 minrest)))))
 \f
 ;;;; converting N-arg arithmetic functions
 ;;;;
index eefc810..7240363 100644 (file)
                 'integer)))
         (funcall #'%f12 0))))
    -33)))
+
+;;; Discussion of a CMUCL PCL bug on Sparc with Raymond Toy revealed a
+;;; potential problem: optimizers and type derivers for MAX and MIN
+;;; were not consistent in treating EQUALP, but not EQL, arguments.
+(dolist (f '(min max))
+  (loop for complex-arg-args in '((1d0 2d0) (0d0 1d0))
+        for complex-arg = `(if x ,@complex-arg-args)
+        do
+        (loop for args in `((1 ,complex-arg)
+                            (,complex-arg 1))
+              for form = `(,f ,@args)
+              for f1 = (compile nil `(lambda (x) ,form))
+              and f2 = (compile nil `(lambda (x) (declare (notinline min max))
+                                             ,form))
+              do
+              (dolist (x '(nil t))
+                (assert (eql (funcall f1 x) (funcall f2 x)))))))
index c04b9b0..b2f2a79 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.7.33"
+"0.8.7.34"