public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/55190] New: [SH] ivopts causes loop setup bloat
Date: Sat, 03 Nov 2012 12:16:00 -0000	[thread overview]
Message-ID: <bug-55190-4@http.gcc.gnu.org/bugzilla/> (raw)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55190

             Bug #: 55190
           Summary: [SH] ivopts causes loop setup bloat
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: olegendo@gcc.gnu.org
            Target: sh*-*-*


The following code:

struct X
{
  int a, b, c, d, e;
};

int test (X* x, unsigned int c)
{
  int s = 0;
  unsigned int i;
  for (i = 0; i < c; ++i)
    s += x[i].b;
  return s;
}

results in:
        tst     r5,r5
        bt/s    .L4
        mov     r5,r1
        shll2   r1
        add     r5,r1
        mov.l   .L9,r2
        shll2   r1
        add     #-20,r1
        shlr2   r1
        mul.l   r2,r1
        mov.l   .L10,r2
        add     #4,r4
        mov     #0,r0
        sts     macl,r1
        and     r2,r1
        add     #1,r1
.L3:
        mov.l   @r4,r2
        dt      r1
        add     #20,r4
        bf/s    .L3
        add     r2,r0
        rts
        nop
.L4:
        rts
        mov     #0,r0
.L11:
        .align 2
.L9:
        .long   214748365
.L10:
        .long   1073741823

In such cases, the loop counter setup code that seems to be produced by ivopts
can be left out, which would result in something like:

        tst     r5,r5
        bt/s    .L15
        add     #4,r4
        mov     #0,r0
.L14:
        mov.l   @r4,r1
        dt      r5
        add     #20,r4
        bf/s    .L14
        add     r1,r0
        rts
        nop
.L15:
        rts
        mov     #0,r0


             reply	other threads:[~2012-11-03 12:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-03 12:16 olegendo at gcc dot gnu.org [this message]
2013-02-16 11:13 ` [Bug target/55190] " olegendo at gcc dot gnu.org
2013-06-17  0:13 ` [Bug rtl-optimization/55190] " olegendo at gcc dot gnu.org
2013-09-30  7:16 ` amker.cheng at gmail dot com
2013-10-03 10:00 ` olegendo at gcc dot gnu.org
2014-07-31 18:03 ` olegendo at gcc dot gnu.org
2015-04-04 11:46 ` olegendo at gcc dot gnu.org
2015-04-07  7:27 ` [Bug rtl-optimization/55190] " olegendo at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2023-07-07  6:49 ` olegendo at gcc dot gnu.org

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=bug-55190-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).