public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "iains at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [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
Date: Tue, 14 Feb 2012 10:10:00 -0000	[thread overview]
Message-ID: <bug-52244-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

======


             reply	other threads:[~2012-02-14 10:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14 10:10 iains at gcc dot gnu.org [this message]
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

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=bug-52244-4@http.gcc.gnu.org/bugzilla/ \
    --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: link
Be 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).