crypto: x86/sha256-ni - optimize code size
authorEric Biggers <ebiggers@google.com>
Thu, 11 Apr 2024 16:23:58 +0000 (09:23 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 19 Apr 2024 10:54:18 +0000 (18:54 +0800)
commit59e62b20acc3161cafe3dce52cd3d6211379c4c5
treed875a64b766dd449e772506182e166b61bca35b9
parent1b5ddb067df930c8232020cd059b2060275427cf
crypto: x86/sha256-ni - optimize code size

- Load the SHA-256 round constants relative to a pointer that points
  into the middle of the constants rather than to the beginning.  Since
  x86 instructions use signed offsets, this decreases the instruction
  length required to access some of the later round constants.

- Use punpcklqdq or punpckhqdq instead of longer instructions such as
  pshufd, pblendw, and palignr.  This doesn't harm performance.

The end result is that sha256_ni_transform shrinks from 839 bytes to 791
bytes, with no loss in performance.

Suggested-by: Stefan Kanthak <stefan.kanthak@nexgo.de>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/sha256_ni_asm.S