Loop Guidelines
deal with such code and create hardware loops and pointer induction vari-
ables. However, it does make it more difficult for the compiler to optimize
and may occasionally result in under-optimized code.
The same advice goes for using automatic (local) variables for loop con-
trol. It is easy for a compiler to see that an automatic scalar, whose address
is not taken, may be held in a register during a loop. But it is not as easy
when the variable is a global or a function static. Therefore, code such as
for (i=0; i<globvar; i++)
a[i] = 10;
Bad: may need to reload
may not create a hardware loop if the compiler cannot be sure that the
write into the array
must be re-loaded each time around the loop before performing
globvar
the exit test.
In this circumstance, the programmer can make the compiler's job easier
by writing:
int upper_bound = globvar;
for (i=0; i<upper_bound; i++)
a[i] = 10;
Good: easily becomes hardware loop.
Using the Restrict Qualifier
The
restrict
pointer aliasing ambiguities. Accesses from distinct
do not interfere with each other. The loads and stores in the following
loop
for (i=0; i<100; i++)
a[i] = b[i];
2-22
globvar
does not change the value of the global variable. The
a
qualifier provides one way to help the compiler resolve
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
on every iteration.
restricted
for ADSP-219x DSPs
pointers
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers