public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu
@ 2013-08-23  5:21 su at cs dot ucdavis.edu
  2013-08-23  7:14 ` [Bug tree-optimization/58223] [4.8/4.9 Regression] " glisse at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-23  5:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58223
           Summary: wrong code at -O3 on x86_64-linux-gnu
           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.8) produces wrong code for the
following testcase on x86_64-linux when compiled at -O3 in both 32-bit and
64-bit modes. This is a regression from 4.7.x.

$ gcc-trunk -v
gcc version 4.9.0 20130822 (experimental) [trunk revision 201915] (GCC) 
$ gcc-4.7 -O3 reduced.c
$ a.out
1
$ gcc-trunk -O2 reduced.c
$ a.out
1
$ gcc-trunk -O3 reduced.c
$ a.out
0
$ gcc-4.8 -O3 reduced.c
$ a.out
0
$ 

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

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

int a[2], b;

int main ()
{
  for (b = 0; b < 2; b++)
    {
      a[0] = 1;
      a[b] = 0;
    }
  printf ("%d\n", a[0]);
  return 0;
}


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2013-08-23  7:14 ` glisse at gcc dot gnu.org
  2013-08-23  7:17 ` mpolacek at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-08-23  7:14 UTC (permalink / raw)
  To: gcc-bugs

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

Marc Glisse <glisse at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-23
            Summary|wrong code at -O3 on        |[4.8/4.9 Regression] wrong
                   |x86_64-linux-gnu            |code at -O3 on
                   |                            |x86_64-linux-gnu
     Ever confirmed|0                           |1

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
ldist pass replaces the a[b]=0 statements with a call to memset after the loop,
apparently missing the aliasing with a[0]=1.


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-08-23  7:14 ` [Bug tree-optimization/58223] [4.8/4.9 Regression] " glisse at gcc dot gnu.org
@ 2013-08-23  7:17 ` mpolacek at gcc dot gnu.org
  2013-08-23  7:31 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-23  7:17 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yep, thus -fno-tree-loop-distribute-patterns is a workaround.


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-08-23  7:14 ` [Bug tree-optimization/58223] [4.8/4.9 Regression] " glisse at gcc dot gnu.org
  2013-08-23  7:17 ` mpolacek at gcc dot gnu.org
@ 2013-08-23  7:31 ` mpolacek at gcc dot gnu.org
  2013-08-23  7:58 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-23  7:31 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.7.3
   Target Milestone|---                         |4.8.3
      Known to fail|                            |4.8.1, 4.9.0


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-08-23  7:31 ` mpolacek at gcc dot gnu.org
@ 2013-08-23  7:58 ` jakub at gcc dot gnu.org
  2013-08-23 14:48 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-23  7:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r188186 .  Richard, can you please have a look?


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2013-08-23  7:58 ` jakub at gcc dot gnu.org
@ 2013-08-23 14:48 ` mpolacek at gcc dot gnu.org
  2013-08-29 12:01 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-23 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Ok, so what happens here is that rdg_build_partitions builds two partitions,
that essentially means we split the loop in the original test case into two
loops:

  for (b = 0; b < 2; b++)
    a[0] = 1;

  for (b = 0; b < 2; b++)
    a[b] = 0;

Now, we go over all partitions and classify_partition them, in both loops we
have only one store and no load, thus we're in
  if (single_store && !single_load)
    {
       ...
    }
condition.  For the first loop we bail out, since const_with_all_bytes_same is
true for 1 and TYPE_MODE for that 1 is not the same as TYPE_MODE for unsigned
char (had the "a" array been of the char type, it would be the same TYPE_MODE).
But for second loop we happily set the PKIND_MEMSET, thus replace it later with
memset.

I don't know much about partitioning, but it seems that we shouldn't split the
loop in the first place.


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2013-08-23 14:48 ` mpolacek at gcc dot gnu.org
@ 2013-08-29 12:01 ` rguenth at gcc dot gnu.org
  2013-08-30  7:48 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-29 12:01 UTC (permalink / raw)
  To: gcc-bugs

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

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 #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.  We indeed shouldn't have split this into two partitions.


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

* [Bug tree-optimization/58223] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2013-08-29 12:01 ` rguenth at gcc dot gnu.org
@ 2013-08-30  7:48 ` rguenth at gcc dot gnu.org
  2013-08-30  7:51 ` [Bug tree-optimization/58223] [4.8 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-30  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Fri Aug 30 07:48:53 2013
New Revision: 202096

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

    PR tree-optimization/58223
    * tree-loop-distribution.c (has_anti_dependence): Rename to ...
    (has_anti_or_output_dependence): ... this and adjust to also
    look for output dependences.
    (mark_nodes_having_upstream_mem_writes): Adjust.
    (rdg_flag_uses): Likewise.

    * gcc.dg/torture/pr58223.c: New testcase.
    * gcc.dg/tree-ssa/ldist-16.c: Flip expected behavior.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr58223.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ldist-16.c
    trunk/gcc/tree-loop-distribution.c


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

* [Bug tree-optimization/58223] [4.8 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (6 preceding siblings ...)
  2013-08-30  7:48 ` rguenth at gcc dot gnu.org
@ 2013-08-30  7:51 ` rguenth at gcc dot gnu.org
  2013-09-09  9:47 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-30  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.9.0
   Target Milestone|4.8.3                       |4.8.2
            Summary|[4.8/4.9 Regression] wrong  |[4.8 Regression] wrong code
                   |code at -O3 on              |at -O3 on x86_64-linux-gnu
                   |x86_64-linux-gnu            |
      Known to fail|4.9.0                       |

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


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

* [Bug tree-optimization/58223] [4.8 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (7 preceding siblings ...)
  2013-08-30  7:51 ` [Bug tree-optimization/58223] [4.8 " rguenth at gcc dot gnu.org
@ 2013-09-09  9:47 ` rguenth at gcc dot gnu.org
  2013-09-09  9:51 ` rguenth at gcc dot gnu.org
  2013-10-15  8:06 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-09-09  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Mon Sep  9 09:47:24 2013
New Revision: 202385

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

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

    PR tree-optimization/58223
    * tree-loop-distribution.c (has_anti_dependence): Rename to ...
    (has_anti_or_output_dependence): ... this and adjust to also
    look for output dependences.
    (mark_nodes_having_upstream_mem_writes): Adjust.
    (rdg_flag_uses): Likewise.

    * gcc.dg/torture/pr58223.c: New testcase.
    * gcc.dg/tree-ssa/ldist-16.c: Flip expected behavior.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58223.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/tree-ssa/ldist-16.c
    branches/gcc-4_8-branch/gcc/tree-loop-distribution.c


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

* [Bug tree-optimization/58223] [4.8 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (8 preceding siblings ...)
  2013-09-09  9:47 ` rguenth at gcc dot gnu.org
@ 2013-09-09  9:51 ` rguenth at gcc dot gnu.org
  2013-10-15  8:06 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-09-09  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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


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

* [Bug tree-optimization/58223] [4.8 Regression] wrong code at -O3 on x86_64-linux-gnu
  2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (9 preceding siblings ...)
  2013-09-09  9:51 ` rguenth at gcc dot gnu.org
@ 2013-10-15  8:06 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-15  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 58732 has been marked as a duplicate of this bug. ***


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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-23  5:21 [Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2013-08-23  7:14 ` [Bug tree-optimization/58223] [4.8/4.9 Regression] " glisse at gcc dot gnu.org
2013-08-23  7:17 ` mpolacek at gcc dot gnu.org
2013-08-23  7:31 ` mpolacek at gcc dot gnu.org
2013-08-23  7:58 ` jakub at gcc dot gnu.org
2013-08-23 14:48 ` mpolacek at gcc dot gnu.org
2013-08-29 12:01 ` rguenth at gcc dot gnu.org
2013-08-30  7:48 ` rguenth at gcc dot gnu.org
2013-08-30  7:51 ` [Bug tree-optimization/58223] [4.8 " rguenth at gcc dot gnu.org
2013-09-09  9:47 ` rguenth at gcc dot gnu.org
2013-09-09  9:51 ` rguenth at gcc dot gnu.org
2013-10-15  8:06 ` 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).