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: [PATCH] Optimize manual byte swap implementations -refreshed


Andreas Krebbel wrote:
Hi Michael,

I'm just wondering out loud whether it would be useful to add tests of bswap
from a memory location in addition to a register (rs6000's main bswap is
load from and store to memory, and from s390.md, it looks like the s390 also
has a bswap from memory). Most of the other bswap targets like the x86 are
register only, so presumably it would would work also.

Yes that works. On S/390 the memory variants will be used when having a bswap implementation with a memory source operand.

Also of interest are constructions like


unsigned littleendian32(unsigned char *p)
{
  return p[3] << 24 | p[2] << 16 | p[1] << 8 | p[0];
}

unsigned bigendian32(unsigned char *p)
{
  return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
}

which, ideally, would be converted to an (unaligned)
word read and a bswap depending on the native
endienness of the target.  Even more ideally, we'd
figure out that the word read may actually be aligned.


r~



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