public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@cygnus.com>
To: Toon Moene <toon@moene.indiv.nluug.nl>
Cc: egcs@egcs.cygnus.com
Subject: Re: A new ia32 backend
Date: Wed, 30 Jun 1999 15:43:00 -0000	[thread overview]
Message-ID: <19990616140502.B30935@cygnus.com> (raw)
Message-ID: <19990630154300.JxMX7EXM6Qc3htSLjUg5OwdJsZGSFiA0E7u1PO5FqUc@z> (raw)
In-Reply-To: <3767FCDD.105D6019@moene.indiv.nluug.nl>

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~

  reply	other threads:[~1999-06-30 15:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-15 22:47 Richard Henderson
1999-06-16  9:28 ` craig
1999-06-30 15:43   ` craig
1999-06-16 12:37 ` Toon Moene
1999-06-16 14:05   ` Richard Henderson [this message]
1999-06-30 15:43     ` Richard Henderson
1999-06-30 15:43   ` Toon Moene
1999-06-16 12:58 ` Gerald Pfeifer
1999-06-16 14:12   ` Joe Buck
1999-06-30 15:43     ` Joe Buck
1999-06-30 15:43   ` Gerald Pfeifer
1999-06-30 15:43 ` Richard Henderson
1999-06-16  6:35 Norbert Berzen
1999-06-16  6:51 ` craig
1999-06-16  6:54   ` craig
1999-06-16 11:10     ` Richard Henderson
1999-06-30 15:43       ` Richard Henderson
1999-06-30 15:43     ` craig
1999-06-30 15:43   ` craig
1999-06-30 15:43 ` Norbert Berzen
1999-06-18 19:19 Mike Stump
1999-06-27  1:05 ` Richard Henderson
1999-06-30 15:43   ` Richard Henderson
1999-06-30 15:43 ` Mike Stump

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990616140502.B30935@cygnus.com \
    --to=rth@cygnus.com \
    --cc=egcs@egcs.cygnus.com \
    --cc=toon@moene.indiv.nluug.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).