7.4.3 IPA Example

In the following example, the variable N always has the same value, so the same IF branch will always be taken. This information is hidden behind a subroutine call, however, so KAP normally will not try to perform dead-code elimination to simplify the block IF in the first routine. When the /ipa=setn command qualifier is specified, KAP will inspect the named subroutine for information on the relationship of its arguments and returned value and the surrounding code. Once the CALLed routine is examined, KAP global forward substitution and dead-code elimination transformations (see Chapter 8) can delete the unused code.

If a subroutine or function cannot be inlined, or if you do not want to inline it, it can often still be analyzed for its effects on the calling routine.

The following example was run with the default values for /optimize and /scalaropt :

  CALL SETN ( N )
  IF ( N.GT.10 ) THEN
    X = 1.
  ELSE
    X = 2.
  ENDIF
  ...
  SUBROUTINE SETN (N)
  INTEGER N
  N = 12
  RETURN
  END

The example becomes the following:

  CALL SETN (N)
   X = 1.
  ...

Just the CALL and the simplified IF block were shown.


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