public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/52244] New: [4.5/4.6/4.7 Regression] wrong code for function returning union between int and _Bool at O > 2, with no-early-inlining
@ 2012-02-14 10:10 iains at gcc dot gnu.org
  2012-02-14 10:25 ` [Bug target/52244] " iains at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2012-02-14 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52244
           Summary: [4.5/4.6/4.7 Regression] wrong code for function
                    returning union between int and _Bool at O > 2, with
                    no-early-inlining
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: iains@gcc.gnu.org
                CC: dominiq@lps.ens.fr
            Target: powerpc-*-darwin9


This was revealed by the test-case attached to PR51528.

in the following:

extern void abort (void);

typedef union u_r 
{
  _Bool b;
  int c;
} u_t;

u_t
bar (void)
{
  u_t u;
  u.c = 0x1234;
  return u;
}

u_t  __attribute__ ((noinline))
foo (void)
{
  u_t u;

  u.b = 1;
  u = bar ();

  return u;
}

int main (int argc, char **argv)
{
  u_t u = foo ();
  if (u.c != 0x1234)
    abort ();
  return 0;
}

====

for  -O2 -fno-early-inlining (at m32)

foo is compiled as (wrong):

        .globl _foo
_foo:
        li r9,0
        stw r9,0(r3)
        blr

instead of (correct):

        .globl _foo
_foo:
        li r2,4660
        stw r2,0(r3)
        blr

======

It only appears to happen for the case where the union is with an item of the
same size as _Bool (which is 32 bits on powerpc-darwin).  Replacing 'c' with a
short or a long long or even char[4] will cause the problem to vanish.

======


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

end of thread, other threads:[~2012-02-14 15:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-14 10:10 [Bug target/52244] New: [4.5/4.6/4.7 Regression] wrong code for function returning union between int and _Bool at O > 2, with no-early-inlining iains at gcc dot gnu.org
2012-02-14 10:25 ` [Bug target/52244] " iains at gcc dot gnu.org
2012-02-14 10:31 ` iains at gcc dot gnu.org
2012-02-14 10:47 ` [Bug middle-end/52244] " iains at gcc dot gnu.org
2012-02-14 10:52 ` jakub at gcc dot gnu.org
2012-02-14 10:55 ` jakub at gcc dot gnu.org
2012-02-14 10:58 ` rguenth at gcc dot gnu.org
2012-02-14 12:10 ` rguenth at gcc dot gnu.org
2012-02-14 13:25 ` rguenth at gcc dot gnu.org
2012-02-14 15:34 ` rguenth at gcc dot gnu.org
2012-02-14 15:38 ` rguenth 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).