public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anton at samba dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/45274]  New: __restrict__ type qualifier does not work on pointers to bitfields
Date: Fri, 13 Aug 2010 07:06:00 -0000	[thread overview]
Message-ID: <bug-45274-8090@http.gcc.gnu.org/bugzilla/> (raw)

I tested an svn build from 20100813 with the following code:

struct bar {
        unsigned int a:1, b:1, c:1, d:1, e:28;
};

void foo(struct bar * __restrict__ src, struct bar * __restrict__ dst)
{
        dst->a = src->a;
        dst->b = src->b;
        dst->c = src->c;
        dst->d = src->d;
        dst->e = src->e;
}

Built as 32bit, we see loads and stores as if the compiler is following pointer
aliasing rules:

# gcc -m32 -O2 -S foo.c 

foo:
        lwz 9,0(3)
        lwz 0,0(4)
        rlwimi 0,9,0,0,0
        stw 0,0(4)
        lwz 9,0(3)
        rlwimi 0,9,0,1,1
        stw 0,0(4)
        lwz 9,0(3)
        rlwimi 0,9,0,2,2
        stw 0,0(4)
        lwz 9,0(3)
        rlwimi 0,9,0,3,3
        stw 0,0(4)
        lwz 9,0(3)
        rlwimi 0,9,0,4,31
        stw 0,0(4)
        blr

Apologies if I am misusing or misinterpreting the use of __restrict__ here.

Also, when built as 64bit things are considerably more complex. Is there a
reason why we can't use the same code as 32bit?

# gcc -m64 -O2 -S foo.c
...
.L.foo:
        lwz 9,0(4)
        lwz 0,0(3)
        rlwinm 9,9,0,1,31
        rlwinm 0,0,0,0,0
        or 0,9,0
        stw 0,0(4)
        rlwinm 0,0,1,1,31
        rlwinm 0,0,31,0xffffffff
        lwz 9,0(3)
        rldicl 9,9,34,63
        slwi 9,9,30
        or 0,0,9
        stw 0,0(4)
        rlwinm 9,0,2,1,31
        rlwinm 9,9,30,0xffffffff
        lwz 0,0(3)
        rldicl 0,0,35,63
        slwi 0,0,29
        or 0,9,0
        stw 0,0(4)
        rlwinm 0,0,3,1,31
        rlwinm 0,0,29,0xffffffff
        lwz 9,0(3)
        rldicl 9,9,36,63
        slwi 9,9,28
        or 0,0,9
        stw 0,0(4)
        rlwinm 0,0,0,0,3
        lwz 9,0(3)
        rlwinm 9,9,0,4,31
        or 0,0,9
        stw 0,0(4)
        blr


-- 
           Summary: __restrict__ type qualifier does not work on pointers to
                    bitfields
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anton at samba dot org
GCC target triplet: powerpc64-unknown-linux-gnu


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


             reply	other threads:[~2010-08-13  7:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13  7:06 anton at samba dot org [this message]
2010-08-13  8:01 ` [Bug middle-end/45274] " jakub 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-45274-8090@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).