This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/35643] gcc-4.2 -O1 -fstrict-aliasing misoptimization
- From: "edwintorok at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Mar 2008 18:54:21 -0000
- Subject: [Bug rtl-optimization/35643] gcc-4.2 -O1 -fstrict-aliasing misoptimization
- References: <bug-35643-15165@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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