public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "aweiner at lsil dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/14896] New: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop Date: Thu, 08 Apr 2004 22:50:00 -0000 [thread overview] Message-ID: <20040408225018.14896.aweiner@lsil.com> (raw) Version: powerpcle-440-eabi-gcc (GCC) 3.4.0 20040225 (prerelease) When using the "-Os" compiler option, the optimizer will improperly optimize- out the assignment of a structure field if that field is the FIRST field within the structure AND the assignemnt is within an infinite-loop block. Example: typedef struct { int a; int b; } TEST; TEST t; /* also fails if 't' is local to foo() */ void foo(void) { for (;;) { /* while (1) also fails */ t.a = 5; } } Code generated: 00000000 <foo>: 0: 00 00 00 48 b 0 <foo> Any of the following changes to the above source cause the compiler to generate the proper code: * Assign second field ('b') of structure rather than first ('a') * Move assignemnt outside of "for(;;)" loop * Access field through pointer rather than instance * Call to a non-inlined function is made within loop block * Compile without "-Os" Below is the compiler output when the second field ('b') is assigned instead of the first ("t.b = 5" vs. "t.a = 5"): 00000000 <foo>: 0: 00 00 20 3d lis r9,0 4: 05 00 00 38 li r0,5 8: 00 00 29 39 addi r9,r9,0 c: 04 00 09 90 stw r0,4(r9) 10: fc ff ff 4b b c <foo+0xc> -- Summary: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P1 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aweiner at lsil dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14896
next reply other threads:[~2004-04-08 22:50 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-04-08 22:50 aweiner at lsil dot com [this message] 2004-04-08 23:06 ` [Bug c/14896] " pinskia at gcc dot gnu dot org 2004-04-12 15:40 ` aweiner at lsil dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040408225018.14896.aweiner@lsil.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).