[RFC] Optimize __arch_swab32 and __arch_swab16
Joakim Tjernlund
joakim.tjernlund at transmode.se
Thu Aug 11 18:51:33 EST 2011
Andreas Schwab <schwab at redhat.com> wrote on 2011/08/11 10:45:42:
>
> Joakim Tjernlund <joakim.tjernlund at transmode.se> writes:
>
> > unsigned short my__arch_swab16(unsigned short value)
> > {
> > __asm__("rlwimi %0,%0,16,0x00ff0000"
> > : "+r" (value));
>
> You are creating a value that does not fit in a short.
Short is passed in a 32 bit register with the upper 16 bits cleared. I just
temporarily use the upper bits and shift it back with the next insn:
__asm__("rlwinm %0,%0,24,0x0000ffff"
: "+r"(value));
Can I not use the upper 16 bits in this manner?
Jocke
More information about the Linuxppc-dev
mailing list