public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA @ 2015-05-24 8:50 gccbugs at rooted dot tk 2015-05-24 8:59 ` [Bug c/66271] " gccbugs at rooted dot tk ` (7 more replies) 0 siblings, 8 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-05-24 8:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 Bug ID: 66271 Summary: -Os generates incorrect code on ARM possibly due to IPA Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: gccbugs at rooted dot tk Target Milestone: --- Created attachment 35609 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35609&action=edit code snippet and generated assembly GCC generates incorrect code when cross compiling for ARM on x86_64 on version 5.1.0 snapshot 5-20150519. The code is correct when -fno-ipa-sra is added as a switch, making me believe that this is an issue with IPA. This bug breaks compiling Linux, particularly lib/vsprintf.c. The problematic part of that file is attached as a code snippet along with the generated assembly. It was compiled with the following command line: arm-none-eabi-gcc bug.c -S -o bug.s -Os -Wall -Wextra -fverbose-asm -frecord-gcc-switches The issue occurs if spec.field_width is passed in as -1. LDRSH at line 96 correctly sign extends this 16-bit value to the 32-bit value -1. If !(spec.flags & LEFT), then the branch at line 100 is not taken. The loop does not run due to the comparison at line 104 (r0 is the result of strnlen(s, ...)). However, lines 103 and 105 effectively zero out the top 16 bits of r3, which is later written back to r5 at line 114. At line 132, r5 should be -2 or 0xFFFFFFFE but is instead 0x0000FFFE. Thus, the branch at line 136 is not taken even though it should not be taken ((len < spec.field_width--) should always be true if spec.field_width is negative and no wrapping occurs). The end result is that lines 49-51 in the C file run once even when they should not run. The code would work correctly if LSR were replaced with ASR on lines 105 and 135. This is done correctly at lines 110 and 140, which makes it odd that the other two lines would be different. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk @ 2015-05-24 8:59 ` gccbugs at rooted dot tk 2015-05-24 9:00 ` gccbugs at rooted dot tk ` (6 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-05-24 8:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 --- Comment #1 from gccbugs at rooted dot tk --- Oddly enough, the code is correct with -O2 instead of -Os. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk 2015-05-24 8:59 ` [Bug c/66271] " gccbugs at rooted dot tk @ 2015-05-24 9:00 ` gccbugs at rooted dot tk 2015-05-24 9:23 ` [Bug ipa/66271] " gccbugs at rooted dot tk ` (5 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-05-24 9:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 --- Comment #2 from gccbugs at rooted dot tk --- Created attachment 35610 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35610&action=edit correct code with -O2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ipa/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk 2015-05-24 8:59 ` [Bug c/66271] " gccbugs at rooted dot tk 2015-05-24 9:00 ` gccbugs at rooted dot tk @ 2015-05-24 9:23 ` gccbugs at rooted dot tk 2015-05-24 9:26 ` gccbugs at rooted dot tk ` (4 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-05-24 9:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 --- Comment #3 from gccbugs at rooted dot tk --- Created attachment 35611 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35611&action=edit gcc -v output ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ipa/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk ` (2 preceding siblings ...) 2015-05-24 9:23 ` [Bug ipa/66271] " gccbugs at rooted dot tk @ 2015-05-24 9:26 ` gccbugs at rooted dot tk 2015-05-24 9:26 ` gccbugs at rooted dot tk ` (3 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-05-24 9:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 --- Comment #5 from gccbugs at rooted dot tk --- Created attachment 35613 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35613&action=edit C source code ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ipa/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk ` (3 preceding siblings ...) 2015-05-24 9:26 ` gccbugs at rooted dot tk @ 2015-05-24 9:26 ` gccbugs at rooted dot tk 2015-06-07 22:58 ` wilson at gcc dot gnu.org ` (2 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-05-24 9:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 --- Comment #4 from gccbugs at rooted dot tk --- Created attachment 35612 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35612&action=edit incorrect output wiith -Os ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ipa/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk ` (4 preceding siblings ...) 2015-05-24 9:26 ` gccbugs at rooted dot tk @ 2015-06-07 22:58 ` wilson at gcc dot gnu.org 2015-06-08 2:10 ` gccbugs at rooted dot tk 2015-09-02 16:12 ` wilson at gcc dot gnu.org 7 siblings, 0 replies; 9+ messages in thread From: wilson at gcc dot gnu.org @ 2015-06-07 22:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 Jim Wilson <wilson at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wilson at gcc dot gnu.org --- Comment #6 from Jim Wilson <wilson at gcc dot gnu.org> --- This appears to be the same problem as 65932. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ipa/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk ` (5 preceding siblings ...) 2015-06-07 22:58 ` wilson at gcc dot gnu.org @ 2015-06-08 2:10 ` gccbugs at rooted dot tk 2015-09-02 16:12 ` wilson at gcc dot gnu.org 7 siblings, 0 replies; 9+ messages in thread From: gccbugs at rooted dot tk @ 2015-06-08 2:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 --- Comment #7 from gccbugs at rooted dot tk --- Seems like it is indeed the same issue. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ipa/66271] -Os generates incorrect code on ARM possibly due to IPA 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk ` (6 preceding siblings ...) 2015-06-08 2:10 ` gccbugs at rooted dot tk @ 2015-09-02 16:12 ` wilson at gcc dot gnu.org 7 siblings, 0 replies; 9+ messages in thread From: wilson at gcc dot gnu.org @ 2015-09-02 16:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66271 Jim Wilson <wilson at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |DUPLICATE --- Comment #9 from Jim Wilson <wilson at gcc dot gnu.org> --- *** This bug has been marked as a duplicate of bug 65932 *** ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-09-02 16:12 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-05-24 8:50 [Bug ipa/66271] New: -Os generates incorrect code on ARM possibly due to IPA gccbugs at rooted dot tk 2015-05-24 8:59 ` [Bug c/66271] " gccbugs at rooted dot tk 2015-05-24 9:00 ` gccbugs at rooted dot tk 2015-05-24 9:23 ` [Bug ipa/66271] " gccbugs at rooted dot tk 2015-05-24 9:26 ` gccbugs at rooted dot tk 2015-05-24 9:26 ` gccbugs at rooted dot tk 2015-06-07 22:58 ` wilson at gcc dot gnu.org 2015-06-08 2:10 ` gccbugs at rooted dot tk 2015-09-02 16:12 ` wilson 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).