Re: [PATCH] i386: optimize swab64
From: Andi Kleen
Date: Mon Apr 25 2005 - 11:09:21 EST
On Mon, Apr 25, 2005 at 10:19:30AM +0300, Denis Vlasenko wrote:
> I noticed that swab64 explicitly swaps 32-bit halves, but this is
> not really needed because CPU is 32-bit anyway and we can
> just tell GCC to treat registers as being swapped.
No, we went through this exactly when the code was originally done.
gcc puts long long only into aligned register pairs, and with
register swap you need at least 4 registers which blows near
all possible registers away and completely breaks register
allocation in the function. Dont apply this!
> Example of resulting code:
> mov 0x20(%ecx,%edi,8),%eax
> mov 0x24(%ecx,%edi,8),%edx
> lea 0x1(%edi),%esi
> mov %esi,0xfffffdf4(%ebp)
> mov %eax,%ebx
> mov %edx,%esi
> bswap %ebx
> bswap %esi
> mov %esi,0xffffff74(%ebp,%edi,8)
> mov %ebx,0xffffff78(%ebp,%edi,8)
> As you can see, swap is achieved simply by using
> appropriate registers in last two insns.
> (Why does gcc do extra register moves just before bswaps
> is another question. No regression here, old code had them too)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/