public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7)
@ 2013-10-10 22:52 su at cs dot ucdavis.edu
  2013-10-11  7:52 ` [Bug tree-optimization/58685] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-10-10 22:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58685
           Summary: wrong code at -Os on x86_64-linux-gnu in 64-bit mode
                    (affecting gcc trunk, 4.8, and 4.7)
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk (as well as 4.7 and 4.8) miscompiles the following code
on x86_64-linux at -Os in 64-bit mode. 

This is a regression from 4.6.x. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131010 (experimental) [trunk revision 203390] (GCC) 
$ 
$ gcc-trunk -m64 -O1 small.c; a.out
$ gcc-trunk -m64 -O2 small.c; a.out
$ gcc-trunk -m32 -Os small.c; a.out
$ gcc-4.6 -m64 -Os small.c; a.out
$ 
$ gcc-trunk -m64 -Os small.c; a.out
a.out: :1564818584: H?l$?L?d$?H?-? : Assertion `' failed.
Aborted (core dumped)
$ gcc-4.8 -m64 -Os small.c; a.out
a.out: :2138443464: H?l$?L?d$?H?-? : Assertion `' failed.
Aborted (core dumped)
$ gcc-4.7 -m64 -Os small.c; a.out
a.out: :1796453480: H?l$?L?d$?H?-? : Assertion `' failed.
Aborted (core dumped)
$


---------------------------------

int a, b, c = 1, d, e;
int *f = &e, *g = &e, *i;

void __assert_fail (char *);

void
fn1 ()
{
  if (a)
    i = 0;
}

int
fn2 ()
{
  0 ? (void) 0 : __assert_fail ("");
  for (; d;)
    ;
  return 0;
}

int
fn3 (int *p1)
{
  for (b = 0; b >= 0; b--)
    {
      int *h = &e;
      *h = 0;
      if (*p1)
    continue;
      e = 1;
    }
  fn1 ();
  c ? (void) 0 : __assert_fail ("");
  return 0;
}

int
main ()
{
  fn3 (g);
  fn3 (g);
  if (*f);
  else
    0 ? (void) 0 : __assert_fail ("");
  return 0;
}


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

* [Bug tree-optimization/58685] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7)
  2013-10-10 22:52 [Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7) su at cs dot ucdavis.edu
@ 2013-10-11  7:52 ` rguenth at gcc dot gnu.org
  2013-10-11 10:58 ` mikpelinux at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-11  7:52 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to work|                            |4.6.4
   Target Milestone|---                         |4.7.4
            Summary|wrong code at -Os on        |[4.7/4.8/4.9 Regression]
                   |x86_64-linux-gnu in 64-bit  |wrong code at -Os on
                   |mode (affecting gcc trunk,  |x86_64-linux-gnu in 64-bit
                   |4.8, and 4.7)               |mode (affecting gcc trunk,
                   |                            |4.8, and 4.7)


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

* [Bug tree-optimization/58685] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7)
  2013-10-10 22:52 [Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7) su at cs dot ucdavis.edu
  2013-10-11  7:52 ` [Bug tree-optimization/58685] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
@ 2013-10-11 10:58 ` mikpelinux at gmail dot com
  2013-10-16 14:23 ` [Bug target/58685] " bernds at gcc dot gnu.org
  2013-10-25 10:10 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mikpelinux at gmail dot com @ 2013-10-11 10:58 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernds at gcc dot gnu.org,
                   |                            |mikpelinux at gmail dot com

--- Comment #1 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Started with r179553, -fshrink-wrap introduction and enabling on x86.  Adding
-fno-shrink-wrap avoids the bug.  Author CC:d.

The code generation differences on this test case at this revision show no
control flow changes but some register save/restore changes:

--- pr58685.s-r179552   2013-10-11 12:46:05.717857352 +0200
+++ pr58685.s-r179553   2013-10-11 12:49:52.847494641 +0200
@@ -45,13 +45,11 @@
 fn3:
 .LFB2:
        .cfi_startproc
-       pushq   %r8
-       .cfi_def_cfa_offset 16
        movl    $0, b(%rip)
        jmp     .L7
 .L9:
-       movl    $0, e(%rip)
        cmpl    $0, (%rdi)
+       movl    $0, e(%rip)
        jne     .L8
        movl    $1, e(%rip)
 .L8:
@@ -61,6 +59,8 @@
        movl    b(%rip), %eax
        testl   %eax, %eax
        jns     .L9
+       pushq   %rdi
+       .cfi_def_cfa_offset 16
        xorl    %eax, %eax
        call    fn1
        cmpl    $0, c(%rip)
@@ -81,7 +81,7 @@
 main:
 .LFB3:
        .cfi_startproc
-       pushq   %r10
+       pushq   %r9
        .cfi_def_cfa_offset 16
        movq    g(%rip), %rdi
        call    fn3
@@ -94,7 +94,7 @@
        call    __assert_fail
 .L12:
        xorl    %eax, %eax
-       popq    %r9
+       popq    %r8
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc


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

* [Bug target/58685] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7)
  2013-10-10 22:52 [Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7) su at cs dot ucdavis.edu
  2013-10-11  7:52 ` [Bug tree-optimization/58685] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
  2013-10-11 10:58 ` mikpelinux at gmail dot com
@ 2013-10-16 14:23 ` bernds at gcc dot gnu.org
  2013-10-25 10:10 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: bernds at gcc dot gnu.org @ 2013-10-16 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Schmidt <bernds at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-10-16
           Assignee|unassigned at gcc dot gnu.org      |bernds at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug target/58685] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7)
  2013-10-10 22:52 [Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7) su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-10-16 14:23 ` [Bug target/58685] " bernds at gcc dot gnu.org
@ 2013-10-25 10:10 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-25 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Also fixed by the fix for 58831.

*** This bug has been marked as a duplicate of bug 58831 ***


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

end of thread, other threads:[~2013-10-25 10:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-10 22:52 [Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7) su at cs dot ucdavis.edu
2013-10-11  7:52 ` [Bug tree-optimization/58685] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-11 10:58 ` mikpelinux at gmail dot com
2013-10-16 14:23 ` [Bug target/58685] " bernds at gcc dot gnu.org
2013-10-25 10:10 ` rguenth at gcc dot gnu.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).