KAP can delete unused lines or sections of code from the transformed code. This can speed up a program by eliminating unnecessary operations and by not using valuable cache space for unused instructions or data. The dead-code eliminations are as follows:
Examples of dead-code eliminations are as follows:
GO TO 10 X = 2 <-- unreachable assignment removed 10 Y = 13
DO 20 I = 10, 2 <-- zero trip DO ... 20 CONTINUE
PARAMETER( N = 12 ) ... IF (N .GT. 10) THEN X = 1. ELSE X = 2. ENDIF
Is transformed to:
PARAMETER( N = 12 ) ... X = 1.
The true branch will always be taken.
KAP performs lifetime analysis to determine the reaching
definitions of variables and removes unused definitions,
subject to overriding factors such as variables involved in
SAVE, EXTERNAL, and COMMON statements, and so on. The
/scalaropt
> 2 qualifier is required.
Y = 5 <-- no subsequent use of Y X = 3 <-- redefinition of X X = 4 PRINT*, X END
The full effect of dead-code elimination is realized when combined with other optimizations such as subprogram inlining and forward substitution, which help in exposing useless or unreachable code.