next up previous contents index
Next: Control Optimization Up: Source Optimization Previous: Constant Folding   Contents   Index


Unused Expression Elimination

unused expression elimination dead code elimination

If the value of any expression is not used, and the expression has no side-effects, then it is deleted. As with constant folding, this optimization applies most often when cleaning up after inline expansion and other optimizations. Any function declared anextensions:constant-function is also subject to unused expression elimination.

Note that Python will eliminate parts of unused expressions known to be side-effect free, even if there are other unknown parts. For example:

(let ((a (list (foo) (bar)))) (if t (zow) (raz a)))
becomes:
(progn (foo) (bar)) (zow)



Peter Van Eynde 2001-03-08