mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gmail.com>
To: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org
Subject: Bad Code generated from __{get,put}_unaligned functions
Date: Thu, 6 Aug 2009 13:56:12 -0400	[thread overview]
Message-ID: <b4198de60908061056m2b27402cjd25f94b6bbed0707@mail.gmail.com> (raw)

I was researching different ways of writing unaligned load/store
macros, so I checked how the kernel did it -- the most general way
possible. See include/linux/unaligned.h. As such, very bad code is
generated, for example on alpha with BWX, we can implement all these
functions with a single instruction, whereas we get stuff like this
generated from the generic functions.

__get_unaligned_le32:
    .frame $30,0,$26,0
    .prologue 0
    ldbu $0,1($16)
    ldbu $1,2($16)
    ldbu $2,3($16)
    ldbu $3,0($16)
    sll $1,16,$1
    sll $0,8,$0
    bis $0,$1,$0
    sll $2,24,$2
    bis $0,$3,$0
    bis $0,$2,$0
    addl $31,$0,$0
    ret $31,($26),1

4 load byte instructions, shift, shift, or, shift, or, or, sign extend
-- or ldl_u instruction. The code is more than doubly-bad for le64.

Do we use the generic functions for a reason I don't see? It appears
that it would be easy enough to add architecture-specific unaligned
get/put functions in arch/*/include/asm/unaligned.h

CC me on replies please.

Matt Turner

             reply	other threads:[~2009-08-06 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 17:56 Matt Turner [this message]
2009-08-06 18:39 ` Falk Hueffner
2009-08-08 22:27   ` Michael Cree

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=b4198de60908061056m2b27402cjd25f94b6bbed0707@mail.gmail.com \
    --to=mattst88@gmail.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®