A new ia32 backend
Richard Henderson
rth@cygnus.com
Wed Jun 30 15:43:00 GMT 1999
On Wed, Jun 16, 1999 at 09:37:01PM +0200, Toon Moene wrote:
> > * Reorganize certain forms of (A*B)+(C*D) that occur in multidimensional
> > array access. This will become ((A*B')+(C*D'))*F, where F is a power
> > of two factor in common to B and D. This allows better use of scaled
> > index addressing modes, and generally better GIV combination.
>
> Well, this won't help Fortran inner loops, but it might simplify some
> code in non-inner loops (which get all the integer multiplies moved out
> of the inner loop by invariant code motion).
Actually, it can help some Fortran inner loops. It requires that the
loop access both single and double precision data with the same final
index. Something like
float f[10][10];
double d[10][10];
for (i = 0; i < 10; ++i)
for (j = 0; j < 10; ++j)
res[j] += f[i][j] + d[i][j];
Previously we'd get (loosely)
f' = &f[i];
d' = &d[i];
for (i = 0; i < 10; ++i)
{
f'' = &f'[0];
d'' = &d'[0];
res' = &res[0];
for (j = 0; j < 10; ++j)
{
*res' = *f'' + *d'';
res'++, f''++, d''++;
}
f'++;
d'++;
}
With the rearrangement we're more likely to see f'' and d'' combined:
f' = &f[i];
d' = &d[i];
for (i = 0; i < 10; ++i)
{
res' = &res[0];
for (j = 0; j < 10; ++j)
*res'++ = *(f' + j*4) + *(d' + j*8);
}
Which uses one less register, and needs one less increment in the
inner loop.
r~
More information about the Gcc
mailing list