The C*$* assert permutation
assertion provides KAP
with sufficient information to allow KAP to generate optimized code
for certain types of indirect addressing (INTEGER arrays used in
subscripts). This assertion requires -optimize=4
or higher. The following shows an example where it is unsafe to
optimize a DO loop:
DO 100 I = 1,N A(IP (I)) = A(IP (I)) + B(I) 100 CONTINUE
KAP cannot safely generate optimized code, because it cannot tell
if the different values in the index array IP
overlap.
If all values in IP
are distinct, the optimized code
is correct; if some of the values are the same, the optimized
code may be unsafe. You can tell KAP that the values in the index
array IP
are all distinct with the C*$* assert
permutation
, as follows:
C*$* ASSERT PERMUTATION( IP ) DO 100 I=1,N A(IP (I)) = A(IP (I)) + B(I) 100 CONTINUE
With the addition of this assertion, KAP knows that it can safely
generate optimized code for this loop. If at run time the values of
IP
are not distinct, the optimized code may generate
incorrect results.