public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14896] New: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop
@ 2004-04-08 22:50 aweiner at lsil dot com
  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
  0 siblings, 2 replies; 3+ messages in thread
From: aweiner at lsil dot com @ 2004-04-08 22:50 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c/14896] Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop
  2004-04-08 22:50 [Bug c/14896] New: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop aweiner at lsil dot com
@ 2004-04-08 23:06 ` pinskia at gcc dot gnu dot org
  2004-04-12 15:40 ` aweiner at lsil dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-08 23:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-08 23:06 -------
This is invalid, you should use volatile keyword to keep the store in there.

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


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


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

* [Bug c/14896] Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop
  2004-04-08 22:50 [Bug c/14896] New: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop aweiner at lsil dot com
  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
  1 sibling, 0 replies; 3+ messages in thread
From: aweiner at lsil dot com @ 2004-04-12 15:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From aweiner at lsil dot com  2004-04-12 15:17 -------
Subject: RE:  Fails to generate code for structure field assi
	gnment when assigning first field and assignment is within an infinite lo
	op

That's plausible, but why does the compiler not exhibit consistent behavior
across all fields of the structure? It only seems exhibits this behavior for
the first element of the structure; it compiles assignments for all
subsequent elements.

-----Original Message-----
From: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org]
Sent: Thursday, April 08, 2004 4:07 PM
To: aweiner@lsil.com
Subject: [Bug c/14896] Fails to generate code for structure field
assignment when assigning first field and assignment is within an
infinite loop



------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-08
23:06 -------
This is invalid, you should use volatile keyword to keep the store in there.

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


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

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.


-- 


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


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

end of thread, other threads:[~2004-04-12 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-08 22:50 [Bug c/14896] New: Fails to generate code for structure field assignment when assigning first field and assignment is within an infinite loop aweiner at lsil dot com
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

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