Linux-arch Archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Charlie Jenkins <charlie@rivosinc.com>
Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Helge Deller <deller@gmx.de>, Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH 4/4] parisc: checksum: Optimize from32to16
Date: Thu, 22 Feb 2024 08:04:49 -0800	[thread overview]
Message-ID: <e00be589-4e9e-48ec-8a25-ad7460f304fa@roeck-us.net> (raw)
In-Reply-To: <20240221-parisc_use_generic_checksum-v1-4-ad34d895fd1b@rivosinc.com>

On Wed, Feb 21, 2024 at 06:37:14PM -0800, Charlie Jenkins wrote:
> Replace the shifting and masking of x with a rotation. This generates
> better assembly.
> 
> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  arch/parisc/lib/checksum.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c
> index eaa660491e24..1ae8cc730d13 100644
> --- a/arch/parisc/lib/checksum.c
> +++ b/arch/parisc/lib/checksum.c
> @@ -27,11 +27,8 @@
>  
>  static inline unsigned short from32to16(unsigned int x)
>  {
> -	/* 32 bits --> 16 bits + carry */
> -	x = (x & 0xffff) + (x >> 16);
> -	/* 16 bits + carry --> 16 bits including carry */
> -	x = (x & 0xffff) + (x >> 16);
> -	return (unsigned short)x;
> +	x += ror32(x, 16);
> +	return (unsigned short)(x >> 16);
>  }
>  
>  unsigned int do_csum(const unsigned char *buff, int len)
> 
> -- 
> 2.34.1
> 

      reply	other threads:[~2024-02-22 16:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  2:37 [PATCH 0/4] parisc: checksum: Use generic implementations and optimize checksum Charlie Jenkins
2024-02-22  2:37 ` [PATCH 1/4] asm-generic headers: Allow csum_partial arch override Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck
2024-02-22  2:37 ` [PATCH 2/4] parisc: checksum: Use generic implementations Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck
2024-02-22  2:37 ` [PATCH 3/4] parisc: checksum: Remove folding from csum_partial Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck
2024-02-22  2:37 ` [PATCH 4/4] parisc: checksum: Optimize from32to16 Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck [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=e00be589-4e9e-48ec-8a25-ad7460f304fa@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=charlie@rivosinc.com \
    --cc=deller@gmx.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).