An example of a loop-carried dependence chain is shown in
Example 2-17.
Example 2-17 An Example of Loop-carried Dependence Chain
for (i=0; i<MAX; i++) {
a[i] = b[i] * foo;
foo = a[i]/3;
}
Data Layout Optimizations
User/Source Coding Rule 2. (H impact, M generality) Pad data structures
defined in the source code so that every data element is aligned to a natural
operand size address boundary.
If the operands are packed in a SIMD instruction, align to the packed
element size (64-bit or 128-bit).
Align data by providing padding inside structures and arrays.
Programmers can reorganize structures and arrays to minimize the
amount of memory wasted by padding. However, compilers might not
have this freedom. The C programming language, for example, specifies
the order in which structure elements are allocated in memory. Section
"Stack and Data Alignment" of Chapter 3, and Appendix D, "Stack
Alignment", further defines the exact storage layout.
Example 2-18 shows how a data structure could be rearranged to reduce
its size.
Example 2-18 Rearranging a Data Structure
struct unpacked { /* fits in 20 bytes due to padding */
int
char
int
char
int
}
struct packed {
// foo is a loop-carried dependence
a;
b;
c;
d;
e;
/* fits in 16 bytes */
General Optimization Guidelines
2
2-39
Need help?
Do you have a question about the ARCHITECTURE IA-32 and is the answer not in the manual?