public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/66187] New: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu
@ 2015-05-17 19:25 su at cs dot ucdavis.edu
2015-05-18 7:31 ` [Bug rtl-optimization/66187] [6 Regression] " jakub at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: su at cs dot ucdavis.edu @ 2015-05-17 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66187
Bug ID: 66187
Summary: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
Target Milestone: ---
The current gcc trunk miscompiles the following code on x86_64-linux at -O1,
-O2 and -O3 in both 32-bit and 64-bit modes.
This is a regression from 5.1.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/6.0.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 6.0.0 20150517 (experimental) [trunk revision 223265] (GCC)
$
$ gcc-trunk -O0 small.c; ./a.out
$ gcc-trunk -Os small.c; ./a.out
$ gcc-5.1 -O1 small.c; ./a.out
$
$ gcc-trunk -O1 small.c
$ ./a.out
Aborted (core dumped)
$
---------------------------------
struct
{
short f1;
} b;
int a = 1, e = -1;
short f;
int
main ()
{
int g;
f = e;
g = b.f1 < 0 ? 0 : f + b.f1;
if ((g & -4) < 0)
a = 0;
if (a)
__builtin_abort ();
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/66187] [6 Regression] wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu
2015-05-17 19:25 [Bug rtl-optimization/66187] New: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2015-05-18 7:31 ` jakub at gcc dot gnu.org
2015-05-18 10:50 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-05-18 7:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66187
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-05-18
CC| |jakub at gcc dot gnu.org
Target Milestone|--- |6.0
Summary|wrong code at -O1, -O2 and |[6 Regression] wrong code
|-O3 on x86_64-linux-gnu |at -O1, -O2 and -O3 on
| |x86_64-linux-gnu
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r222877.
I bet the problem is in:
&& (tree_int_cst_min_precision (@4, UNSIGNED)
<= TYPE_PRECISION (TREE_TYPE (@0)))
which for signed types IMHO should be < instead.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/66187] [6 Regression] wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu
2015-05-17 19:25 [Bug rtl-optimization/66187] New: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2015-05-18 7:31 ` [Bug rtl-optimization/66187] [6 Regression] " jakub at gcc dot gnu.org
@ 2015-05-18 10:50 ` jakub at gcc dot gnu.org
2015-05-19 13:55 ` jakub at gcc dot gnu.org
2015-05-19 14:10 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-05-18 10:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66187
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 #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 35560
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35560&action=edit
gcc6-pr66187.patch
Untested fix. Perhaps for the unsigned type and plus only, we could do even
better, we don't really need to ensure the mask fits into precision, but
perhaps just that the bit immediately above precision is clear (all bits above
that are necessarily clear in the plus).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/66187] [6 Regression] wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu
2015-05-17 19:25 [Bug rtl-optimization/66187] New: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2015-05-18 7:31 ` [Bug rtl-optimization/66187] [6 Regression] " jakub at gcc dot gnu.org
2015-05-18 10:50 ` jakub at gcc dot gnu.org
@ 2015-05-19 13:55 ` jakub at gcc dot gnu.org
2015-05-19 14:10 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-05-19 13:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66187
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Tue May 19 13:54:32 2015
New Revision: 223366
URL: https://gcc.gnu.org/viewcvs?rev=223366&root=gcc&view=rev
Log:
PR tree-optimization/66187
* match.pd ((bit_and (plus/minus (convert @0) (convert @1)) mask)):
Pass TYPE_SIGN to tree_int_cst_min_precision. If
!TYPE_OVERFLOW_WRAPS, ensure @4 is non-negative.
* gcc.c-torture/execute/pr66187.c: New test.
* gcc.dg/pr66187-1.c: New test.
* gcc.dg/pr66187-2.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr66187.c
trunk/gcc/testsuite/gcc.dg/pr66187-1.c
trunk/gcc/testsuite/gcc.dg/pr66187-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/match.pd
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/66187] [6 Regression] wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu
2015-05-17 19:25 [Bug rtl-optimization/66187] New: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2015-05-19 13:55 ` jakub at gcc dot gnu.org
@ 2015-05-19 14:10 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-05-19 14:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66187
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed, thanks for the report.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-19 14:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-17 19:25 [Bug rtl-optimization/66187] New: wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2015-05-18 7:31 ` [Bug rtl-optimization/66187] [6 Regression] " jakub at gcc dot gnu.org
2015-05-18 10:50 ` jakub at gcc dot gnu.org
2015-05-19 13:55 ` jakub at gcc dot gnu.org
2015-05-19 14:10 ` 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).