From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: [PATCH] lib/crypto: x86/nh: Optimize nh_avx2()
Date: Sat, 7 Nov 2026 14:02:59 -0800 [thread overview]
Message-ID: <20261107220259.GM137269@quark> (raw)
In-Reply-To: <20261105042442.308062-1-ebiggers@kernel.org>
On Wed, Nov 04, 2026 at 08:24:42PM -0800, Eric Biggers wrote:
> Various microoptimizations for nh_avx2(). Nothing too exciting:
>
> - Instead of adding the message words to the key words and then
> permuting both, do the following: permute both when loading, add the
> permuted words, and multiply together adjacent pairs. This saves one
> vpshufd instruction per 32 bytes processed, and the ones that remain
> are now better separated in the flow.
>
> - Reassign register aliases to put the most frequently used variables in
> %ymm0-%ymm7, which take fewer bytes to encode in many instructions.
>
> - Update the registers used in _nh_2xstride() to match nh_sse2() and
> eliminate the need for T7.
>
> - Replace the initial 'add $0x20, KEY' with base+displacement
> addressing, which was already being used anyway in most cases.
>
> - Update the horizontal sum algorithm at the end of the function to save
> a couple instructions.
>
> nh_avx2() shrinks from 664 bytes to 518 bytes, and a quick benchmark
> shows 1% faster Adiantum encryption on x86_64.
>
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> lib/crypto/x86/nh-avx2.S | 116 +++++++++++++++++++--------------------
> 1 file changed, 57 insertions(+), 59 deletions(-)
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next
- Eric
prev parent reply other threads:[~2026-11-07 22:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 4:24 [PATCH] lib/crypto: x86/nh: Optimize nh_avx2() Eric Biggers
2026-11-07 22:02 ` Eric Biggers [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=20261107220259.GM137269@quark \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@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.