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 switch 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 resulting CALL and the simplified IF block are as follows:
CALL SETN (N) X = 1. ...
Copyright © Digital Equipment Corporation. 1997. All Rights Reserved.