0.6.12.61:
authorWilliam Harold Newman <william.newman@airmail.net>
Wed, 1 Aug 2001 18:02:29 +0000 (18:02 +0000)
committerWilliam Harold Newman <william.newman@airmail.net>
Wed, 1 Aug 2001 18:02:29 +0000 (18:02 +0000)
copied transforms for TRUNCATE, FLOOR, and CEILING from
CMU CL 18c. (Like various other efficiency fixes,
they're in contrib/compiler-extras.lisp instead
of the main system. My plan is to merge all the
contrib/*-extra.lisp stuff into the main system
in version 0.7.x.)

contrib/compiler-extras.lisp
version.lisp-expr

index d04a308..82c96be 100644 (file)
   (check-inlineability-of-find-position-if sequence from-end)
   '(%find-position-vector-macro item sequence
                                from-end start end key test))
+\f
+^L
+;;;; optimizations for floating point FLOOR, CEILING, TRUNCATE, and
+;;;; ROUND, lifted from CMU CL 18c
+;;;;
+;;;; (Without these optimizations, these functions cons!)
+
+;; Convert (TRUNCATE x y) to the obvious implementation.  We only want
+;; this when under certain conditions and let the generic TRUNCATE
+;; handle the rest.  (Note: if Y = 1, the divide and multiply by Y
+;; should be removed by other DEFTRANSFORMs.)
+
+(deftransform truncate ((x &optional y)
+                        (float &optional (or float integer)))
+  '(let ((res (%unary-truncate (/ x y))))
+     (values res (- x (* y res)))))
+
+(deftransform floor ((number &optional divisor)
+                     (float &optional (or integer float)))
+  '(multiple-value-bind (tru rem) (truncate number divisor)
+    (if (and (not (zerop rem))
+             (if (minusp divisor)
+                 (plusp number)
+                 (minusp number)))
+        (values (1- tru) (+ rem divisor))
+        (values tru rem))))
+
+(deftransform ceiling ((number &optional divisor)
+                       (float &optional (or integer float)))
+  '(multiple-value-bind (tru rem) (truncate number divisor)
+    (if (and (not (zerop rem))
+             (if (minusp divisor)
+                 (minusp number)
+                 (plusp number)))
+        (values (1+ tru) (- rem divisor))
+        (values tru rem))))
index 2400f6d..6ab2baf 100644 (file)
@@ -16,4 +16,4 @@
 ;;; four numeric fields, is used for versions which aren't released
 ;;; but correspond only to CVS tags or snapshots.
 
-"0.6.12.60"
+"0.6.12.61"