swap instruction generation
Ian Lance Taylor
iant@google.com
Thu Sep 22 16:08:00 GMT 2011
naga raj <gnuuser.raj@gmail.com> writes:
> I have tried with all the possibilities that you have mentioned but
> swaph instruction was not generated.
> Instead of swaph compiler is generating
>
> 1f0: 64640408 bslli r3, r4, 8 (left shift )
>
> 1f4: 64840008 bsrli r4, r4, 8 (right shift)
>
> 1f8: 80632000 or r3, r3, r4 (or operation)
I have no other suggestions. I do see bswap:HI used on x86_64 for this
input file.
int swapb(int n)
{
return ((((n) & 0xff000000) >> 24)
| (((n) & 0x00ff0000) >> 8)
| (((n) & 0x0000ff00) << 8)
| (((n) & 0x000000ff) << 24));
}
short int swaph(unsigned short int n)
{
return ((((n) & 0xff00) >> 8)
| (((n) & 0xff) << 8));
}
int main(int a, unsigned short b)
{
a=swapb(a);
b=swaph(b);
return a + b;
}
Ian
More information about the Gcc-help
mailing list