next up previous contents
Next: Loop Unrolling Up: Optimization Strategies for HPJava Previous: Strength Reduction   Contents


Dead Code Elimination

Dead Code Elimination (DCE) [2] is an optimization technique to eliminate some variables not used at all. A variable is useless in a program P if it is dead at all exits from P, and its only use is in a definition of itself. All definitions of a useless variable may be eliminated. Some instructions might have implicit side effects with carelessly applying DCE for high-level languages such as Java. For example,

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
int a = foo() ;\end{verbatim}\end{minipage}
$

and assume that $ a$ only appears in this definition. That is, $ a$ is useless and may be deleted. But, in general, we can't know what happens inside the method call, foo(). An overall construct generates 6 variables outside the loop according to the naive translation scheme. The first 4 variables are called control variables for overall construct. These variables are initialized by methods such as localBlock(), str(), dim(), and restrict(). Since these control variables are often unused, and the methods are specialized methods known to the compiler--side effect free--we don't have any side effects from applying DCE with data flow analysis to them. The next 2 variables are control subscripts. They are useless if the overall has neither integer global index values (e.g. i`) nor shifted indices. The compiler can easily know the uselessness of the control subscripts through applying data flow analysis, and can eliminate them without any side effects. We assume that DCE should be applied after all optimization techniques we discussed earlier. Moreover, we assume we narrow the target of DCE for the HPJava optimization strategy. That is, for the moment, DCE will target only control variables and control scripts for overall constructs.
next up previous contents
Next: Loop Unrolling Up: Optimization Strategies for HPJava Previous: Strength Reduction   Contents
Bryan Carpenter 2004-06-09