public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jiez at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/45144]  New: SRA optimization issue of bit-field
Date: Fri, 30 Jul 2010 15:12:00 -0000	[thread overview]
Message-ID: <bug-45144-11162@http.gcc.gnu.org/bugzilla/> (raw)

For the following code:

void baz (unsigned);

extern unsigned buf[];

struct A
{
  unsigned a1:10;
  unsigned a2:3;
  unsigned:19;
};

union TMP
{
  struct A a;
  unsigned int b;
};

static unsigned
foo (struct A *p)
{
  union TMP t;
  struct A x;

  x = *p;
  t.a = x;
  return t.b;
}

void
bar (unsigned orig, unsigned *new)
{
  struct A a;
  union TMP s;

  s.b = orig;
  a = s.a;
  if (a.a1)
    baz (a.a2);
  *new = foo (&a);
}

"arm-none-eabi-gcc -O2" generates:

bar:
        @ Function supports interworking.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        stmfd   sp!, {r3, r4, r5, r6, r7, lr}
        mov     r4, r0, asl #22
        mov     r5, r0, lsr #10
        movs    r4, r4, lsr #22
        mov     r6, r1
        and     r5, r5, #7
        mov     r7, r0, lsr #13
        movne   r0, r5
        blne    baz
.L2:
        orr     r4, r4, r5, asl #10
        orr     r7, r4, r7, asl #13
        str     r7, [r6, #0]
        ldmfd   sp!, {r3, r4, r5, r6, r7, lr}
        bx      lr

while "arm-none-eabi-gcc -O2 -fno-tree-sra" generates:

bar:
        @ Function supports interworking.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        stmfd   sp!, {r3, r4, r5, lr}
        movs    r3, r0, asl #22
        mov     r4, r0
        mov     r5, r1
        movne   r0, r0, lsr #10
        andne   r0, r0, #7
        blne    baz
.L2:
        str     r4, [r5, #0]
        ldmfd   sp!, {r3, r4, r5, lr}
        bx      lr


-- 
           Summary: SRA optimization issue of bit-field
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jiez at gcc dot gnu dot org
GCC target triplet: arm-none-eabi


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


             reply	other threads:[~2010-07-30 15:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-30 15:12 jiez at gcc dot gnu dot org [this message]
2010-07-30 17:10 ` [Bug tree-optimization/45144] " jakub at gcc dot gnu dot org
2010-07-31  9:25 ` rguenth at gcc dot gnu dot org
2010-08-02  4:34 ` jiez at gcc dot gnu dot org
2010-08-02  7:54 ` ramana at gcc dot gnu dot org
2010-08-05  3:06 ` jiez at gcc dot gnu dot 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-45144-11162@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).