Intel PXA270 Optimization Manual page 105

Pxa27x processor family
Table of Contents

Advertisement

In the above code, data is read from both arrays a and b, but a and b are not spatially close. Array
merging can place a and b spatially close.
struct {
int a;
int b;
} c;
int ix;
for (i=0; i<NMAX]; i++)
{
ix = c[i].b;
if (c[i].a!= 0)
ix = c[i].a;
do_other_calculations;
}
As an example of rearranging sections in a structure that are frequently written to, refer to this code
sample:
struct employee
struct employee *prev;
struct employee *next;
float Year2DatePay;
float Year2DateTax;
int ssno;
int empid;
float Year2Date401KDed;
float Year2DateOtherDed;
};
In the data structure shown above, the fields Year2DatePay, Year2DateTax, Year2Date401KDed,
and Year2DateOtherDed are likely to change with each pay check. The remaining fields however
change rarely. If the fields are laid out as shown above, assuming that the structure is aligned on a
32-byte boundary, modifications to the Year2Date fields are likely to use two write buffers when
the data is written out to memory. However, the number of write buffers that are commonly used
can be reduced to 1 by rearranging the fields in the above data structure as shown:
struct employee {
struct employee *prev;
struct employee *next;
int ssno;
int empid;
float Year2DatePay;
float Year2DateTax;
float Year2Date401KDed;
float Year2DateOtherDed;
};
Intel® PXA27x Processor Family Optimization Guide
{
High Level Language Optimization
5-7

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pxa271Pxa272Pxa273

Table of Contents