Optimizing Compilers for Modern Architectures: A Dependence-Based Approach

8.5 Loop Interchange for Register Reuse

8.5 Loop Interchange for Register Reuse

In the material so far, we have not considered the impact of loop order on register reuse. Although most users would write loops that allocate potential reuse to the innermost loop, there are cases where the best loop order is not obvious. For the programmer, the problem is complicated by the need to present the computation clearly. It may also be complicated by interactions with other parts of the memory hierarchy, such as cache (see Chapter 9). Finally, the code being compiled may not be generated by a compiler. Instead it may have come from a preprocessor, such as one that translates Fortran 90 array statements to loops (see Chapter 13).

Consider, for instance, the following loop containing a Fortran 90 vector statement that might be used to initialize a matrix:

    DO I = 2, N       A(1:M, I) = A(1:M, I 1)    ENDDO

The DO-loop "carries" the values in the first column across the entire matrix. As we shall see in Chapter 13, this loop will be converted to a scalar loop as follows:

    DO I = 2, N       DO J = 1, M          A(J,I) = A(J,I 1)       ENDDO    ENDDO

The straightforward implementation will produce

    DO I = 2, N...

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.