public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "miro.kropacek at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/113779] New: Very inefficient m68k code generated for simple copy loop
Date: Mon, 05 Feb 2024 21:07:56 +0000	[thread overview]
Message-ID: <bug-113779-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113779

            Bug ID: 113779
           Summary: Very inefficient m68k code generated for simple copy
                    loop
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: miro.kropacek at gmail dot com
  Target Milestone: ---

Even as simple loop as this:

void f(const long* src, long* dst, int count) {
        for (int i = 0; i < count; i++) {
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
                *dst++ = *src++;
        }
}

is compiled to:

#NO_APP
        .file   "test.c"
        .text
        .align  2
        .globl  f
        .type   f, @function
f:
        move.l 4(%sp),%a0
        move.l 8(%sp),%a1
        move.l 12(%sp),%d1
        jle .L1
        clr.l %d0
.L3:
        move.l (%a0),(%a1)
        move.l 4(%a0),4(%a1)
        move.l 8(%a0),8(%a1)
        move.l 12(%a0),12(%a1)
        move.l 16(%a0),16(%a1)
        move.l 20(%a0),20(%a1)
        move.l 24(%a0),24(%a1)
        move.l 28(%a0),28(%a1)
        move.l 32(%a0),32(%a1)
        move.l 36(%a0),36(%a1)
        move.l 40(%a0),40(%a1)
        move.l 44(%a0),44(%a1)
        move.l 48(%a0),48(%a1)
        move.l 52(%a0),52(%a1)
        move.l 56(%a0),56(%a1)
        add.w #64,%a0
        add.w #64,%a1
        move.l -4(%a0),-4(%a1)
        addq.l #1,%d0
        cmp.l %d1,%d0
        jne .L3
.L1:
        rts
        .size   f, .-f
        .ident  "GCC: (GNU) 13.2.0"

This has been like this for ages: gcc 4.6.4, gcc 7.2.0 and lately gcc 13.2.0
... the last gcc where it was reported to transform into move.l (a0)+,(a1)+ was
gcc 2.95 and gcc 3.x. 

So what's the catch here? Why gcc hates move.l (ax)+,(ay)+ so much? Tested on
m68k-elf-gcc -O2 -fomit-frame-pointer -m68020-60.

             reply	other threads:[~2024-02-05 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 21:07 miro.kropacek at gmail dot com [this message]
2024-02-05 21:20 ` [Bug target/113779] " pinskia at gcc dot gnu.org
2024-02-06  7:58 ` rguenth at gcc dot gnu.org
2024-02-06  8:16 ` miro.kropacek at gmail dot com
2024-02-06 12:47 ` mikpelinux at gmail dot com
2024-02-06 12:58 ` miro.kropacek at gmail dot com
2024-02-06 13:14 ` rguenth at gcc dot gnu.org
2024-02-17  0:39 ` hp 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-113779-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).