"Paul Werkowski" <[EMAIL PROTECTED]> wrote:

> |
> | Consider the following file to be compiled:
> |
> | (declaim (optimize (speed 3)
> |    (compilation-speed 0)
> |    (safety 0)
> |    (debug 0)))
> |
> | (defun assign (array value)
> |   (declare (type (simple-array fixnum (* *)) array))
> |   (declare (type fixnum value))
> |   (let ((size (array-dimension array 0))) ; don't worry, array is square
> |     (dotimes (i size)
> |       (declare (type fixnum i))
> |       (dotimes (j size)
> | (setf (aref array i j) value)))))
> |
> |
> |         The declaration of i as a fixnum seems to allow CMU-CL to inline
> | some operations on the loop. Otherwise, I would get a message liike this:
> |
>
> <...>
>
> |         But do I really have the right to do so ? The macro expansion of
> | the function indicates that two consecutive declarations for i are issued
> | in that case.
>
> CMUCL inserts the declaration of UNSIGNED-BYTE for each counter,
> meaning not negative integer.

        Sure. But what I was wondering was that if I insert my own
declaration, the macroexpanded code ends up with two different ones (CMU-CL's
one isn't removed) which looks weird. I was wondering if it's even legal.


> | Also, I don't understand why CMU-CL gives me no note at all about the loop
> | on J, which behaves exactly the same.
>
> The compiler notes are about the computation for the actual element offset.
> The sum of two fixnums can be greater than the fixnum range.

        I'm not sure we understood each other: I understand why the compiler
issues the notes, but my question was about the fact that I have two nested
loops (one on I and one on J), but only notes about I.



> If you constrain your SIZE variable to something less than 1/2 max fixnum
> then the notes will go away.

Trying this:

(defun assign (array value)
  (declare (type (simple-array fixnum (* *)) array))
  (declare (type fixnum value))
  (let ((size (the (integer 0 100) (array-dimension array 0))))
    (dotimes (i size)
      (dotimes (j size)
        (setf (aref array i j) value)))))

leads to the same notes about I (and still no note about J).


Thanks.

--
Didier Verna, [EMAIL PROTECTED], http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-BicĂȘtre, France   Fax.+33 (1) 53 14 59 22   [EMAIL PROTECTED]


Reply via email to