This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: make sure struct real_value's bitfields are packed


$ cat /tmp/sign.c
int foo (int x)
{
  return ((x & 0xff) ^ 0x80) - 0x80;
}
$ gcc -S -O2 -fomit-frame-pointer /tmp/sign.c

foo:
        movsbl  4(%esp),%eax
        ret

Works on PowerPC, too. Curiously, it's not optimized like this if the return type is exactly the size we're extending to (it work if the return type is bigger or smaller):

$ cat sign.c
int foo (int x)
{
  return ((x & 0xffffffff) ^ 0x80000000) - 0x80000000;
}
$ cat sign.s
.foo:
        xoris 3,3,0x8000
        addis 3,3,0x8000
        extsw 3,3
        blr


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]