public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Michael P. Hayes" <michaelh@ongaonga.chch.cri.nz>
To: egcs@cygnus.com
Subject: Loop optimisation
Date: Tue, 04 Nov 1997 19:30:00 -0000	[thread overview]
Message-ID: <199711050335.QAA19282@ongaonga.chch.cri.nz> (raw)

I've noticed that GCC poorly optimises the following loops:

void foo(const float *src, float *dst, int size, int offset)
{
    int i;

    for (i = 0; i < size; i++)
      dst[i + offset] = src[i];
}

where the loop RTL of interest after CSE is

  (set (reg:SI 43) (plus:SI (reg/v:SI 40) (reg/v:SI 42)))
  (set (reg:SI 44) (plus:SI (reg/v:SI 37) (reg:SI 43)))
  (set (mem/s:SF (reg:SI 44)) (reg:SF 45))

where 40 is i, the induction variable pseudo
      42 is offset
      37 is &dst 

Ideally, the redundant address calculations should be hoisted out of
the loop.  Is this within the scope of the current loop optimiser?

Michael.

                 reply	other threads:[~1997-11-04 19:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=199711050335.QAA19282@ongaonga.chch.cri.nz \
    --to=michaelh@ongaonga.chch.cri.nz \
    --cc=egcs@cygnus.com \
    /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).