public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/42863]  New: [4.5] Regression whith auto increments
@ 2010-01-25 19:34 gcc-bugzilla at gcc dot gnu dot org
  2010-01-25 19:45 ` [Bug middle-end/42863] " schwab at linux-m68k dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2010-01-25 19:34 UTC (permalink / raw)
  To: gcc-bugs


This is a general m68k code generation regression. Starting with revision
150588 GCC for m68k generates "surprising" code for auto increments, eg.
for a strlcpy implementation. Compiling this code with the 4.5.0 snapshot
from 20100107 yields:

-- 4.5.0 --
_strlcpy:
        movel d3,sp@-
        movel d2,sp@-
        movel sp@(16),d0
        movel sp@(20),d1
        jeq L7
        movel d0,a0
        movel sp@(12),a1
L3:
        movel a0,d2
        subql #1,d1
        jeq L11
        moveb a0@+,d2
        moveb d2,a1@+
        movel a0,d3 | <--
        tstb d2     | <--
        jne L3
L4:
        subl d3,d0
        notl d0
        movel sp@+,d2
        movel sp@+,d3
        rts
L7:
        movel d0,d2
        movel d2,a0
L6:
        moveb a0@+,d1
        movel a0,d3 | <--
        tstb d1     | <--
        jeq L4
        moveb a0@+,d1
        movel a0,d3 | <--
        tstb d1     | <--
        jne L6
        jra L4
L11:
        clrb a1@
        movel d2,a0
        jra L6
-- cut --

Suddenly GCC inserts "useless" moves and because of these moves has also
to generate explicit tst instructions. Older GCC versions generated better
code by using tst.b incrementing an address register without extra move
instructions, i.e. 4.4.0:

-- 4.4.0 (release) --
_strlcpy:
        movel d2,sp@-
        movel sp@(8),a1
        movel sp@(12),d0
        movel sp@(16),d1
        jne L2
        movel d0,a0
L8:
        tstb a0@+
        jne L8
L5:
        subl a0,d0
        notl d0
        movel sp@+,d2
        rts
L2:
        movel d0,a0
        subql #1,d1
        jeq L11
L6:
        moveb a0@+,d2
        moveb d2,a1@
        jeq L5
        addql #1,a1
        subql #1,d1
        jne L6
L11:
        clrb a1@
        tstb a0@+
        jne L8
        jra L5
-- cut --

Environment:
System: FreeBSD 6.3-STABLE #0: Sat Mar 1 11:12:32 CET 2008
root@sirius:/usr/obj/usr/src/sys/SIRIUS i386

host: i386-unknown-freebsd6.3
build: i386-unknown-freebsd6.3
target: m68k-unknown-amigaos
configured with: ../gcc-4.5-gg/configure --disable-nls --disable-libssp
--enable-languages=c --with-gmp=/usr/local --disable-tls --target=m68k-amigaos

How-To-Repeat:
Compiling the following code with

  gcc-4.5.0 -O2 -fomit-frame-pointer strlcpy.c -o -

demonstrates the problem. FWIW, m68k-elf exhibits the very same problem!

-- cut --
typedef unsigned long size_t;
size_t
strlcpy(char *dst, const char *src, size_t n)
{ const char *s = src;
  if (n) {
    while (--n)
      if ((*dst++ = *s++) == '\0')
        goto out;
    *dst = '\0';
  }
  while (*s++ != '\0')
    continue;
out:
   return ~(src - s);
}
-- cut --


------- Comment #1 from gnikl at users dot sourceforge dot net  2010-01-25 19:34 -------
Fix:
Reverting rev 150588 restores the previous behaviour.


-- 
           Summary: [4.5] Regression whith auto increments
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gnikl at users dot sourceforge dot net
 GCC build triplet: i386-unknown-freebsd6.3
  GCC host triplet: i386-unknown-freebsd6.3
GCC target triplet: m68k-unknown-amigaos


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


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

* [Bug middle-end/42863] [4.5] Regression whith auto increments
  2010-01-25 19:34 [Bug middle-end/42863] New: [4.5] Regression whith auto increments gcc-bugzilla at gcc dot gnu dot org
@ 2010-01-25 19:45 ` schwab at linux-m68k dot org
  2010-01-26 12:10 ` [Bug rtl-optimization/42863] [4.5 Regression] with " rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: schwab at linux-m68k dot org @ 2010-01-25 19:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from schwab at linux-m68k dot org  2010-01-25 19:44 -------
m68k-unknown-amigaos is not a valid target.


-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i386-unknown-freebsd6.3     |
   GCC host triplet|i386-unknown-freebsd6.3     |
 GCC target triplet|m68k-unknown-amigaos        |m68k-elf


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


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

* [Bug rtl-optimization/42863] [4.5 Regression] with auto increments
  2010-01-25 19:34 [Bug middle-end/42863] New: [4.5] Regression whith auto increments gcc-bugzilla at gcc dot gnu dot org
  2010-01-25 19:45 ` [Bug middle-end/42863] " schwab at linux-m68k dot org
@ 2010-01-26 12:10 ` rguenth at gcc dot gnu dot org
  2010-04-06 11:39 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-26 12:10 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |rtl-optimization
           Keywords|                            |missed-optimization
           Priority|P3                          |P4
            Summary|[4.5] Regression with auto  |[4.5 Regression] with auto
                   |increments                  |increments
   Target Milestone|---                         |4.5.0


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


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

* [Bug rtl-optimization/42863] [4.5 Regression] with auto increments
  2010-01-25 19:34 [Bug middle-end/42863] New: [4.5] Regression whith auto increments gcc-bugzilla at gcc dot gnu dot org
  2010-01-25 19:45 ` [Bug middle-end/42863] " schwab at linux-m68k dot org
  2010-01-26 12:10 ` [Bug rtl-optimization/42863] [4.5 Regression] with " rguenth at gcc dot gnu dot org
@ 2010-04-06 11:39 ` rguenth at gcc dot gnu dot org
  2010-04-07 23:50 ` [Bug rtl-optimization/42863] [4.5/4.6 " hp at gcc dot gnu dot org
  2010-07-31  9:33 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-06 11:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2010-04-06 11:20 -------
GCC 4.5.0 is being released.  Deferring to 4.5.1.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.5.0                       |4.5.1


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


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

* [Bug rtl-optimization/42863] [4.5/4.6 Regression] with auto increments
  2010-01-25 19:34 [Bug middle-end/42863] New: [4.5] Regression whith auto increments gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-04-06 11:39 ` rguenth at gcc dot gnu dot org
@ 2010-04-07 23:50 ` hp at gcc dot gnu dot org
  2010-07-31  9:33 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: hp at gcc dot gnu dot org @ 2010-04-07 23:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hp at gcc dot gnu dot org  2010-04-07 23:50 -------
FWIW, I see similar "useless" register moves for cris-elf (also an
autoincrement port with cc0) on trunk r158090 and 4.5-branch r158099, that
aren't there on the 4.4 branch r158082 (with no changes that matter in
r158096).  JFTR, the cc0-clobbering ones are moved by the delayed-branch pass,
but that doesn't matter to m68k. :)


-- 

hp at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hp at gcc dot gnu dot org


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


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

* [Bug rtl-optimization/42863] [4.5/4.6 Regression] with auto increments
  2010-01-25 19:34 [Bug middle-end/42863] New: [4.5] Regression whith auto increments gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-04-07 23:50 ` [Bug rtl-optimization/42863] [4.5/4.6 " hp at gcc dot gnu dot org
@ 2010-07-31  9:33 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-31  9:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-07-31 09:29 -------
GCC 4.5.1 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.5.1                       |4.5.2


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


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

end of thread, other threads:[~2010-07-31  9:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-25 19:34 [Bug middle-end/42863] New: [4.5] Regression whith auto increments gcc-bugzilla at gcc dot gnu dot org
2010-01-25 19:45 ` [Bug middle-end/42863] " schwab at linux-m68k dot org
2010-01-26 12:10 ` [Bug rtl-optimization/42863] [4.5 Regression] with " rguenth at gcc dot gnu dot org
2010-04-06 11:39 ` rguenth at gcc dot gnu dot org
2010-04-07 23:50 ` [Bug rtl-optimization/42863] [4.5/4.6 " hp at gcc dot gnu dot org
2010-07-31  9:33 ` rguenth at gcc dot gnu 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).