public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/42516]  New: [m68k] Suboptimal halfword swap on coldfire
@ 2009-12-27 16:53 nizze86 at hotmail dot com
  2009-12-27 17:19 ` [Bug target/42516] " schwab at linux-m68k dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nizze86 at hotmail dot com @ 2009-12-27 16:53 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-12-30 23:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-27 16:53 [Bug target/42516] New: [m68k] Suboptimal halfword swap on coldfire nizze86 at hotmail dot com
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

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).