[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Undesirable compiler optimizations



In System 78.49, ... microcode 836, on Lisp Machine Twenty-two:

(DEFUN TEST  (X) (INTERN X))
(DEFUN TEST0 (X) (PROG1 (INTERN X)))
(DEFUN TEST1 (X) (PROG1 (INTERN X) NIL))
(DEFUN TEST2 (X) (VALUES (INTERN X)))

All of the above compile to the same code. TEST does not do what I wanted
interpreted or compiled. TEST0, TEST1, and TEST2 all do the right thing
interpreted. TEST0 gives a warning that PROG1 has only one arg; both it
and TEST1 optimize out the PROG1 allowing all three values from INTERN to
fall through. This may or may not be a reasonable optimization. I think it
makes the predictability of number of return values very poor. Certainly
the last case, TEST2, I would have expected could only return one value,
but it is also optimized away and the three values from INTERN are allowed
to fall through. There should be some special form that allows one to really
block out the other return values from a function; probably the VALUES 
optimization above should be removed; saying explicitly (VALUES (INTERN X))
instead of just (INTERN X) seems to me a clear indication that I want only
one value back from the function... 
-kmp