public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
@ 2013-12-06 17:55 su at cs dot ucdavis.edu
2013-12-17 19:08 ` [Bug tree-optimization/59413] " mpolacek at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-12-06 17:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
Bug ID: 59413
Summary: wrong code at -Os on x86_64-linux-gnu in both 32-bit
and 64-bit modes
Product: gcc
Version: 4.9.0
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 miscompiles the following code on x86_64-linux at -Os
(but not at the other optimization levels) in both 32-bit and 64-bit modes.
It is interesting that the typedef appears necessary to trigger the
miscompilation.
This is a regression from 4.8.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 --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.9.0 20131206 (experimental) [trunk revision 205734] (GCC)
$
$ gcc-trunk -O1 small.c; a.out
7
$ gcc-trunk -O2 small.c; a.out
7
$ gcc-4.8 -Os small.c; a.out
7
$
$ gcc-trunk -Os small.c; a.out
2
$
--------------------------------
int printf (const char *, ...);
typedef unsigned int uint32_t;
uint32_t a;
int b;
int
main ()
{
uint32_t c;
for (a = 7; a <= 1; a++)
{
char d = a;
c = d;
b = a == c;
}
printf ("%d\n", a);
return 0;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
@ 2013-12-17 19:08 ` mpolacek at gcc dot gnu.org
2013-12-19 12:29 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-12-17 19:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I can't reproduce this one with gcc version 4.9.0 20131217.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
2013-12-17 19:08 ` [Bug tree-optimization/59413] " mpolacek at gcc dot gnu.org
@ 2013-12-19 12:29 ` jakub at gcc dot gnu.org
2013-12-20 1:50 ` su at cs dot ucdavis.edu
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-19 12:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I couldn't reproduce this either, neither -m32/-m64 helps, tried also r205733
and various other snapshots, everything prints 7.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
2013-12-17 19:08 ` [Bug tree-optimization/59413] " mpolacek at gcc dot gnu.org
2013-12-19 12:29 ` jakub at gcc dot gnu.org
@ 2013-12-20 1:50 ` su at cs dot ucdavis.edu
2013-12-20 1:56 ` su at cs dot ucdavis.edu
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-12-20 1:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Jakub Jelinek from comment #2)
> I couldn't reproduce this either, neither -m32/-m64 helps, tried also
> r205733 and various other snapshots, everything prints 7.
I rebuilt r205734 with the same config
configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++
--disable-werror --enable-multilib
and
make bootstrap-lean
It still fails for me at -Os:
$ ./gcc -Os small.c; a.out
2
$ cat small.c
int printf (const char *, ...);
typedef unsigned int uint32_t;
uint32_t a;
int b;
int
main ()
{
uint32_t c;
for (a = 7; a <= 1; a++)
{
char d = a;
c = d;
b = a == c;
}
printf ("%d\n", a);
return 0;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2013-12-20 1:50 ` su at cs dot ucdavis.edu
@ 2013-12-20 1:56 ` su at cs dot ucdavis.edu
2013-12-20 5:31 ` [Bug tree-optimization/59413] [4.9 Regression] " hjl.tools at gmail dot com
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-12-20 1:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
--- Comment #4 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Jakub Jelinek from comment #2)
> I couldn't reproduce this either, neither -m32/-m64 helps, tried also
> r205733 and various other snapshots, everything prints 7.
But it doesn't appear to fail with the latest trunk revision (r206135):
$ 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 --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++,lto --disable-werror --enable-multilib
Thread model: posix
gcc version 4.9.0 20131219 (experimental) [trunk revision 206135] (GCC)
$
$ gcc-trunk -Os small.c; a.out
7
$
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (3 preceding siblings ...)
2013-12-20 1:56 ` su at cs dot ucdavis.edu
@ 2013-12-20 5:31 ` hjl.tools at gmail dot com
2013-12-20 12:10 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2013-12-20 5:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-12-20
Target Milestone|--- |4.9.0
Summary|wrong code at -Os on |[4.9 Regression] wrong code
|x86_64-linux-gnu in both |at -Os on x86_64-linux-gnu
|32-bit and 64-bit modes |in both 32-bit and 64-bit
| |modes
Ever confirmed|0 |1
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
It is fixed by r205884. We can add the testcase and close it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (4 preceding siblings ...)
2013-12-20 5:31 ` [Bug tree-optimization/59413] [4.9 Regression] " hjl.tools at gmail dot com
@ 2013-12-20 12:10 ` jakub at gcc dot gnu.org
2013-12-20 12:39 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-20 12:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Weird, I still get exactly the same code (except for gcc version string)
between pre-r205884 and post-r205884. So, what exact differences are you
seeing on the testcase, and with -fdump-tree-all -da starting with what pass?
Tried both a non-bootstrap gcc in my bisecting tree and 12 freshly built gcc
x86_64 bootstraps from around Dec 5 till now.
Because when I'm not able to reproduce it, I'm hesistant to adding the
testcase...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (5 preceding siblings ...)
2013-12-20 12:10 ` jakub at gcc dot gnu.org
@ 2013-12-20 12:39 ` hjl.tools at gmail dot com
2013-12-20 12:49 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2013-12-20 12:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl.tools at gmail dot com
--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
[hjl@gnu-mic-2 gcc-regression]$ cat pr59413.c
typedef unsigned int uint32_t;
uint32_t a;
int b;
int
main ()
{
uint32_t c;
for (a = 7; a <= 1; a++)
{
char d = a;
c = d;
b = a == c;
}
if (a != 7)
__builtin_abort ();
return 0;
}
[hjl@gnu-mic-2 gcc-regression]$
/export/project/git/gcc-regression/master/205883/usr/bin/gcc -S pr59413.c -Os
-o bad.s
[hjl@gnu-mic-2 gcc-regression]$
/export/project/git/gcc-regression/master/205887/usr/bin/gcc -S pr59413.c -Os
-o good.s
[hjl@gnu-mic-2 gcc-regression]$ diff -up bad.s good.s
--- bad.s 2013-12-20 04:38:57.810620352 -0800
+++ good.s 2013-12-20 04:39:12.476337299 -0800
@@ -8,20 +8,9 @@
main:
.LFB0:
.cfi_startproc
- movl b(%rip), %edx
- movl $7, %eax
-.L2:
- incl %eax
- cmpl $3, %eax
- je .L6
- movl $1, %edx
- jmp .L2
-.L6:
- pushq %rax
- .cfi_def_cfa_offset 16
- movl %edx, b(%rip)
- movl $2, a(%rip)
- call abort
+ movl $7, a(%rip)
+ xorl %eax, %eax
+ ret
.cfi_endproc
.LFE0:
.size main, .-main
@@ -31,5 +20,5 @@ main:
.LHOTE0:
.comm b,4,4
.comm a,4,4
- .ident "GCC: (GNU) 4.9.0 20131211 (experimental) [trunk revision
205883]"
+ .ident "GCC: (GNU) 4.9.0 20131211 (experimental) [trunk revision
205887]"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-mic-2 gcc-regression]$
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (6 preceding siblings ...)
2013-12-20 12:39 ` hjl.tools at gmail dot com
@ 2013-12-20 12:49 ` jakub at gcc dot gnu.org
2013-12-20 12:58 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-20 12:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, my fault then, terribly sorry, I've simplified the testcase a little bit
(removed the typedef and used unsigned int instead). Apparently for the
reproduction it is important that the c variable uses some typedef to unsigned
int rather than that type directly.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (7 preceding siblings ...)
2013-12-20 12:49 ` jakub at gcc dot gnu.org
@ 2013-12-20 12:58 ` hjl.tools at gmail dot com
2013-12-20 13:07 ` jakub at gcc dot gnu.org
2013-12-20 13:09 ` jakub at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2013-12-20 12:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to H.J. Lu from comment #5)
> It is fixed by r205884. We can add the testcase and close it.
FWIW, it is also introduced by r204516.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (8 preceding siblings ...)
2013-12-20 12:58 ` hjl.tools at gmail dot com
@ 2013-12-20 13:07 ` jakub at gcc dot gnu.org
2013-12-20 13:09 ` jakub at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-20 13:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Dec 20 13:07:10 2013
New Revision: 206147
URL: http://gcc.gnu.org/viewcvs?rev=206147&root=gcc&view=rev
Log:
PR tree-optimization/59413
* gcc.c-torture/execute/pr59413.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr59413.c
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59413] [4.9 Regression] wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
` (9 preceding siblings ...)
2013-12-20 13:07 ` jakub at gcc dot gnu.org
@ 2013-12-20 13:09 ` jakub at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-20 13:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59413
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Thanks, testcase committed, so we are all set now.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-12-20 13:09 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-06 17:55 [Bug tree-optimization/59413] New: wrong code at -Os on x86_64-linux-gnu in both 32-bit and 64-bit modes su at cs dot ucdavis.edu
2013-12-17 19:08 ` [Bug tree-optimization/59413] " mpolacek at gcc dot gnu.org
2013-12-19 12:29 ` jakub at gcc dot gnu.org
2013-12-20 1:50 ` su at cs dot ucdavis.edu
2013-12-20 1:56 ` su at cs dot ucdavis.edu
2013-12-20 5:31 ` [Bug tree-optimization/59413] [4.9 Regression] " hjl.tools at gmail dot com
2013-12-20 12:10 ` jakub at gcc dot gnu.org
2013-12-20 12:39 ` hjl.tools at gmail dot com
2013-12-20 12:49 ` jakub at gcc dot gnu.org
2013-12-20 12:58 ` hjl.tools at gmail dot com
2013-12-20 13:07 ` jakub at gcc dot gnu.org
2013-12-20 13:09 ` 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).