Optimizing Compilers for Modern Architectures: A Dependence-Based Approach

In practice, loops in real programs are often much more complicated than the ones used as examples in this chapter so far. For example, to do a good job on dense linear algebra, a transformation system will need to handle loops that contain if statements, triangular and trapezoidal loops, and specialized loop nests such as those found in LU decomposition. This section describes some of the methods for handling such loop nests.
Unfortunately, the strategy for scalar replacement described in Section 8.3 does not extend naturally to conditional code. Consider the following example:
DO I = 1, N5 IF (M(I).LT.0) A(I) = B(I) + C10 D(I) = A(I) + E ENDDO
The true dependence from statement 5 to statement 10 due to the assignment and use of A(I) does not reveal that the assignment to A(I) is conditional. Using only dependence information, a naive scalar replacement scheme might produce the following code:
DO I = 1, N5 IF (M(I).LT.0) THEN a0 = B(I) + C A(I) = a0 ENDIF10 D(I) = a0 + E ...