The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Harvey Harrison <harvey.harrison@gmail.com>,
	Al Viro <viro@ftp.linux.org.uk>,
	mchehab@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] or51132.c: unaligned
Date: Tue, 20 May 2008 17:55:38 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0805201752230.3081@woody.linux-foundation.org> (raw)
In-Reply-To: <20080521004548.GD28946@ZenIV.linux.org.uk>



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

  parent reply	other threads:[~2008-05-21  0:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-21  0:33 [PATCH] or51132.c: unaligned Al Viro
2008-05-21  0:41 ` Harvey Harrison
2008-05-21  0:45   ` Al Viro
2008-05-21  0:51     ` Harvey Harrison
2008-05-21  0:56       ` Al Viro
2008-05-21  0:55     ` Linus Torvalds [this message]
2008-05-21  1:18       ` Al Viro
2008-05-21  2:02         ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.10.0805201752230.3081@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=harvey.harrison@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox