AMD Athlon Processor x86 Optimization Manual page 35

X86 code optimization
Table of Contents

Advertisement

22007E/0—November 1999
Avoid Unnecessary Store-to-Load Dependencies
code in a way that avoids the store-to-load dependency. In some
instances the language definition may prohibit the compiler
from using code transformations that would remove the store-
to-load dependency. It is therefore recommended that the
programmer remove the dependency manually, e.g., by
introducing a temporary variable that can be kept in a register.
This can result in a significant performance increase. The
following is an example of this.
Example 1 (Avoid):
double x[VECLEN], y[VECLEN], z[VECLEN];
unsigned int k;
for (k = 1; k < VECLEN; k++) {
x[k] = x[k-1] + y[k];
}
for (k = 1; k < VECLEN; k++) {
x[k] = z[k] * (y[k] - x[k-1]);
}
Example 2 (Preferred):
double x[VECLEN], y[VECLEN], z[VECLEN];
unsigned int k;
double t;
t = x[0];
for (k = 1; k < VECLEN; k++) {
t = t + y[k];
x[k] = t;
}
t = x[0];
for (k = 1; k < VECLEN; k++) {
t = z[k] * (y[k] - t);
x[k] = t;
}
AMD Athlon™ Processor x86 Code Optimization
19

Advertisement

Table of Contents
loading

Table of Contents