next up previous contents index
Next: Type Uncertainty Up: Advanced Compiler Use and Previous: Trace Files and Disassembly   Contents   Index


Efficiency Notes

efficiency notes efficiency tuning

Efficiency notes are messages that warn the user that the compiler has chosen a relatively inefficient implementation for some operation. Usually an efficiency note reflects the compiler's desire for more type information. If the type of the values concerned is known to the programmer, then additional declarations can be used to get a more efficient implementation.

Efficiency notes are controlled by theextensions:inhibit-warnings (see section optimize-declaration) optimization quality. When speed is greater thanextensions:inhibit-warnings, efficiency notes are enabled. Note that this implicitly enables efficiency notes wheneverspeed is increased from its default of 1.

Consider this program with an obscure missing declaration:

(defun eff-note (x y z) (declare (fixnum x y z)) (the fixnum (+ x y z)))
If compiled with (speed 3) (safety 0), this note is given:
In: DEFUN EFF-NOTE (+ X Y Z) ==> (+ (+ X Y) Z) Note: Forced to do inline (signed-byte 32) arithmetic (cost 3). Unable to do inline fixnum arithmetic (cost 2) because: The first argument is a (INTEGER -1073741824 1073741822), not a FIXNUM.
This efficiency note tells us that the result of the intermediate computation (+ x y) is not known to be a fixnum, so the addition of the intermediate sum to z must be done less efficiently. This can be fixed by changing the definition ofeff-note:
(defun eff-note (x y z) (declare (fixnum x y z)) (the fixnum (+ (the fixnum (+ x y)) z)))



Subsections
next up previous contents index
Next: Type Uncertainty Up: Advanced Compiler Use and Previous: Trace Files and Disassembly   Contents   Index
Peter Van Eynde 2001-03-08