public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
@ 2013-10-14 18:38 su at cs dot ucdavis.edu
2013-10-15 8:22 ` [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-10-14 18:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Bug ID: 58726
Summary: wrong code at -Os on x86_64-linux-gnu (affecting
trunk/4.7/4.6, but not 4.8)
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The current gcc trunk miscompiles the following code on x86_64-linux at -Os in
both 32-bit and 64-bit modes.
This is a regression from 4.8.x.
It also affects 4.6.x and 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.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --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 20131014 (experimental) [trunk revision 203511] (GCC)
$
$ gcc-trunk -O1 small.c; a.out
-9162
$ gcc-trunk -Os small.c; a.out
-32768
$
$ gcc-4.8 -Os small.c; a.out
-9162
$
$ gcc-4.7 -Os small.c; a.out
-32768
$ gcc-4.6 -Os small.c; a.out
-32768
$
------------------------------------
int printf (const char *, ...);
int a, c;
union
{
int f1;
int f2:1;
} b;
short
foo (short p)
{
return p < 0 ? p : a;
}
int
main ()
{
b.f1 = 56374;
unsigned short d;
int e = b.f2;
d = e == 0 ? b.f1 : 0;
c = foo (d);
printf ("%d\n", c);
return 0;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
@ 2013-10-15 8:22 ` rguenth at gcc dot gnu.org
2013-10-18 19:55 ` mikpelinux at gmail dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-15 8:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|wrong code at -Os on |[4.7/4.8/4.9 Regression]
|x86_64-linux-gnu (affecting |wrong code at -Os on
|trunk/4.7/4.6, but not 4.8) |x86_64-linux-gnu (affecting
| |trunk/4.7/4.6, but not 4.8)
Target Milestone|--- |4.7.4
Known to fail| |4.4.7, 4.5.4, 4.6.4, 4.7.3,
| |4.8.2, 4.9.0
Status|UNCONFIRMED |NEW
Known to work| |4.1.2, 4.3.4, 4.8.1
Keywords| |wrong-code
Last reconfirmed| |2013-10-15
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. Works with 4.8.1 but fails on the branch. Seems to be a heisenbug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
2013-10-15 8:22 ` [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
@ 2013-10-18 19:55 ` mikpelinux at gmail dot com
2013-11-05 15:03 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mikpelinux at gmail dot com @ 2013-10-18 19:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Mikael Pettersson <mikpelinux at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpelinux at gmail dot com
--- Comment #2 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Started with r133452.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
2013-10-15 8:22 ` [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-18 19:55 ` mikpelinux at gmail dot com
@ 2013-11-05 15:03 ` rguenth at gcc dot gnu.org
2013-12-03 19:25 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-05 15:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |rsandifo at gcc dot gnu.org
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2013-11-05 15:03 ` rguenth at gcc dot gnu.org
@ 2013-12-03 19:25 ` jakub at gcc dot gnu.org
2013-12-03 19:51 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-03 19:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Testcase suitable for gcc.c-torture/execute/:
int a, c;
union { int f1; int f2 : 1; } b;
short
foo (short p)
{
return p < 0 ? p : a;
}
int
main ()
{
if (sizeof (short) * __CHAR_BIT__ != 16
|| sizeof (int) * __CHAR_BIT__ != 32)
return 0;
b.f1 = 56374;
unsigned short d;
int e = b.f2;
d = e == 0 ? b.f1 : 0;
c = foo (d);
if (c != (short) 56374)
__builtin_abort ();
return 0;
}
This seems to be a bug in the combiner, during combination of:
(gdb) p debug_rtx (i3)
(insn 22 21 23 2 (parallel [
(set (reg:CCGOC 17 flags)
(compare:CCGOC (and:HI (reg/v:HI 83 [ d ])
(const_int -9162 [0xffffffffffffdc36]))
(const_int 0 [0])))
(set (reg:HI 85 [ D.1789 ])
(and:HI (reg/v:HI 83 [ d ])
(const_int -9162 [0xffffffffffffdc36])))
]) pr58726.c:7 395 {*andhi_2}
(expr_list:REG_DEAD (reg/v:HI 83 [ d ])
(nil)))
(gdb) p debug_rtx (i2)
(insn 55 54 56 2 (parallel [
(set (subreg:SI (reg/v:HI 83 [ d ]) 0)
(if_then_else:SI (ltu:SI (reg:CC 17 flags)
(const_int 0 [0]))
(const_int -1 [0xffffffffffffffff])
(const_int 0 [0])))
(clobber (reg:CC 17 flags))
]) pr58726.c:19 925 {*x86_movsicc_0_m1}
(expr_list:REG_DEAD (reg:CC 17 flags)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
(gdb) p debug_rtx (i1)
(insn 54 15 55 2 (set (reg:CC 17 flags)
(compare:CC (reg:QI 98 [ D.1788 ])
(const_int 1 [0x1]))) pr58726.c:19 5 {*cmpqi_1}
(expr_list:REG_DEAD (reg:QI 98 [ D.1788 ])
(nil)))
The problem is that reg:HI 83 is substed multiple twice (with unique_copy == 0)
and apparently force_to_mode seems to destructively modify the expression,
which is shared, around line 8533. On the second occurrence it is first
force_to_mode'd with mask 0xdc36, and on the first occurrence later on
simplify_comparison performs:
11187 /* If this is a sign bit comparison and we can do arithmetic in
11188 MODE, say that we will only be needing the sign bit of OP0. */
11189 if (sign_bit_comparison_p && HWI_COMPUTABLE_MODE_P (mode))
11190 op0 = force_to_mode (op0, mode,
11191 (unsigned HOST_WIDE_INT) 1
11192 << (GET_MODE_PRECISION (mode) - 1),
11193 0);
with mask 0x8000, which destructively modifies also the second occurrence.
So the question is, do we have to copy_rtx always just in case, or should some
routines (e.g. force_to_mode) be documented as not modifying the argument in
place? I guess this issue can be fixed easily just by changing those two
SUBSTs at the end of force_to_mode in IF_THEN_ELSE handling (and there is
another one for ROTATE{,RT}), but the question is if we don't have tons of
similar latent issues. The changes in place were done using SUBST, so if we
undo_all, they are properly reverted, the problem is when they aren't reverted,
as in this case.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (3 preceding siblings ...)
2013-12-03 19:25 ` jakub at gcc dot gnu.org
@ 2013-12-03 19:51 ` jakub at gcc dot gnu.org
2013-12-04 11:25 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-03 19:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 31366
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31366&action=edit
gcc49-pr58726.patch
Untested patch that does that, fixes the testcase.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (4 preceding siblings ...)
2013-12-03 19:51 ` jakub at gcc dot gnu.org
@ 2013-12-04 11:25 ` jakub at gcc dot gnu.org
2013-12-04 15:51 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-04 11:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed Dec 4 11:25:06 2013
New Revision: 205664
URL: http://gcc.gnu.org/viewcvs?rev=205664&root=gcc&view=rev
Log:
PR rtl-optimization/58726
* combine.c (force_to_mode): Fix comment typo. Don't destructively
modify x for ROTATE, ROTATERT and IF_THEN_ELSE.
* gcc.c-torture/execute/pr58726.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr58726.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/combine.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (5 preceding siblings ...)
2013-12-04 11:25 ` jakub at gcc dot gnu.org
@ 2013-12-04 15:51 ` jakub at gcc dot gnu.org
2013-12-04 15:56 ` [Bug rtl-optimization/58726] [4.7 " jakub at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-04 15:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed Dec 4 15:51:02 2013
New Revision: 205672
URL: http://gcc.gnu.org/viewcvs?rev=205672&root=gcc&view=rev
Log:
PR rtl-optimization/58726
* combine.c (force_to_mode): Fix comment typo. Don't destructively
modify x for ROTATE, ROTATERT and IF_THEN_ELSE.
* gcc.c-torture/execute/pr58726.c: New test.
Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr58726.c
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/combine.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (6 preceding siblings ...)
2013-12-04 15:51 ` jakub at gcc dot gnu.org
@ 2013-12-04 15:56 ` jakub at gcc dot gnu.org
2013-12-11 15:17 ` ebotcazou at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-04 15:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Known to work| |4.8.3, 4.9.0
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Summary|[4.7/4.8/4.9 Regression] |[4.7 Regression] wrong code
|wrong code at -Os on |at -Os on x86_64-linux-gnu
|x86_64-linux-gnu (affecting |(affecting trunk/4.7/4.6,
|trunk/4.7/4.6, but not 4.8) |but not 4.8)
Known to fail|4.9.0 |
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 4.8.3+ so far.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (7 preceding siblings ...)
2013-12-04 15:56 ` [Bug rtl-optimization/58726] [4.7 " jakub at gcc dot gnu.org
@ 2013-12-11 15:17 ` ebotcazou at gcc dot gnu.org
2014-02-22 8:57 ` ebotcazou at gcc dot gnu.org
2014-10-23 6:08 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2013-12-11 15:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Let's close this, I don't think that we need the fix on the 4.7 branch.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (8 preceding siblings ...)
2013-12-11 15:17 ` ebotcazou at gcc dot gnu.org
@ 2014-02-22 8:57 ` ebotcazou at gcc dot gnu.org
2014-10-23 6:08 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2014-02-22 8:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/58726] [4.7 Regression] wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
` (9 preceding siblings ...)
2014-02-22 8:57 ` ebotcazou at gcc dot gnu.org
@ 2014-10-23 6:08 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-23 6:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.7.4 |4.8.3
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-10-23 4:06 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-14 18:38 [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8) su at cs dot ucdavis.edu
2013-10-15 8:22 ` [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-18 19:55 ` mikpelinux at gmail dot com
2013-11-05 15:03 ` rguenth at gcc dot gnu.org
2013-12-03 19:25 ` jakub at gcc dot gnu.org
2013-12-03 19:51 ` jakub at gcc dot gnu.org
2013-12-04 11:25 ` jakub at gcc dot gnu.org
2013-12-04 15:51 ` jakub at gcc dot gnu.org
2013-12-04 15:56 ` [Bug rtl-optimization/58726] [4.7 " jakub at gcc dot gnu.org
2013-12-11 15:17 ` ebotcazou at gcc dot gnu.org
2014-02-22 8:57 ` ebotcazou at gcc dot gnu.org
2014-10-23 6:08 ` pinskia 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).