Re: [PATCH] or51132.c: unaligned
From: Linus Torvalds
Date: Tue May 20 2008 - 22:02:30 EST
On Wed, 21 May 2008, Al Viro wrote:
>
> FWIW, I wonder how they really compare on misaligned and whether it would
> make sense for gcc to try and generate a single load on targets that are
> known to allow that...
It would almost certainly help on x86. The cost of an unaligned integer
access that doesn't cross a cache-fetch boundary (8 bytes on older CPU's,
16 or 32 bytes on newer ones) is zero, last I saw. IOW, there are
misaligned cases that have a higher cost, but they are pretty rare, and
especially so with small data and modern CPU's.
So no disadvantage for 95% of all cases, and the advantage of doing just a
single instruction, rather than four (2 zero-extending loads, a shift and
an add/or, with data dependencies on most of them).
Linus
--
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/