8.2.6 Invariant-IF Restructuring

KAP recognizes loops with invariant-IFs. To avoid repeatedly performing the same IF test, KAP generates two versions of the loop and places the IF test outside, as shown in the following example:

DO 1 I=1,N
IF (ADD) THEN
X(I) = X(I) + Y(I)
ELSE
X(I) = X(I) - Y(I)
ENDIF
1  CONTINUE
10 CONTINUE

Becomes:

IF (ADD) THEN
DO 3 I=1,N
X(I) = X(I) + Y(I)
3   CONTINUE
ELSE
DO 4 I=1,N
X(I) = X(I) - Y(I)
4    CONTINUE
ENDIF

This transformation is enabled only when -scalaropt >2. See the command switches -each_invariant_if_growth and -max_invariant_if_growth for ways to restrict this transformation.


Previous Page | Next Page | Contents | Index |
Command Line Switches