public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk)
@ 2013-08-29 23:30 su at cs dot ucdavis.edu
  2013-08-29 23:31 ` [Bug tree-optimization/58277] " su at cs dot ucdavis.edu
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-29 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58277
           Summary: wrong code at -O3 (affecting 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.7 and 4.8) produces wrong code for the
attached testcase on x86_64-linux when compiled at -O3 in 32-bit mode. It is a
regression from 4.6.x.  

This one has been quite nasty to reduce; the attached testcase is the simplest
I was able to get. I believe it doesn't have any undefined behavior. 


$ 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
--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 20130829 (experimental) [trunk revision 202067] (GCC) 
$ gcc-trunk -m32 -O2 small.c
$ a.out
0
$ gcc-4.6 -m32 -O3 small.c
$ a.out
0
$ gcc-trunk -m32 -O3 small.c
$ a.out
0
Aborted (core dumped)
$ gcc-4.7 -m32 -O3 small.c
$ a.out
0
Aborted (core dumped)
$ gcc-4.8 -m32 -O3 small.c
$ a.out
0
Aborted (core dumped)
$


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

* [Bug tree-optimization/58277] wrong code at -O3 (affecting 4.7, 4.8, and trunk)
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
@ 2013-08-29 23:31 ` su at cs dot ucdavis.edu
  2013-08-29 23:39 ` su at cs dot ucdavis.edu
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-29 23:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> ---
Created attachment 30725
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30725&action=edit
testcase


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

* [Bug tree-optimization/58277] wrong code at -O3 (affecting 4.7, 4.8, and trunk)
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
  2013-08-29 23:31 ` [Bug tree-optimization/58277] " su at cs dot ucdavis.edu
@ 2013-08-29 23:39 ` su at cs dot ucdavis.edu
  2013-08-29 23:40 ` su at cs dot ucdavis.edu
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-29 23:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zhendong Su <su at cs dot ucdavis.edu> ---
I'm also attaching a related testcase (small2.c) for both 32-bit and 64-bit
modes. 

$ gcc-trunk -m64 -O2 small2.c
$ a.out
$ gcc-4.6 -m64 -O3 small2.c
$ a.out
$ gcc-4.7 -m64 -O3 small2.c
$ a.out
Aborted (core dumped)
$ gcc-4.8 -m64 -O3 small2.c
$ a.out
Aborted (core dumped)
$ gcc-trunk -m64 -O3 small2.c
$ a.out
Aborted (core dumped)
$


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

* [Bug tree-optimization/58277] wrong code at -O3 (affecting 4.7, 4.8, and trunk)
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
  2013-08-29 23:31 ` [Bug tree-optimization/58277] " su at cs dot ucdavis.edu
  2013-08-29 23:39 ` su at cs dot ucdavis.edu
@ 2013-08-29 23:40 ` su at cs dot ucdavis.edu
  2013-08-30  7:39 ` [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3 jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-29 23:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
Created attachment 30726
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30726&action=edit
another testcase for both 32-bit and 64-bit modes


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

* [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-08-29 23:40 ` su at cs dot ucdavis.edu
@ 2013-08-30  7:39 ` jakub at gcc dot gnu.org
  2013-08-30  8:00 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-30  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

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 -O3           |[4.7/4.8/4.9 Regression]
                   |(affecting 4.7, 4.8, and    |wrong code at -O3
                   |trunk)                      |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Both testcases started to fail with r181172.


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

* [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2013-08-30  7:39 ` [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3 jakub at gcc dot gnu.org
@ 2013-08-30  8:00 ` mpolacek at gcc dot gnu.org
  2013-08-30  8:02 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-30  8:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-30
                 CC|                            |matz at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thus confirmed.


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

* [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2013-08-30  8:00 ` mpolacek at gcc dot gnu.org
@ 2013-08-30  8:02 ` jakub at gcc dot gnu.org
  2013-08-30  9:31 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-30  8:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But, skimming through the dumps, it looks like it is the strlen pass that
removes the important n = 0; store.


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

* [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2013-08-30  8:02 ` jakub at gcc dot gnu.org
@ 2013-08-30  9:31 ` jakub at gcc dot gnu.org
  2013-08-30 12:41 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-30  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30728
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30728&action=edit
gcc49-pr58277.patch

Untested fix.


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

* [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (6 preceding siblings ...)
  2013-08-30  9:31 ` jakub at gcc dot gnu.org
@ 2013-08-30 12:41 ` jakub at gcc dot gnu.org
  2013-08-30 12:53 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-30 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Aug 30 12:41:17 2013
New Revision: 202104

URL: http://gcc.gnu.org/viewcvs?rev=202104&root=gcc&view=rev
Log:
    PR tree-optimization/58277
    * tree-ssa-strlen.c (strlen_enter_block): If do_invalidate gave up
    after seeing too many stmts with vdef in between dombb and current
    bb, invalidate everything.

    * gcc.c-torture/execute/pr58277-1.c: New test.
    * gcc.c-torture/execute/pr58277-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr58277-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-strlen.c


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

* [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (7 preceding siblings ...)
  2013-08-30 12:41 ` jakub at gcc dot gnu.org
@ 2013-08-30 12:53 ` jakub at gcc dot gnu.org
  2013-08-30 12:58 ` [Bug tree-optimization/58277] [4.7 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-30 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Aug 30 12:53:47 2013
New Revision: 202105

URL: http://gcc.gnu.org/viewcvs?rev=202105&root=gcc&view=rev
Log:
    PR tree-optimization/58277
    * tree-ssa-strlen.c (strlen_enter_block): If do_invalidate gave up
    after seeing too many stmts with vdef in between dombb and current
    bb, invalidate everything.

    * gcc.c-torture/execute/pr58277-1.c: New test.
    * gcc.c-torture/execute/pr58277-2.c: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr58277-2.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-strlen.c


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

* [Bug tree-optimization/58277] [4.7 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (8 preceding siblings ...)
  2013-08-30 12:53 ` jakub at gcc dot gnu.org
@ 2013-08-30 12:58 ` jakub at gcc dot gnu.org
  2013-08-30 16:46 ` su at cs dot ucdavis.edu
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-30 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.7/4.8/4.9 Regression]    |[4.7 Regression] wrong code
                   |wrong code at -O3           |at -O3

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 4.8+ so far, thanks for reporting it.


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

* [Bug tree-optimization/58277] [4.7 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (9 preceding siblings ...)
  2013-08-30 12:58 ` [Bug tree-optimization/58277] [4.7 " jakub at gcc dot gnu.org
@ 2013-08-30 16:46 ` su at cs dot ucdavis.edu
  2014-05-07 16:02 ` jakub at gcc dot gnu.org
  2014-05-07 16:19 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-30 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Jakub Jelinek from comment #10)
> Fixed for 4.8+ so far, thanks for reporting it.

Thanks Jakub. Wow, that's quick! You folks are wonderful.


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

* [Bug tree-optimization/58277] [4.7 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (10 preceding siblings ...)
  2013-08-30 16:46 ` su at cs dot ucdavis.edu
@ 2014-05-07 16:02 ` jakub at gcc dot gnu.org
  2014-05-07 16:19 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-05-07 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed May  7 16:01:24 2014
New Revision: 210171

URL: http://gcc.gnu.org/viewcvs?rev=210171&root=gcc&view=rev
Log:
    Backported from mainline
    2013-08-30  Jakub Jelinek  <jakub@redhat.com>

    PR tree-optimization/58277
    * tree-ssa-strlen.c (strlen_enter_block): If do_invalidate gave up
    after seeing too many stmts with vdef in between dombb and current
    bb, invalidate everything.

    * gcc.c-torture/execute/pr58277-1.c: New test.
    * gcc.c-torture/execute/pr58277-2.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/execute/pr58277-2.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-strlen.c


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

* [Bug tree-optimization/58277] [4.7 Regression] wrong code at -O3
  2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
                   ` (11 preceding siblings ...)
  2014-05-07 16:02 ` jakub at gcc dot gnu.org
@ 2014-05-07 16:19 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-05-07 16:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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


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

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

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-29 23:30 [Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk) su at cs dot ucdavis.edu
2013-08-29 23:31 ` [Bug tree-optimization/58277] " su at cs dot ucdavis.edu
2013-08-29 23:39 ` su at cs dot ucdavis.edu
2013-08-29 23:40 ` su at cs dot ucdavis.edu
2013-08-30  7:39 ` [Bug tree-optimization/58277] [4.7/4.8/4.9 Regression] wrong code at -O3 jakub at gcc dot gnu.org
2013-08-30  8:00 ` mpolacek at gcc dot gnu.org
2013-08-30  8:02 ` jakub at gcc dot gnu.org
2013-08-30  9:31 ` jakub at gcc dot gnu.org
2013-08-30 12:41 ` jakub at gcc dot gnu.org
2013-08-30 12:53 ` jakub at gcc dot gnu.org
2013-08-30 12:58 ` [Bug tree-optimization/58277] [4.7 " jakub at gcc dot gnu.org
2013-08-30 16:46 ` su at cs dot ucdavis.edu
2014-05-07 16:02 ` jakub at gcc dot gnu.org
2014-05-07 16:19 ` 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).