public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nizze86 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/42516]  New: [m68k] Suboptimal halfword swap on coldfire
Date: Sun, 27 Dec 2009 16:53:00 -0000	[thread overview]
Message-ID: <bug-42516-15704@http.gcc.gnu.org/bugzilla/> (raw)

When compiling the following function for a coldfire target, such as mcf5249:
(using the following command line m68k-elf-gcc hswap.c -mcpu=5249 -S -O2)
unsigned hswap(unsigned x)
{
    return (x << 16) | (x >> 16);
}

gcc produces:

hswap:
        link.w %fp,#0
        move.l 8(%fp),%d1
        move.l %d1,%d0
        clr.w %d0
        swap %d0
        swap %d1
        clr.w %d1
        or.l %d1,%d0
        unlk %fp
        rts

Optimization level affects only instr ordering.

the same function compiled for 68020
(using the following command line m68k-elf-gcc hswap.c -mcpu=68020 -S -O2)

hswap:
        link.w %fp,#0
        move.l 8(%fp),%d0
        swap %d0
        unlk %fp
        rts

which is valid code for the coldfire target too and much smaller and faster

this is using gcc 4.4.2 configured with 
--enable-languages=c --disable-libssp --with-arch=cf --with-cpu=5249

the same behaviour is present in gcc 3.4.6 too.


-- 
           Summary: [m68k] Suboptimal halfword swap on coldfire
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nizze86 at hotmail dot com
  GCC host triplet: amd64-unknown-linux
GCC target triplet: m68k-elf


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


             reply	other threads:[~2009-12-27 16:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-27 16:53 nizze86 at hotmail dot com [this message]
2009-12-27 17:19 ` [Bug target/42516] " schwab at linux-m68k dot org
2009-12-27 20:05 ` mkuvyrkov at gcc dot gnu dot org
2009-12-30 23:04 ` schwab at gcc dot gnu dot org
2009-12-30 23:05 ` schwab at linux-m68k dot 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-42516-15704@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).