[net.lang] what the PSL compiler *really* does

shebs@utah-cs.UUCP (Stanley Shebs) (11/05/85)

In article <2800@hplabsc.UUCP> nielsen@hplabsc.UUCP (Walter Nielsen) writes:

>> 	(for (from i 0 1000000) (do (+ 2 2)))
>
>If you look at the code generated by the PSL compiler, even at the 
>C-macro level (by setting *plap to t), you will see that (+ 2 2)
>never gets evaluated.  You should have gotten a message from the
>compiler to the effect of: 
>   "Value of (WCONST 4) not used, therefore not compiled"
>
>For that matter if you have a function defined as (DE FOO () (EQ 4 (+ 2 2))) 
>and compile it, the resulting function is identical to (DE FOO () T).  
>The reason for being is that the PSL compiler folds constants (i.e. 
>evaluates constant expressions at compile-time) and in the first case 
>does some data-flow analysis to see that the resulting value is never
>used again. 

>Walter

Sloppy me - should have checked on the machine first.  Of course, one
should complicate the code enough to confuse the compiler and keep it
from optimizing everything away;  the following improved test has been run by
me personally in vanilla PSL:

(defun foo () 
  (for (from i 0 100000) 
       (do (setq i (plus 2 i)))))

							stan shebs