public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization
@ 2008-03-19 18:51 edwintorok at gmail dot com
2008-03-19 18:55 ` [Bug rtl-optimization/35643] " edwintorok at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: edwintorok at gmail dot com @ 2008-03-19 18:51 UTC (permalink / raw)
To: gcc-bugs
When I compile the testcase with -O2, or with '-O1 -fstrict-aliasing' incorrect
code is generated. The testcase calls abort() in this case.
This is a regression in gcc-4.2 only: gcc-4.1 and gcc-4.3 do not show the bug.
$ gcc-4.2 -O1 test.i -o ok && ./ok
$ gcc-4.2 -O2 test.i -o fails && ./fails
Aborted
$ gcc-4.2 -O1 -fstrict-aliasing test.i -o fails2 && ./fails2
Aborted
$ gcc-4.2 -O3 test.i -o fails3 && ./fails3
Aborted
The testcase gives no warnings:
$ gcc-4.2 -Wall -W -O2 -Wstrict-aliasing test.i
The original code that is miscompiled is ClamAV, but only if -O3 is used.
I created an initial reduced testcase using delta.
Manually inlining some functions show this bug even at -O2 on the reduced
testcase.
I reproduced this on 2 different systems:
edwin@lightspeed2:~$ uname -a
Linux lightspeed2 2.6.25-rc4-00134-g84c6f60 #4 Sun Mar 9 19:40:34 EET 2008
x86_64 GNU/Linux
edwin@lightspeed2:~$ gcc-4.2 -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--disable-libmudflap --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.3 (Debian 4.2.3-2)
I also reproduced the bug with gcc 4.2.3 built with --enable-checking=yes:
edwin@lightspeed2:~$ gcc-4.2.3/inst/bin/gcc -O1 -fstrict-aliasing test.i -o
fails && ./fails
Aborted
edwin@lightspeed2:~$ gcc-4.2.3/inst/bin/gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../configure --enable-languages=c
--prefix=/home/edwin/gcc-4.2.3/obj/../inst --enable-checking=yes
--disable-multilib --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --disable-bootstrap
Thread model: posix
gcc version 4.2.3
The second system:
edwin@thunder:~$ uname -a
Linux thunder 2.6.25-rc5-00323-g9a9e0d6 #22 SMP PREEMPT Sun Mar 16 10:23:46 EET
2008 i686 GNU/Linux
edwin@thunder:~$ gcc-4.2 -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--disable-libmudflap --enable-targets=all --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Debian 4.2.3-2)
--
Summary: gcc-4.2 -O1 -fstrict-aliasing misoptimization
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: edwintorok at gmail dot com
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/35643] gcc-4.2 -O1 -fstrict-aliasing misoptimization
2008-03-19 18:51 [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization edwintorok at gmail dot com
@ 2008-03-19 18:55 ` edwintorok at gmail dot com
2008-03-19 19:36 ` edwintorok at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: edwintorok at gmail dot com @ 2008-03-19 18:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from edwintorok at gmail dot com 2008-03-19 18:54 -------
Created an attachment (id=15345)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15345&action=view)
testcase
Some observations:
If you remove some dead code the optimization bug goes away:
Remove either of these and you'll get correct code, for example:
if (metadata->chunk_current >= metadata->chunk_end) {
}
If I remove that if and compare assembly output, I see this:
$ diff -wu bad.s ok.s
--- bad.s 2008-03-19 20:51:59.000000000 +0200
+++ ok.s 2008-03-19 20:51:47.000000000 +0200
@@ -60,7 +60,7 @@
testb %al, %al
js .L9
movsbq %sil,%rax
- addq %rax, %rcx
+ leaq 1(%rcx,%rax), %rcx
.L11:
movzbl (%rdx), %eax
addq $1, %rdx
Of course the original code that is miscompiled doesn't have dead code, it is
just because of the reduction.
If you need more info please ask.
This is related to this bug (but that occurs only at -O3):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470557
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/35643] gcc-4.2 -O1 -fstrict-aliasing misoptimization
2008-03-19 18:51 [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization edwintorok at gmail dot com
2008-03-19 18:55 ` [Bug rtl-optimization/35643] " edwintorok at gmail dot com
@ 2008-03-19 19:36 ` edwintorok at gmail dot com
2008-03-19 19:57 ` [Bug rtl-optimization/35643] [4.2 Regression] " rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: edwintorok at gmail dot com @ 2008-03-19 19:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from edwintorok at gmail dot com 2008-03-19 19:35 -------
Created an attachment (id=15346)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15346&action=view)
another reduced testcase
I reduced the testcase further using delta, however I had to be careful to
avoid deleting initializations. This testcase is valgrind clean.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/35643] [4.2 Regression] gcc-4.2 -O1 -fstrict-aliasing misoptimization
2008-03-19 18:51 [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization edwintorok at gmail dot com
2008-03-19 18:55 ` [Bug rtl-optimization/35643] " edwintorok at gmail dot com
2008-03-19 19:36 ` edwintorok at gmail dot com
@ 2008-03-19 19:57 ` rguenth at gcc dot gnu dot org
2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
2009-03-31 15:35 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-19 19:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-03-19 19:56 -------
-O vs. -O -fstrict-aliasing. This is another flow-insensitive alias problem.
diff -u t.c.099t.optimized t.c.099t.optimizedx
--- t.c.099t.optimized 2008-03-19 20:45:05.000000000 +0100
+++ t.c.099t.optimizedx 2008-03-19 20:45:00.000000000 +0100
@@ -16,9 +16,9 @@
Analyzing Edge Insertions.
cli_chm_prepare_file (metadata)
{
- char * temp.77;
uint64_t section;
char * D.1574;
+ char * D.1572;
char * D.1565;
<bb 2>:
@@ -30,12 +30,10 @@
metadata->chunk_data = D.1565 + (char *) (unsigned int)
metadata->chunk_offset;
<L3>:;
- D.1574 = metadata->chunk_data + 20B;
- metadata->chunk_current = D.1574;
- temp.77 = D.1574 + 1B + (char *) (uint64_t) *D.1574;
- metadata->chunk_current = temp.77;
- section = (uint64_t) *temp.77;
- metadata->chunk_current = temp.77 + 1B;
+ D.1572 = metadata->chunk_data + 20B;
+ D.1574 = D.1572 + (char *) (uint64_t) *D.1572;
+ section = (uint64_t) *D.1574;
+ metadata->chunk_current = D.1574 + 1B;
if (section > 1) goto <L9>; else goto <L10>;
<L9>:;
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |alias, wrong-code
Known to fail| |4.2.3
Known to work| |4.1.3 4.3.0
Last reconfirmed|0000-00-00 00:00:00 |2008-03-19 19:56:20
date| |
Summary|gcc-4.2 -O1 -fstrict- |[4.2 Regression] gcc-4.2 -O1
|aliasing misoptimization |-fstrict-aliasing
| |misoptimization
Target Milestone|--- |4.2.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/35643] [4.2 Regression] gcc-4.2 -O1 -fstrict-aliasing misoptimization
2008-03-19 18:51 [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization edwintorok at gmail dot com
` (2 preceding siblings ...)
2008-03-19 19:57 ` [Bug rtl-optimization/35643] [4.2 Regression] " rguenth at gcc dot gnu dot org
@ 2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
2009-03-31 15:35 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-05-19 20:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jsm28 at gcc dot gnu dot org 2008-05-19 20:25 -------
4.2.4 is being released, changing milestones to 4.2.5.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.2.4 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/35643] [4.2 Regression] gcc-4.2 -O1 -fstrict-aliasing misoptimization
2008-03-19 18:51 [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization edwintorok at gmail dot com
` (3 preceding siblings ...)
2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
@ 2009-03-31 15:35 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jsm28 at gcc dot gnu dot org 2009-03-31 15:35 -------
Closing 4.2 branch, fixed in 4.3.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to fail|4.2.3 |4.2.3 4.2.5
Resolution| |FIXED
Target Milestone|4.2.5 |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-03-31 15:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-19 18:51 [Bug rtl-optimization/35643] New: gcc-4.2 -O1 -fstrict-aliasing misoptimization edwintorok at gmail dot com
2008-03-19 18:55 ` [Bug rtl-optimization/35643] " edwintorok at gmail dot com
2008-03-19 19:36 ` edwintorok at gmail dot com
2008-03-19 19:57 ` [Bug rtl-optimization/35643] [4.2 Regression] " rguenth at gcc dot gnu dot org
2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
2009-03-31 15:35 ` jsm28 at gcc dot gnu dot 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).