public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/20204] New: [4.0 regression] miscompilation of asm-declared registers
@ 2005-02-25 11:46 hp at gcc dot gnu dot org
  2005-02-25 12:10 ` [Bug tree-optimization/20204] " hp at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: hp at gcc dot gnu dot org @ 2005-02-25 11:46 UTC (permalink / raw)
  To: gcc-bugs

Between LAST_UPDATED: "Thu Feb 24 08:05:18 UTC 2005"
and "Thu Feb 24 14:59:24 UTC 2005" I see lots of testsuite regressions.
For GCC, they are (as per Mike Stump's script): 

Tests that now fail, but worked before:

21_strings/basic_string/insert/char/2.cc execution test
21_strings/basic_string/replace/char/3.cc execution test
22_locale/money_get/get/char/14.cc execution test
22_locale/money_get/get/char/6.cc execution test
23_containers/vector/check_construct_destroy.cc execution test
23_containers/vector/invalidation/3.cc execution test
25_algorithms/sort.cc execution test

Tests that now fail, but worked before:

gcc.c-torture/execute/20010124-1.c execution,  -O0
gcc.c-torture/execute/20010124-1.c execution,  -O1
gcc.c-torture/execute/20010124-1.c execution,  -O2
gcc.c-torture/execute/20010124-1.c execution,  -Os

(also failures in newlib sanity tests).
It seems that the cause is that memmove is miscompiled.
Here's a slightly minimized test-case.  Note the use of asm-declared registers:
void *x (void *pdst, const void *psrc, unsigned int pn)
{
  register void *return_dst __asm__ ("r10") = pdst;
  register unsigned char *dst __asm__ ("r13") = pdst;
  register unsigned const char *src __asm__ ("r11") = psrc;
  register int n __asm__ ("r12") = pn;

  if (src < dst && dst < src + n)
    {
      src += n;
      dst += n;
      while (n--)
        *--dst = *--src;
      return return_dst;
    }

  while (n >= 16) n--;

  return return_dst;
}
extern void abort ();
extern void exit (int);
char xx[30] = "abc";
int main (void)
{
  char yy[30] = "aab";

  if (x (xx + 1, xx, 2) != xx + 1 || memcmp (xx, yy, sizeof (yy)) != 0)
    abort ();
  exit (0);
}

The moving while-loop results in this code (pruned;
assembly syntax should be understandable enough knowing that
destinations are to the right):
_x:
        cmp.d $r11,$r10
        bls .L2
        nop
        add.d $r12,$r11
        cmp.d $r11,$r10
        blo .L14
        move.d $r10,$r9

.L2:
        cmpq 15,$r12
        ble .L17
        clear.d $r9

        subq 15,$r12
        addq 1,$r9
.L16:
        cmp.d $r9,$r12
        bne .L16
        addq 1,$r9

.L17:
        ret
        nop
.L14:
        test.d $r12
        beq .L17
        add.d $r12,$r9

.L10:
        subq 1,$r9
        subq 1,$r11
        move.b [$r11],$r13
        cmpq 1,$r12
        beq .L17
        move.b $r13,[$r9]

        subq 1,$r9
        subq 1,$r11
        move.b [$r11],$r13
        cmpq 1,$r12
        bne .L10
        move.b $r13,[$r9]

        ba .L17
        nop
        .size   _x, .-_x

Note the absence of update of R12.

-- 
           Summary: [4.0 regression] miscompilation of asm-declared
                    registers
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: critical
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hp at gcc dot gnu dot org
                CC: dnovillo at gcc dot gnu dot org,gcc-bugs at gcc dot gnu
                    dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: cris-axis-elf


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


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

end of thread, other threads:[~2005-02-25 21:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-25 11:46 [Bug tree-optimization/20204] New: [4.0 regression] miscompilation of asm-declared registers hp at gcc dot gnu dot org
2005-02-25 12:10 ` [Bug tree-optimization/20204] " hp at gcc dot gnu dot org
2005-02-25 12:10 ` hp at gcc dot gnu dot org
2005-02-25 12:33 ` dnovillo at redhat dot com
2005-02-25 12:33 ` hp at gcc dot gnu dot org
2005-02-25 12:37 ` dnovillo at redhat dot com
2005-02-25 18:54 ` dnovillo at gcc dot gnu dot org
2005-02-25 21:20 ` hp at gcc dot gnu dot org
2005-02-25 21:33 ` hp at gcc dot gnu dot org
2005-02-25 21:36 ` hp at gcc dot gnu dot org
2005-02-25 23:03 ` dnovillo at gcc dot gnu dot org
2005-02-26 10:35 ` [Bug tree-optimization/20204] [4.0/4.1 " cvs-commit at gcc dot gnu dot org
2005-02-26 11:23 ` cvs-commit at gcc dot gnu dot org
2005-02-26 11:25 ` dnovillo at gcc dot gnu dot org
2005-02-26 12:02 ` pinskia at gcc dot gnu dot org
2005-02-26 12:56 ` pinskia 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).