public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50254] New: gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code
@ 2011-08-31 17:18 vzapolskiy at gmail dot com
  2011-09-01  8:38 ` [Bug c/50254] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vzapolskiy at gmail dot com @ 2011-08-31 17:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50254

             Bug #: 50254
           Summary: gcc-4.5 -fstrict-aliasing -fschedule-insns
                    optimization produces wrong code
    Classification: Unclassified
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vzapolskiy@gmail.com


Created attachment 25154
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25154
test code

Hello,

recently my team found a problem in our code after a gcc compiler update from
gcc-4.4 to gcc-4.5. I've extracted the problematic code snippet, you can find
it in the attachement.

The problem is unveiled, if you try to compile the test with various
combinations of base optimization and strict-aliasing and fschedule-insns
flags.

For instance that's what I get on my amd64/gcc-4.6.0:
<log>
$ gcc -O0                                          test.c -o test && ./test
$ gcc -O0                      -fschedule-insns    test.c -o test && ./test
$ gcc -O0 -fstrict-aliasing                        test.c -o test && ./test
$ gcc -O0 -fstrict-aliasing    -fschedule-insns    test.c -o test && ./test
Aborted
$ gcc -O1                                          test.c -o test && ./test
$ gcc -O1                      -fschedule-insns    test.c -o test && ./test
$ gcc -O1 -fstrict-aliasing                        test.c -o test && ./test
Aborted
$ gcc -O1 -fstrict-aliasing    -fschedule-insns    test.c -o test && ./test
Aborted
$ gcc -O2                                          test.c -o test && ./test
Aborted
$ gcc -O2 -fno-strict-aliasing                     test.c -o test && ./test
$ gcc -O2                      -fno-schedule-insns test.c -o test && ./test
Aborted
$ gcc -O2 -fno-strict-aliasing -fno-schedule-insns test.c -o test && ./test
$ 
</log>

The problem described above is reproducible on armv7, i386, amd64 target
architectures with gcc-4.5 and gcc-4.6 compilers.

The issue might be invalid, but because it hasn't been known with gcc-4.4, I'd
greatly appreciate to get some comments from GCC team on it.

Thank you in advance.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/50254] gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code
  2011-08-31 17:18 [Bug c/50254] New: gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code vzapolskiy at gmail dot com
@ 2011-09-01  8:38 ` rguenth at gcc dot gnu.org
  2011-09-01  9:37 ` vzapolskiy at gmail dot com
  2011-09-01  9:38 ` vzapolskiy at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-01  8:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50254

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-01 08:38:15 UTC ---
        qentry->next      = (void *)qhead;

is voiolating strict aliasing rules if you ever end up loading/storing
qentry->next->{prev,next}.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/50254] gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code
  2011-08-31 17:18 [Bug c/50254] New: gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code vzapolskiy at gmail dot com
  2011-09-01  8:38 ` [Bug c/50254] " rguenth at gcc dot gnu.org
@ 2011-09-01  9:37 ` vzapolskiy at gmail dot com
  2011-09-01  9:38 ` vzapolskiy at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: vzapolskiy at gmail dot com @ 2011-09-01  9:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50254

Vladimir Zapolskiy <vzapolskiy at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #25154|0                           |1
        is obsolete|                            |

--- Comment #2 from Vladimir Zapolskiy <vzapolskiy at gmail dot com> 2011-09-01 09:37:00 UTC ---
Created attachment 25157
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25157
test code

(In reply to comment #1)
>         qentry->next      = (void *)qhead;
> 
> is voiolating strict aliasing rules if you ever end up loading/storing
> qentry->next->{prev,next}.

Thank you very much for the quick response.

I managed to reduce a test case and hopefully understand strict aliasing rules.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/50254] gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code
  2011-08-31 17:18 [Bug c/50254] New: gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code vzapolskiy at gmail dot com
  2011-09-01  8:38 ` [Bug c/50254] " rguenth at gcc dot gnu.org
  2011-09-01  9:37 ` vzapolskiy at gmail dot com
@ 2011-09-01  9:38 ` vzapolskiy at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: vzapolskiy at gmail dot com @ 2011-09-01  9:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50254

Vladimir Zapolskiy <vzapolskiy at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #3 from Vladimir Zapolskiy <vzapolskiy at gmail dot com> 2011-09-01 09:37:33 UTC ---
Closed, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-01  9:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31 17:18 [Bug c/50254] New: gcc-4.5 -fstrict-aliasing -fschedule-insns optimization produces wrong code vzapolskiy at gmail dot com
2011-09-01  8:38 ` [Bug c/50254] " rguenth at gcc dot gnu.org
2011-09-01  9:37 ` vzapolskiy at gmail dot com
2011-09-01  9:38 ` vzapolskiy at gmail dot com

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).