0.9.7.4:
authorJuho Snellman <jsnell@iki.fi>
Wed, 30 Nov 2005 01:08:19 +0000 (01:08 +0000)
committerJuho Snellman <jsnell@iki.fi>
Wed, 30 Nov 2005 01:08:19 +0000 (01:08 +0000)
Improve type inference for LOOP arithmetic-for index variables
        that have constant bounds and step (e.g (LOOP FOR I TO 10 ...)).
        Fixes bug 278a.

        * Comment out some code in the LOOP macro that was supposed to
          generate optimized code for constant arithemetic-for, but
          actually pessimized by outsmarting the loop induction variable
          handling.
        * Produces slightly less optimal code (one extra test and jump
          when entering the loop) than the old version in the case where
          sufficient type information is specified manually with an
          OF-TYPE.
        * Remove some fossilized remnants of the loop extension facility.

BUGS
NEWS
src/code/loop.lisp
version.lisp-expr

diff --git a/BUGS b/BUGS
index 24a6847..3512ffe 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -878,17 +878,6 @@ WORKAROUND:
            (1+ *faa*))
      (faa 1d0) => type error
 
-278:
-  a.
-    (defun foo ()
-      (declare (optimize speed))
-      (loop for i of-type (integer 0) from 0 by 2 below 10
-            collect i))
-
-  uses generic arithmetic.
-
-  b. (fixed in 0.8.3.6)
-
 279: type propagation error -- correctly inferred type goes astray?
   In sbcl-0.8.3 and sbcl-0.8.1.47, the warning
        The binding of ABS-FOO is a (VALUES (INTEGER 0 0)
diff --git a/NEWS b/NEWS
index 674b2ee..8c888c7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ changes in sbcl-0.9.8 relative to sbcl-0.9.7:
   * bug fix: FILE-STRING-LENGTH is now external-format sensitive,
     returning the number of octets which would be written to the
     file-stream.  (thanks to Robert J. Macomber)
+  * optimization: improved type inference for arithmetic-for
+    index variables in LOOP
 
 changes in sbcl-0.9.7 relative to sbcl-0.9.6:
   * minor incompatible change: (SETF CLASS-NAME) and (SETF
index 68f1741..101a8df 100644 (file)
@@ -1795,6 +1795,27 @@ code to be loaded.
          (setq step-hack
                `(,variable ,step-hack)))
        (let ((first-test test) (remaining-tests test))
+         ;; As far as I can tell, the effect of the following code is
+         ;; to detect cases where we know statically whether the first
+         ;; iteration of the loop will be executed. Depending on the
+         ;; situation, we can either:
+         ;;  a) save one jump and one comparison per loop (not per iteration)
+         ;;     when it will get executed
+         ;;  b) remove the loop body completely when it won't be executed
+         ;;
+         ;; Noble goals. However, the code generated in case a) will
+         ;; fool the loop induction variable detection, and cause
+         ;; code like (LOOP FOR I TO 10 ...) to use generic addition
+         ;; (bug #278a).
+         ;;
+         ;; Since the gain in case a) is rather minimal and Python is
+         ;; generally smart enough to handle b) without any extra
+         ;; support from the loop macro, I've disabled this code for
+         ;; now. The code and the comment left here in case somebody
+         ;; extends the induction variable bound detection to work
+         ;; with code where the stepping precedes the test.
+         ;; -- JES 2005-11-30
+         #+nil
          (when (and stepby-constantp start-constantp limit-constantp
                     (realp start-value) (realp limit-value))
            (when (setq first-test
@@ -1815,22 +1836,6 @@ code to be loaded.
     '((:from :upfrom :downfrom) (:to :upto :downto :above :below) (:by))
     nil (list (list kwd val)))))
 
-(defun loop-sequence-elements-path (variable data-type prep-phrases
-                                    &key
-                                    fetch-function
-                                    size-function
-                                    sequence-type
-                                    element-type)
-  (multiple-value-bind (indexv) (loop-named-var 'index)
-    (let ((sequencev (loop-named-var 'sequence)))
-      (list* nil nil                            ; dummy bindings and prologue
-             (loop-sequencer
-              indexv 'fixnum
-              variable (or data-type element-type)
-              sequencev sequence-type
-              `(,fetch-function ,sequencev ,indexv)
-              `(,size-function ,sequencev)
-              prep-phrases)))))
 \f
 ;;;; builtin LOOP iteration paths
 
index cab149b..a21db99 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.9.7.3"
+"0.9.7.4"