From: David Laight <David.Laight@ACULAB.COM>
To: 'WANG Xuerui' <kernel@xen0n.name>,
'Bibo Mao' <maobibo@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
"loongarch@lists.linux.dev" <loongarch@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] LoongArch: add checksum optimization for 64-bit system
Date: Wed, 8 Feb 2023 14:19:27 +0000 [thread overview]
Message-ID: <7636a7bebfd44e378c5b16d6fd355232@AcuMS.aculab.com> (raw)
In-Reply-To: <5b3c9b61-7fd5-f50c-32ba-e857090b71bc@xen0n.name>
From: WANG Xuerui
> Sent: 08 February 2023 13:48
...
> Yeah LoongArch can do rotates, and your suggestion can indeed reduce one
> insn from every invocation of csum_fold.
>
> From this:
>
> 000000000000096c <csum_fold>:
> sum += (sum >> 16) | (sum << 16);
> 96c: 004cc08c rotri.w $t0, $a0, 0x10
> 970: 00101184 add.w $a0, $t0, $a0
> return ~(__force __sum16)(sum >> 16);
> 974: 0044c084 srli.w $a0, $a0, 0x10
> 978: 00141004 nor $a0, $zero, $a0
> }
> 97c: 006f8084 bstrpick.w $a0, $a0, 0xf, 0x0
> 980: 4c000020 jirl $zero, $ra, 0
>
> To:
>
> 0000000000000984 <csum_fold2>:
> return (~sum - rol32(sum, 16)) >> 16;
> 984: 0014100c nor $t0, $zero, $a0
> return (x << amt) | (x >> (32 - amt));
> 988: 004cc084 rotri.w $a0, $a0, 0x10
> return (~sum - rol32(sum, 16)) >> 16;
> 98c: 00111184 sub.w $a0, $t0, $a0
> }
> 990: 00df4084 bstrpick.d $a0, $a0, 0x1f, 0x10
> 994: 4c000020 jirl $zero, $ra, 0
It is actually slightly better than that.
In the csum_fold2 version the first two instructions
are independent - so can execute in parallel on some cpu.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-02-08 14:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 4:01 Bibo Mao
2023-02-08 13:12 ` David Laight
2023-02-08 13:48 ` WANG Xuerui
2023-02-08 14:19 ` David Laight [this message]
2023-02-09 1:16 ` maobibo
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=7636a7bebfd44e378c5b16d6fd355232@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=chenhuacai@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
/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®