Greetings, and thanks! (incf x) goes to (let ((g 1)) (+ x g)), so the setq is effectively (setq x (the fixnum (let ((g 1)) (+ x g)))). Here, as we do not yet hav reverse type propagation, the + appears to overflow the fixnum range and proceeds more slowly. Replacing fixnum with e.g. seqind removes the issue. But perhaps the best is to avoid the let binding when the increment is constant.
Take care, Robert Boyer <[EMAIL PROTECTED]> writes: > I think that the following transcript shows that sometimes, incf is an order > of magnitude slower than it can and ought to be. No idea why. Perhaps I > just am uninformed about the meaning of incf. > > Bob > > ------------------------------------------------------------------------------- > GCL (GNU Common Lisp) 2.7.0 ANSI Apr 1 2006 15:10:32 > >(defun foo () (let ((x 0)) (declare (fixnum x)) (loop while (< x 100000000) > >do (incf x)))) > FOO > >(compile 'foo) > NIL > >(time (foo)) > real time : 1.880 secs > run-gbc time : 1.880 secs > child run time : 0.000 secs > gbc time : 0.000 secs > NIL > >(defun foo () (let ((x 0)) (declare (fixnum x)) (loop while (< x 100000000) > >do (setq x (+ x 1))))) > FOO > >(compile 'foo) > NIL > >(time (foo)) > real time : 0.110 secs > run-gbc time : 0.100 secs > child run time : 0.000 secs > gbc time : 0.000 secs > NIL > > > -- Camm Maguire [EMAIL PROTECTED] ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah _______________________________________________ Gcl-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gcl-devel
