From: David Laight <David.Laight@ACULAB.COM>
To: 'Charlie Jenkins' <charlie@rivosinc.com>,
Conor Dooley <conor@kernel.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>
Subject: RE: [PATCH v2 1/5] riscv: Checksum header
Date: Sun, 10 Sep 2023 21:20:33 +0000 [thread overview]
Message-ID: <cec0f23506a54b9aaaef054ea949e4aa@AcuMS.aculab.com> (raw)
In-Reply-To: <ZPoMAGYlIxPZsE7+@ghost>
...
> > > +/*
> > > + * Fold a partial checksum without adding pseudo headers
> > > + */
> > > +static inline __sum16 csum_fold(__wsum sum)
> > > +{
> > > + sum += (sum >> 16) | (sum << 16);
> > > + return (__force __sum16)(~(sum >> 16));
> > > +}
I'm intrigued, gcc normally compiler that quite well.
The very similar (from arch/arc):
return (~sum - rol32(sum, 16)) >> 16;
is slightly better on most architectures.
(Especially if the ~sum and rol() can be executed together.)
The only odd archs I saw were sparc32 (carry flag bug no rotate)
and arm (barrel shifter on all instructions).
It is better than the current asm for a lot of archs including x64.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-09-10 21:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 4:46 [PATCH v2 0/5] riscv: Add fine-tuned checksum functions Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 1/5] riscv: Checksum header Charlie Jenkins
2023-09-07 9:40 ` Conor Dooley
2023-09-07 17:44 ` Charlie Jenkins
2023-09-10 21:20 ` David Laight [this message]
2023-09-11 18:16 ` Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 2/5] riscv: Add checksum library Charlie Jenkins
2023-09-07 9:52 ` Conor Dooley
2023-09-07 17:47 ` Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 3/5] riscv: Vector checksum header Charlie Jenkins
2023-09-07 9:47 ` Conor Dooley
2023-09-07 17:43 ` Charlie Jenkins
2023-09-07 9:58 ` Conor Dooley
2023-09-07 17:41 ` Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 4/5] riscv: Vector checksum library Charlie Jenkins
2023-09-06 4:46 ` [PATCH v2 5/5] riscv: Test checksum functions Charlie Jenkins
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=cec0f23506a54b9aaaef054ea949e4aa@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=conor@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/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 NNTP newsgroup(s).