public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux
@ 2013-06-08 19:25 dhazeghi at yahoo dot com
  2013-06-08 20:11 ` [Bug rtl-optimization/57569] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dhazeghi at yahoo dot com @ 2013-06-08 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57569
           Summary: wrong code for struct copy at -O3 on x86_64-linux
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The following code is miscompiled with current gcc-trunk on x86_64-linux at -O3
optimization level in 32-bit mode, outputting garbage (rather than 0).  This is
a regression from 4.7.

$ gcc-trunk -v
gcc version 4.9.0 20130608 (experimental) [trunk revision 199849] (GCC) 
$ gcc-trunk -O2 -m32 reduced.c 
$ ./a.out 
0
$ gcc-4.7 -O3 -m32 reduced.c 
$ ./a.out 
0
$ gcc-trunk -O3 -m32 reduced.c 
$ ./a.out 
134519796
----------------------------
int printf (const char *, ...);

struct S { int f0; } a; 

int b, e, *d = &b, f;

void 
fn1 ()
{
  int **g[9][6];
  int ***h = &g[6][3];
  for (; e < 9; e++) {
    f = 0;
    for (; f < 6; f++)
      g[e][f] = &d;
  }
  ***h = 0;
}

void
fn2 ()
{
  fn1 ();
  struct S c[4][10] = {};
  a = c[3][9];
}

int
main ()
{
  fn2 ();
  printf ("%d\n", a.f0);
  return 0;
}


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

* [Bug rtl-optimization/57569] [4.8/4.9 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
@ 2013-06-08 20:11 ` jakub at gcc dot gnu.org
  2013-06-10 15:22 ` matz at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-06-08 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-06-08
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |matz at gcc dot gnu.org
   Target Milestone|---                         |4.8.2
            Summary|wrong code for struct copy  |[4.8/4.9 Regression] wrong
                   |at -O3 on x86_64-linux      |code for struct copy at -O3
                   |                            |on x86_64-linux
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r188667.


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

* [Bug rtl-optimization/57569] [4.8/4.9 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
  2013-06-08 20:11 ` [Bug rtl-optimization/57569] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
@ 2013-06-10 15:22 ` matz at gcc dot gnu.org
  2013-06-11 14:18 ` matz at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: matz at gcc dot gnu.org @ 2013-06-10 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Michael Matz <matz at gcc dot gnu.org> ---
My guess is that it's again somewhere using the wrong predicate
to test directed rw/wr/ww dependencies.


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

* [Bug rtl-optimization/57569] [4.8/4.9 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
  2013-06-08 20:11 ` [Bug rtl-optimization/57569] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
  2013-06-10 15:22 ` matz at gcc dot gnu.org
@ 2013-06-11 14:18 ` matz at gcc dot gnu.org
  2013-06-16 13:38 ` amylaar at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: matz at gcc dot gnu.org @ 2013-06-11 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Michael Matz <matz at gcc dot gnu.org> ---
It's cse, and it's because it indeed uses the wrong dependence test.
The CSE tables holds values read from memory which are supposed to be
clobbered by following writes, i.e. write-after-read, which has to use
anti_dependence.  This fixes the testcase:

Index: cse.c
===================================================================
--- cse.c       (revision 199694)
+++ cse.c       (working copy)
@@ -1837,7 +1837,7 @@ check_dependence (rtx *x, void *data)
 {
   struct check_dependence_data *d = (struct check_dependence_data *) data;
   if (*x && MEM_P (*x))
-    return canon_true_dependence (d->exp, d->mode, d->addr, *x, NULL_RTX);
+    return anti_dependence (*x, d->exp);
   else
     return 0;
 }


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

* [Bug rtl-optimization/57569] [4.8/4.9 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (2 preceding siblings ...)
  2013-06-11 14:18 ` matz at gcc dot gnu.org
@ 2013-06-16 13:38 ` amylaar at gcc dot gnu.org
  2013-10-16  9:50 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: amylaar at gcc dot gnu.org @ 2013-06-16 13:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amylaar at gcc dot gnu.org

--- Comment #4 from Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> ---
Created attachment 30313
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30313&action=edit
testcase for gcc.dg/torture

This is the testcase adapted to fit into the gcc.dg/torture framework.

On i686-pc-linux-gnu, with svn revision 200126, I see the following results:

PASS: gcc.dg/torture/pr57569.c  -O0  (test for excess errors)
PASS: gcc.dg/torture/pr57569.c  -O0  execution test
PASS: gcc.dg/torture/pr57569.c  -O1  (test for excess errors)
PASS: gcc.dg/torture/pr57569.c  -O1  execution test
PASS: gcc.dg/torture/pr57569.c  -O2  (test for excess errors)
PASS: gcc.dg/torture/pr57569.c  -O2  execution test
PASS: gcc.dg/torture/pr57569.c  -O3 -fomit-frame-pointer  (test for excess
errors)
FAIL: gcc.dg/torture/pr57569.c  -O3 -fomit-frame-pointer  execution test
PASS: gcc.dg/torture/pr57569.c  -O3 -fomit-frame-pointer -funroll-loops  (test
for excess errors)
FAIL: gcc.dg/torture/pr57569.c  -O3 -fomit-frame-pointer -funroll-loops 
execution test
PASS: gcc.dg/torture/pr57569.c  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  (test for excess errors)
FAIL: gcc.dg/torture/pr57569.c  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
PASS: gcc.dg/torture/pr57569.c  -O3 -g  (test for excess errors)
FAIL: gcc.dg/torture/pr57569.c  -O3 -g  execution test
PASS: gcc.dg/torture/pr57569.c  -Os  (test for excess errors)
PASS: gcc.dg/torture/pr57569.c  -Os  execution test
PASS: gcc.dg/torture/pr57569.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  (test for excess errors)
PASS: gcc.dg/torture/pr57569.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
PASS: gcc.dg/torture/pr57569.c  -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)
PASS: gcc.dg/torture/pr57569.c  -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test


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

* [Bug rtl-optimization/57569] [4.8/4.9 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (3 preceding siblings ...)
  2013-06-16 13:38 ` amylaar at gcc dot gnu.org
@ 2013-10-16  9:50 ` jakub at gcc dot gnu.org
  2013-10-30 12:56 ` [Bug rtl-optimization/57569] [4.8 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-16  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.2                       |4.8.3

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.2 has been released.


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

* [Bug rtl-optimization/57569] [4.8 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (4 preceding siblings ...)
  2013-10-16  9:50 ` jakub at gcc dot gnu.org
@ 2013-10-30 12:56 ` rguenth at gcc dot gnu.org
  2014-03-17 15:32 ` wschmidt at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-30 12:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
           Priority|P3                          |P2
      Known to work|                            |4.9.0
            Summary|[4.8/4.9 Regression] wrong  |[4.8 Regression] wrong code
                   |code for struct copy at -O3 |for struct copy at -O3 on
                   |on x86_64-linux             |x86_64-linux
      Known to fail|                            |4.8.2

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar, re-confirmed on the 4.8 branch.


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

* [Bug rtl-optimization/57569] [4.8 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (5 preceding siblings ...)
  2013-10-30 12:56 ` [Bug rtl-optimization/57569] [4.8 " rguenth at gcc dot gnu.org
@ 2014-03-17 15:32 ` wschmidt at gcc dot gnu.org
  2014-05-22  9:02 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2014-03-17 15:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Author: wschmidt
Date: Mon Mar 17 15:31:43 2014
New Revision: 208620

URL: http://gcc.gnu.org/viewcvs?rev=208620&root=gcc&view=rev
Log:
gcc/

2014-03-17  Mikael Pettersson  <mikpelinux@gmail.com>
        Committed by Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    Backport from mainline:

    2013-06-20  Joern Rennecke <joern.rennecke@embecosm.com>

    PR rtl-optimization/57425
    PR rtl-optimization/57569
    * alias.c (write_dependence_p): Remove parameters mem_mode and
    canon_mem_addr.  Add parameters x_mode, x_addr and x_canonicalized.
    Changed all callers.
    (canon_anti_dependence): Get comments and semantics in sync.
    Add parameter mem_canonicalized.  Changed all callers.
    * rtl.h (canon_anti_dependence): Update prototype.

    2013-06-16  Joern Rennecke <joern.rennecke@embecosm.com>

    PR rtl-optimization/57425
    PR rtl-optimization/57569
    * alias.c (write_dependence_p): Add new parameters mem_mode,
    canon_mem_addr and mem_canonicalized.  Change type of writep to bool.
    Changed all callers.
    (canon_anti_dependence): New function.
    * cse.c (check_dependence): Use canon_anti_dependence.
    * cselib.c (cselib_invalidate_mem): Likewise.
    * rtl.h (canon_anti_dependence): Declare.

gcc/testsuite/

2014-03-17  Mikael Pettersson  <mikpelinux@gmail.com>
        Committed by Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    Backport from mainline:

    2013-06-16  Joern Rennecke <joern.rennecke@embecosm.com>

    PR rtl-optimization/57425
    PR rtl-optimization/57569
    * gcc.dg/torture/pr57425-1.c, gcc.dg/torture/pr57425-2.c: New files.
    * gcc.dg/torture/pr57425-3.c, gcc.dg/torture/pr57569.c: Likewise.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr57425-1.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr57425-2.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr57425-3.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr57569.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/alias.c
    branches/gcc-4_8-branch/gcc/cse.c
    branches/gcc-4_8-branch/gcc/cselib.c
    branches/gcc-4_8-branch/gcc/rtl.h
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/57569] [4.8 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (6 preceding siblings ...)
  2014-03-17 15:32 ` wschmidt at gcc dot gnu.org
@ 2014-05-22  9:02 ` rguenth at gcc dot gnu.org
  2014-12-19 13:40 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-22  9:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57569

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.3                       |4.8.4

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 4.8.3 is being released, adjusting target milestone.


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

* [Bug rtl-optimization/57569] [4.8 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (7 preceding siblings ...)
  2014-05-22  9:02 ` rguenth at gcc dot gnu.org
@ 2014-12-19 13:40 ` jakub at gcc dot gnu.org
  2014-12-20 13:51 ` mikpelinux at gmail dot com
  2014-12-20 15:54 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57569

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.4                       |4.8.5

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.


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

* [Bug rtl-optimization/57569] [4.8 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (8 preceding siblings ...)
  2014-12-19 13:40 ` jakub at gcc dot gnu.org
@ 2014-12-20 13:51 ` mikpelinux at gmail dot com
  2014-12-20 15:54 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: mikpelinux at gmail dot com @ 2014-12-20 13:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57569

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpelinux at gmail dot com

--- Comment #10 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Please close this one, it was fixed for 4.8.3 by r208620.


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

* [Bug rtl-optimization/57569] [4.8 Regression] wrong code for struct copy at -O3 on x86_64-linux
  2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
                   ` (9 preceding siblings ...)
  2014-12-20 13:51 ` mikpelinux at gmail dot com
@ 2014-12-20 15:54 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-20 15:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57569

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
.


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

end of thread, other threads:[~2014-12-20 15:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-08 19:25 [Bug rtl-optimization/57569] New: wrong code for struct copy at -O3 on x86_64-linux dhazeghi at yahoo dot com
2013-06-08 20:11 ` [Bug rtl-optimization/57569] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
2013-06-10 15:22 ` matz at gcc dot gnu.org
2013-06-11 14:18 ` matz at gcc dot gnu.org
2013-06-16 13:38 ` amylaar at gcc dot gnu.org
2013-10-16  9:50 ` jakub at gcc dot gnu.org
2013-10-30 12:56 ` [Bug rtl-optimization/57569] [4.8 " rguenth at gcc dot gnu.org
2014-03-17 15:32 ` wschmidt at gcc dot gnu.org
2014-05-22  9:02 ` rguenth at gcc dot gnu.org
2014-12-19 13:40 ` jakub at gcc dot gnu.org
2014-12-20 13:51 ` mikpelinux at gmail dot com
2014-12-20 15:54 ` jakub 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).