5.3.5 C*$* max_invariant_if_growth (0-1000)

When a loop contains an IF statement whose condition does not change from one iteration to another, the same test must be repeated for every iteration. The code can often be made more efficient by floating the IF outside the loop and putting the THEN and ELSE sections into their own loops.

This gets more complicated when there is other code in the loop, because a copy of it must be included in both the THEN and ELSE loops. The C*$* max_invariant_if_growth directive allows you to limit the total additional lines of code generated through invariant-IF restructuring in each program unit.

This can be controlled globally with the /max_invariant_if_growth command qualifier. The maximum amount of additional code generated in a single loop through invariant-IF floating can be limited with the /each_invariant_if_growth qualifier and directive.

This directive is in effect to the end of the routine, or until it is reset by a succeeding directive of the same type, for example:

C*$*each_invariant_if_growth(<integer>)
C*$*max_invariant_if_growth(<integer>)

      DO I = ...

C*$*each_invariant_if_growth(<integer>)
C*$*max_invariant_if_growth(<integer>)

        DO J = ...
C*$*each_invariant_if_growth(<integer>)

C*$*max_invariant_if_growth(<integer>)

          DO K = ...
           section-1
            IF ( ) THEN
             section-2
            ELSE

             section-3
            ENDIF
           section-4

          ENDDO
        ENDDO
      ENDDO

In floating the invariant-IF out of the loop nest, the constraints set by the innermost directives are honored first. If those constraints are satisfied, then the invariant-IF is floated from the inner loop. The middle pair of directives is tested and the invariant-IF will be floated from the middle loop provided that there is no violation of the restrictions established by these directives. The process of floating continues as long as the directive constraints are satisfied.


Previous Page | Next Page | Contents | Index |
Command-Line Qualifiers