Optimizing Compilers for Modern Architectures: A Dependence-Based Approach

8.8 Complex Loop Nests

8.8 Complex Loop Nests

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.

8.8.1 Loops with If Statements

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   ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Loop Powered Devices
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.