public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk)
@ 2013-08-27  4:36 su at cs dot ucdavis.edu
  2013-08-27  7:15 ` [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above jakub at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-27  4:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58246
           Summary: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8,
                    and trunk)
           Product: gcc
           Version: unknown
            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 gcc 4.6, 4.7, and 4.8) produces wrong code
for the following testcase on x86_64-linux when compiled at -O1 and above in
both 32-bit and 64-bit modes. 


$ gcc-trunk -v
gcc version 4.9.0 20130826 (experimental) [trunk revision 201986] (GCC) 
$ gcc-trunk -O0 small.c
$ a.out
1
$ gcc-trunk -O1 small.c
$ a.out
0
$ gcc-4.8 -O1 small.c
$ a.out
0
$ gcc-4.7 -O1 small.c
$ a.out
0
$ gcc-4.6 -O1 small.c
$ a.out
0
$ 


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

int printf (const char *, ...);

int a, b; 

int main ()
{
  int t[2] = {1,1};

  for (a = 0; a < 2; a++)
    {
      b ^= t[a];
      t[a] = t[1] = 0;
    }

  printf ("%d\n", b);

  return 0;
}


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

* [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
@ 2013-08-27  7:15 ` jakub at gcc dot gnu.org
  2013-08-27  7:23 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-27  7:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.7.4
            Summary|wrong code at -O1 and above |[4.7/4.8/4.9 Regression]
                   |(affecting 4.6, 4.7, 4.8,   |wrong code at -O1 and above
                   |and trunk)                  |

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


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

* [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
  2013-08-27  7:15 ` [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above jakub at gcc dot gnu.org
@ 2013-08-27  7:23 ` jakub at gcc dot gnu.org
  2013-08-29 10:41 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-27  7:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-27
     Ever confirmed|0                           |1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
We have:
  # .MEM_13 = VDEF <.MEM_11>
  tD.1723[1] = 0;
  # .MEM_15 = VDEF <.MEM_13>
  tD.1723[a.0_6] = 0;
at mergephi1 and cddce1 decides to delete the first of the two stores as needed
for some weird reason:

processing: _8 = t[a.0_6];

marking necessary through .MEM_4 stmt t[1] = 1;
marking necessary through .MEM_3 stmt t[0] = 1;
marking necessary through .MEM_15 stmt t[a.0_6] = 0;
processing: t[a.0_6] = 0;

processing: t[0] = 1;

processing: t[1] = 1;

processing: a = 0;


Eliminating unnecessary statements:
Deleting : t[1] = 0;

Removed 1 of 18 statements (5%)


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

* [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
  2013-08-27  7:15 ` [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above jakub at gcc dot gnu.org
  2013-08-27  7:23 ` jakub at gcc dot gnu.org
@ 2013-08-29 10:41 ` rguenth at gcc dot gnu.org
  2013-08-29 10:58 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-29 10:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.


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

* [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-08-29 10:41 ` rguenth at gcc dot gnu.org
@ 2013-08-29 10:58 ` rguenth at gcc dot gnu.org
  2013-08-29 13:04 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-29 10:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
We decide to stop because we think that we reached a killing definition when
looking for possible defs of

  _8 = t[a.0_6];

and reach, over the loop backedge

  t[a.0_6] = 0;

here:

          /* Or they need to be exactly the same.  */
          else if (ref->ref
                   /* Make sure there is no induction variable involved
                      in the references (gcc.c-torture/execute/pr42142.c).
                      The simplest way is to check if the kill dominates
                      the use.  */
                   && dominated_by_p (CDI_DOMINATORS, (basic_block) data,
                                      gimple_bb (def_stmt))
                   && operand_equal_p (ref->ref, lhs, 0))
            return true;

where the dominance check was supposed to prevent this bug from happening...

I have a fix.


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

* [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2013-08-29 10:58 ` rguenth at gcc dot gnu.org
@ 2013-08-29 13:04 ` rguenth at gcc dot gnu.org
  2013-08-30  7:54 ` [Bug tree-optimization/58246] [4.7/4.8 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-29 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Thu Aug 29 13:04:19 2013
New Revision: 202071

URL: http://gcc.gnu.org/viewcvs?rev=202071&root=gcc&view=rev
Log:
2013-08-29  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/58246
    * tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Properly
    handle the dominance check inside a basic-block.

    * gcc.dg/torture/pr58246.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr58246.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-dce.c


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

* [Bug tree-optimization/58246] [4.7/4.8 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2013-08-29 13:04 ` rguenth at gcc dot gnu.org
@ 2013-08-30  7:54 ` rguenth at gcc dot gnu.org
  2013-09-03 12:18 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-30  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.9.0
            Summary|[4.7/4.8/4.9 Regression]    |[4.7/4.8 Regression] wrong
                   |wrong code at -O1 and above |code at -O1 and above

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.


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

* [Bug tree-optimization/58246] [4.7/4.8 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2013-08-30  7:54 ` [Bug tree-optimization/58246] [4.7/4.8 " rguenth at gcc dot gnu.org
@ 2013-09-03 12:18 ` rguenth at gcc dot gnu.org
  2014-05-07  7:59 ` [Bug tree-optimization/58246] [4.7 " rguenth at gcc dot gnu.org
  2014-05-07  8:00 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-09-03 12:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Sep  3 12:18:34 2013
New Revision: 202217

URL: http://gcc.gnu.org/viewcvs?rev=202217&root=gcc&view=rev
Log:
2013-09-03  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2013-08-29  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/58246
    * tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Properly
    handle the dominance check inside a basic-block.

    * gcc.dg/torture/pr58246.c: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58246.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-ssa-dce.c


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

* [Bug tree-optimization/58246] [4.7 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (6 preceding siblings ...)
  2013-09-03 12:18 ` rguenth at gcc dot gnu.org
@ 2014-05-07  7:59 ` rguenth at gcc dot gnu.org
  2014-05-07  8:00 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-07  7:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
      Known to fail|                            |4.7.3

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

* [Bug tree-optimization/58246] [4.7 Regression] wrong code at -O1 and above
  2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (7 preceding siblings ...)
  2014-05-07  7:59 ` [Bug tree-optimization/58246] [4.7 " rguenth at gcc dot gnu.org
@ 2014-05-07  8:00 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-07  8:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Wed May  7 07:59:26 2014
New Revision: 210141

URL: http://gcc.gnu.org/viewcvs?rev=210141&root=gcc&view=rev
Log:
2014-05-07  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2013-08-29  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/58246
    * tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Properly
    handle the dominance check inside a basic-block.

    * gcc.dg/torture/pr58246.c: New testcase.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr58246.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-ssa-dce.c


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

end of thread, other threads:[~2014-05-07  8:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-27  4:36 [Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
2013-08-27  7:15 ` [Bug tree-optimization/58246] [4.7/4.8/4.9 Regression] wrong code at -O1 and above jakub at gcc dot gnu.org
2013-08-27  7:23 ` jakub at gcc dot gnu.org
2013-08-29 10:41 ` rguenth at gcc dot gnu.org
2013-08-29 10:58 ` rguenth at gcc dot gnu.org
2013-08-29 13:04 ` rguenth at gcc dot gnu.org
2013-08-30  7:54 ` [Bug tree-optimization/58246] [4.7/4.8 " rguenth at gcc dot gnu.org
2013-09-03 12:18 ` rguenth at gcc dot gnu.org
2014-05-07  7:59 ` [Bug tree-optimization/58246] [4.7 " rguenth at gcc dot gnu.org
2014-05-07  8:00 ` 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).