All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: David Newall <davidn@davidnewall.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Screwy arch/x86/include/asm/string_32.h
Date: Sat, 14 Mar 2009 15:53:02 -0700	[thread overview]
Message-ID: <49BC354E.4070809@goop.org> (raw)
In-Reply-To: <49BBD619.6050809@davidnewall.com>

David Newall wrote:
> There's a lot of weirdness in __constant_memcpy in
> arch/x86/include/asm/string_32.h (2.6.29-rc7).
>
>    1. The first switch is missing a case for n equal 7.
>   
That's because there's no way to copy 7 bytes in two operations of 1/2/4 
bytes; it would need to be 3 (4+2+1), which I guess the author deemed 
overly complex.

>    2. When n < 20, the four tests (n > 16, n > 12, n > 8 & n > 4)
>       execute identical statements; always 'asm volatile("movsl" :
>       "=&D"(edi), "=&S"(esi) : "0"(edi), "1"(esi) : "memory")'.
>   

movs is a string instruction which has the side-effect of incrementing 
esi and edi, so each if() falls through to copy the next 4 bytes.

However, the tail switch should probably use plain "mov" rather than 
"movs" because nobody uses esi/edi afterwards.

    J

      reply	other threads:[~2009-03-14 22:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-14 16:06 Screwy arch/x86/include/asm/string_32.h David Newall
2009-03-14 22:53 ` Jeremy Fitzhardinge [this message]

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=49BC354E.4070809@goop.org \
    --to=jeremy@goop.org \
    --cc=davidn@davidnewall.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.