For the most part, the transformations needed to simplify expressions and reduce a program to restricted form are straightforward. For completeness, however, we will outline in some detail the algorithm applied by the current HPJava translator. We should remark that much of the discussion in this section is not very specific to HPJava; similar strategies could be used in other Java preprocessors that need to conservatively simplify expressions, as a pre-requisite to translating some subset of those expressions.
One principle of the HPspmd model is that parts of a program that are written entirely in the base language--not using special HPspmd features--should, as far as practical, be compiled in exactly the same way as if they appeared in a local sequential program. We will take this requirement as a guiding heuristic in defining our transformations. In a rather literal and microcosmic way, we interpret the heuristic to mean that sub-expressions that are pure Java expressions--not involving multiarrays--should, as far as possible, be copied unchanged to the translated program. Ideally the generated Java program should not break up these subexpressions by introducting temporaries. (Necessarily, a ``pure Java'' sub-expression may as a whole be precomputed and stored in a temporary, if it was originally embedded in an expression node that also included special HPJava terms.)
In our scheme certain subexpressions are singled out according to the simplification rules. These are expressions that must be precomputed, to meet the requirements of a subsequent translation phase. In general, if the these subexpressions are precomputed, dependence relations may force some other, ``ordinary'' subexpressions to be precomputed as well.