Avoiding Loop Rotation By Hand - Analog Devices VISUALDSP++ 3.5 Manual

C/c++ compiler and library for adsp-219x processors
Hide thumbs Also See for VISUALDSP++ 3.5:
Table of Contents

Advertisement

Loop Guidelines
xc = xa + xb; yc = ya + yb;
c[i] = xc; c[i+1] = yc;
}
}
Bad: harder for the compiler to optimize.

Avoiding Loop Rotation by Hand

Tip: Do not rotate loops by hand.
Programmers are often tempted to "rotate" loops in DSP code by "hand"
attempting to execute loads and stores from earlier or future iterations at
the same time as computation from the current iteration. This technique
introduces loop-carried dependencies that prevent the compiler from rear-
ranging the code effectively. However, it is better to give the compiler a
"normalized" version, and leave the rotation to the compiler.
int ss(short *a, short *b, int n) {
int sum = 0;
int i;
for (i = 0; i < n; i++) {
sum += a[i] + b[i];
}
return sum;
}
Good: will be rotated by the compiler.
int ss(short *a, short *b, int n) {
short ta, tb;
int sum = 0;
int i = 0;
ta = a[i]; tb = b[i];
for (i = 1; i < n; i++) {
sum += ta + tb;
ta = a[i]; tb = b[i];
}
sum += ta + tb;
2-18
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
for ADSP-219x DSPs

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?

Questions and answers

Related Products for Analog Devices VISUALDSP++ 3.5

Table of Contents