public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu
@ 2014-06-01 22:00 su at cs dot ucdavis.edu
2014-06-02 8:10 ` [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] " rguenth at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-06-01 22:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
Bug ID: 61383
Summary: wrong code at -O2 and -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 and 4.9) miscompiles the following
code on x86_64-linux at -O2 and -O3 in both 32-bit and 64-bit modes.
This is a regression from 4.7.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.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.10.0 20140601 (experimental) [trunk revision 211110] (GCC)
$
$ gcc-trunk -Os small.c; a.out
$ gcc-4.7.3 -O2 small.c; a.out
$
$ gcc-trunk -O2 small.c; a.out
Floating point exception (core dumped)
$ gcc-4.8.2 -O2 small.c; a.out
Floating point exception (core dumped)
$
------------------------------
int a, b = 1, c, d, e, f, g;
int
fn1 ()
{
int h;
for (;;)
{
g = b;
g = g ? 0 : 1 % g;
e = a + 1;
for (; d < 1; d = e)
{
h = f == 0 ? 0 : 1 % f;
if (f < 1)
c = 0;
else if (h)
break;
}
if (b)
return 0;
}
}
int
main ()
{
fn1 ();
return 0;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2014-06-02 8:10 ` rguenth at gcc dot gnu.org
2014-06-02 8:44 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-02 8:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-06-02
Known to work| |4.7.3
Target Milestone|--- |4.8.4
Summary|wrong code at -O2 and -O3 |[4.8/4.9/4.10 Regression]
|on x86_64-linux-gnu |wrong code at -O2 and -O3
| |on x86_64-linux-gnu
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-06-02 8:10 ` [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] " rguenth at gcc dot gnu.org
@ 2014-06-02 8:44 ` jakub at gcc dot gnu.org
2014-06-02 13:19 ` glisse at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-06-02 8:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |glisse at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r190184.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-06-02 8:10 ` [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] " rguenth at gcc dot gnu.org
2014-06-02 8:44 ` jakub at gcc dot gnu.org
@ 2014-06-02 13:19 ` glisse at gcc dot gnu.org
2014-06-02 13:37 ` ubizjak at gmail dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-06-02 13:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
This very minor variant also misbehaves with 4.7 and 4.6, so before my patch.
An unsafe instruction (1%f) is taken out of a branch in ifcombine.
int a, b = 1, c, d, e, f, g;
int
fn1 ()
{
int h;
for (;;)
{
g = b;
g = g ? 0 : 1 % g;
e = a + 1;
for (; d < 1; d = e)
{
if (f == 0)
h = 0;
else
h = 1 % f;
if (f < 1)
c = 0;
else if (h)
break;
}
if (b)
return 0;
}
}
int
main ()
{
fn1 ();
return 0;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2014-06-02 13:19 ` glisse at gcc dot gnu.org
@ 2014-06-02 13:37 ` ubizjak at gmail dot com
2014-06-02 20:59 ` ebotcazou at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2014-06-02 13:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
There is similar issue in RTL PRE GCSE [1], PR45223.
>From gcc-bugs-return-452995-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jun 02 14:02:13 2014
Return-Path: <gcc-bugs-return-452995-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6281 invoked by alias); 2 Jun 2014 14:02:13 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6186 invoked by uid 48); 2 Jun 2014 14:02:05 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
Date: Mon, 02 Jun 2014 14:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-61383-4-riiLslS0bg@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61383-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61383-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-06/txt/msg00077.txt.bz2
Content-length: 865
https://gcc.gnu.org/bugzilla/show_bug.cgi?ida383
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #3)
> This very minor variant also misbehaves with 4.7 and 4.6, so before my
> patch. An unsafe instruction (1%f) is taken out of a branch in ifcombine.
>
> int a, b = 1, c, d, e, f, g;
>
> int
> fn1 ()
> {
> int h;
> for (;;)
> {
> g = b;
> g = g ? 0 : 1 % g;
> e = a + 1;
> for (; d < 1; d = e)
> {
> if (f == 0)
> h = 0;
> else
> h = 1 % f;
> if (f < 1)
> c = 0;
> else if (h)
> break;
> }
> if (b)
> return 0;
> }
> }
>
> int
> main ()
> {
> fn1 ();
> return 0;
> }
I have a patch in testing. (and fixed the tree PRE issue in the past...)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (3 preceding siblings ...)
2014-06-02 13:37 ` ubizjak at gmail dot com
@ 2014-06-02 20:59 ` ebotcazou at gcc dot gnu.org
2014-06-03 8:49 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2014-06-02 20:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu.org
--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> There is similar issue in RTL PRE GCSE [1], PR45223.
Right, there are various similar old issues in the RTL optimizers, but we must
be extra careful because we really don't want to pessimize the common case to
fix some artificial testcases.
Note that we have some backup here: the (green) Dragon Book gives a code motion
algorithm that is subject to this kind of issues and the authors elegantly
write "For this reason, it is wise to use the following algorithm for code
motion only if optimization may be inhibited by the programmer". :-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (4 preceding siblings ...)
2014-06-02 20:59 ` ebotcazou at gcc dot gnu.org
@ 2014-06-03 8:49 ` rguenth at gcc dot gnu.org
2014-06-04 12:02 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-03 8:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Jun 3 08:48:28 2014
New Revision: 211163
URL: http://gcc.gnu.org/viewcvs?rev=211163&root=gcc&view=rev
Log:
2014-06-03 Richard Biener <rguenther@suse.de>
PR tree-optimization/61383
* tree-ssa-ifcombine.c (bb_no_side_effects_p): Make sure
stmts can't trap.
* gcc.dg/torture/pr61383-1.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/torture/pr61383-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-ifcombine.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (5 preceding siblings ...)
2014-06-03 8:49 ` rguenth at gcc dot gnu.org
@ 2014-06-04 12:02 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-04 12:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (6 preceding siblings ...)
2014-06-04 12:02 ` rguenth at gcc dot gnu.org
@ 2014-06-04 13:41 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-04 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Wed Jun 4 13:41:09 2014
New Revision: 211232
URL: http://gcc.gnu.org/viewcvs?rev=211232&root=gcc&view=rev
Log:
2014-06-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/61383
* tree-ssa-ifcombine.c (bb_no_side_effects_p): Make sure
stmts can't trap.
* gcc.dg/torture/pr61383-1.c: New testcase.
Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr61383-1.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-ifcombine.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (7 preceding siblings ...)
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
@ 2014-06-04 13:41 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-04 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work| |4.10.0, 4.8.4, 4.9.1
Resolution|--- |FIXED
Known to fail| |4.8.3, 4.9.0
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (8 preceding siblings ...)
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
@ 2014-06-04 13:41 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-04 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61383
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Wed Jun 4 13:40:33 2014
New Revision: 211231
URL: http://gcc.gnu.org/viewcvs?rev=211231&root=gcc&view=rev
Log:
2014-06-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/61383
* tree-ssa-ifcombine.c (bb_no_side_effects_p): Make sure
stmts can't trap.
* gcc.dg/torture/pr61383-1.c: New testcase.
Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr61383-1.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
branches/gcc-4_9-branch/gcc/tree-ssa-ifcombine.c
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-06-04 13:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 22:00 [Bug tree-optimization/61383] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-06-02 8:10 ` [Bug tree-optimization/61383] [4.8/4.9/4.10 Regression] " rguenth at gcc dot gnu.org
2014-06-02 8:44 ` jakub at gcc dot gnu.org
2014-06-02 13:19 ` glisse at gcc dot gnu.org
2014-06-02 13:37 ` ubizjak at gmail dot com
2014-06-02 20:59 ` ebotcazou at gcc dot gnu.org
2014-06-03 8:49 ` rguenth at gcc dot gnu.org
2014-06-04 12:02 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` rguenth at gcc dot gnu.org
2014-06-04 13:41 ` 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).