Gmane
From: Linus Torvalds <torvalds <at> linux-foundation.org>
Subject: Re: [PATCH] or51132.c: unaligned
Newsgroups: gmane.linux.kernel
Date: 2008-05-21 00:55:38 GMT (20 weeks, 3 days, 5 hours and 28 minutes ago)

On Wed, 21 May 2008, Al Viro wrote:

> On Tue, May 20, 2008 at 05:41:12PM -0700, Harvey Harrison wrote:
> 
> > > +	return buf[0] | (buf[1] << 8);
> > 
> > return get_unaligned_le16(buf);
> 
> And the point of that would be?

Perhaps better code generation?

I didn't look what 

	buf[0] | (buf[1] << 8)

generates, but on x86, get_unaligned_le16() should just boil down to

	*(unsigned short *)buf

which is certainly going to mostly generate better code (smaller, faster) 
than at least the most likely and straigthforward of the former.

(Just checked. Gcc is not smart enough to make those two loads plus a 
shift be one word load. At least not my version)

		Linus