[Ecls-list] INCF/1+ and LOOP differences at same OPTIMIZE/SAFETY levels
Matthew Mondor
mm_lists at pulsar-zone.net
Fri Dec 24 06:24:44 UTC 2010
Hello,
I noticed that on -current ECL, using the same OPTIMIZE
SPEED/SAFETY/DEBUG levels
(optimize (speed 3) (safety 1) (debug 1))
When using the LOOP macro with variables known to be FIXNUM, the
increment can be optimized inline using C + directly without further
checks. However, if using INCF or SETF/1+, an explicit call to
ecl_one_plus() is generated, even if the variable is known as a FIXNUM.
Initially, I thought that it was because the compiler could infer the
upper value the variable would reach (in which case it's a great
optimization), but I noticed that even on variables without an upper
bound (i.e. for i of-type fixnum from 0), inline + is also used.
So this made me wonder: is ecl_one_plus() used for safety at that
safety level (1) because of potential wrapping in the INCF/1+ case? If
so, shouldn't LOOP also use ecl_one_plus() at that same safety level?
At SAFETY 0 DEBUG 0 SPEED 3, both INCF and LOOP get inlined, yet the
SETF/1+ case still uses ecl_plus_one().
(Attached is example code and indented C results)
Thanks again,
--
Matt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.lisp
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20101224/b3bf40cf/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.c
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20101224/b3bf40cf/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test2.lisp
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20101224/b3bf40cf/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test2.c
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20101224/b3bf40cf/attachment-0001.c>
More information about the ecl-devel
mailing list