public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/13984] New: Bad code generated with -O0 @ 2004-02-02 17:38 klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] " klawson at ad-holdings dot co dot uk ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: klawson at ad-holdings dot co dot uk @ 2004-02-02 17:38 UTC (permalink / raw) To: gcc-bugs The following code was generated by sh-elf-gcc. The space variable (a long) is taken from @(0,r3) and stored in r1. The len variable is taken from @(4.r3) and stored in r3. A subtract operation is then performed, and r3 is used to find where to store the result. This is bad because r3 was used as temporary storage for the subtract operation and no longer contains a reference to memory. The final mov.l instruction causes a fault as it is storing to a misaligned (nonsense) address. 576 space -= len; - 0x8c0bb984 <cyg_sosend+2148>: mov #64,r3 - 0x8c0bb986 <cyg_sosend+2150>: add r14,r3 - 0x8c0bb988 <cyg_sosend+2152>: mov #64,r3 - 0x8c0bb98a <cyg_sosend+2154>: add r14,r3 - 0x8c0bb98c <cyg_sosend+2156>: mov.l @(0,r3),r1 - 0x8c0bb98e <cyg_sosend+2158>: mov.l @(4,r3),r3 - 0x8c0bb990 <cyg_sosend+2160>: sub r3,r1 - 0x8c0bb992 <cyg_sosend+2162>: mov.l r1,@(0,r3) The following CFLAGS are used: -mb -m3 -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -ggdb -O0 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority Using optimisation level 1, the code is generated as: 576 space -= len; - 0x8c0a6080 <cyg_sosend+1280>: sub r8,r11 -- Summary: Bad code generated with -O0 Product: gcc Version: 3.2.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: klawson at ad-holdings dot co dot uk CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-cygwin GCC target triplet: sh-elf-gcc http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/13984] Bad code generated with -O0 2004-02-02 17:38 [Bug c/13984] New: Bad code generated with -O0 klawson at ad-holdings dot co dot uk @ 2004-02-02 17:40 ` klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] sh-elf-gcc: " klawson at ad-holdings dot co dot uk ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: klawson at ad-holdings dot co dot uk @ 2004-02-02 17:40 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ------- Created an attachment (id=5652) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5652&action=view) Result of -save-temps -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/13984] sh-elf-gcc: Bad code generated with -O0 2004-02-02 17:38 [Bug c/13984] New: Bad code generated with -O0 klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] " klawson at ad-holdings dot co dot uk @ 2004-02-02 17:40 ` klawson at ad-holdings dot co dot uk 2004-02-02 17:52 ` [Bug target/13984] " pinskia at gcc dot gnu dot org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: klawson at ad-holdings dot co dot uk @ 2004-02-02 17:40 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Summary|Bad code generated with -O0 |sh-elf-gcc: Bad code | |generated with -O0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/13984] sh-elf-gcc: Bad code generated with -O0 2004-02-02 17:38 [Bug c/13984] New: Bad code generated with -O0 klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] " klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] sh-elf-gcc: " klawson at ad-holdings dot co dot uk @ 2004-02-02 17:52 ` pinskia at gcc dot gnu dot org 2004-02-04 15:58 ` klawson at ad-holdings dot co dot uk 2004-02-04 16:10 ` pinskia at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-02-02 17:52 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-02 17:52 ------- Can you try on a more recent compiler like 3.3.2? -- What |Removed |Added ---------------------------------------------------------------------------- Component|c |target Keywords| |wrong-code http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/13984] sh-elf-gcc: Bad code generated with -O0 2004-02-02 17:38 [Bug c/13984] New: Bad code generated with -O0 klawson at ad-holdings dot co dot uk ` (2 preceding siblings ...) 2004-02-02 17:52 ` [Bug target/13984] " pinskia at gcc dot gnu dot org @ 2004-02-04 15:58 ` klawson at ad-holdings dot co dot uk 2004-02-04 16:10 ` pinskia at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: klawson at ad-holdings dot co dot uk @ 2004-02-04 15:58 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From klawson at ad-holdings dot co dot uk 2004-02-04 15:58 ------- Subject: Re: sh-elf-gcc: Bad code generated with -O0 Thanks. I tried compiling with 3.3.2 and the problem has disappeared. The code generated at -O0 and -O2 is now exactly the same for this bit of C, and is working in both cases. Many thanks, Kelvin. pinskia at gcc dot gnu dot org wrote: > ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-02 17:52 ------- > Can you try on a more recent compiler like 3.3.2? > -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/13984] sh-elf-gcc: Bad code generated with -O0 2004-02-02 17:38 [Bug c/13984] New: Bad code generated with -O0 klawson at ad-holdings dot co dot uk ` (3 preceding siblings ...) 2004-02-04 15:58 ` klawson at ad-holdings dot co dot uk @ 2004-02-04 16:10 ` pinskia at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-02-04 16:10 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-04 16:10 ------- Submiter reports this works correctly with a new compiler so closing. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED Target Milestone|--- |3.3.2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-02-04 16:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-02-02 17:38 [Bug c/13984] New: Bad code generated with -O0 klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] " klawson at ad-holdings dot co dot uk 2004-02-02 17:40 ` [Bug c/13984] sh-elf-gcc: " klawson at ad-holdings dot co dot uk 2004-02-02 17:52 ` [Bug target/13984] " pinskia at gcc dot gnu dot org 2004-02-04 15:58 ` klawson at ad-holdings dot co dot uk 2004-02-04 16:10 ` pinskia 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).