diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-02-09 03:30:23 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-02-09 03:30:23 +0300 |
commit | 461a994b09c5022b93bccccf903b39438d61bbf1 (patch) | |
tree | 81c00839ff70b8e95b3a0511e7f6d50b0fcc320e /libbb | |
parent | c0ff0d4528d718c20b9ca2290bd10d59e9f794a3 (diff) |
libbb/sha256: code shrink in 32-bit x86
function old new delta
sha256_process_block64_shaNI 697 676 -21
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/hash_md5_sha256_x86-32_shaNI.S | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libbb/hash_md5_sha256_x86-32_shaNI.S b/libbb/hash_md5_sha256_x86-32_shaNI.S index a849dfcc2..846230e3e 100644 --- a/libbb/hash_md5_sha256_x86-32_shaNI.S +++ b/libbb/hash_md5_sha256_x86-32_shaNI.S @@ -34,16 +34,18 @@ #define XMMTMP %xmm7 +#define SHUF(a,b,c,d) $(a+(b<<2)+(c<<4)+(d<<6)) + .balign 8 # allow decoders to fetch at least 2 first insns sha256_process_block64_shaNI: - movu128 76+0*16(%eax), STATE0 - movu128 76+1*16(%eax), STATE1 - shuf128_32 $0xB1, STATE0, STATE0 /* CDAB */ - shuf128_32 $0x1B, STATE1, STATE1 /* EFGH */ + movu128 76+0*16(%eax), STATE1 /* DCBA (msb-to-lsb: 3,2,1,0) */ + movu128 76+1*16(%eax), STATE0 /* HGFE */ +/* shufps takes dwords 0,1 from *2nd* operand, and dwords 2,3 from 1st one */ mova128 STATE0, XMMTMP - palignr $8, STATE1, STATE0 /* ABEF */ - pblendw $0xF0, XMMTMP, STATE1 /* CDGH */ + shufps SHUF(1,0,1,0), STATE1, STATE0 /* ABEF */ + shufps SHUF(3,2,3,2), STATE1, XMMTMP /* CDGH */ + mova128 XMMTMP, STATE1 /* XMMTMP holds flip mask from here... */ mova128 PSHUFFLE_BSWAP32_FLIP_MASK, XMMTMP @@ -231,18 +233,19 @@ sha256_process_block64_shaNI: sha256rnds2 STATE1, STATE0 /* Write hash values back in the correct order */ - shuf128_32 $0x1B, STATE0, STATE0 /* FEBA */ - shuf128_32 $0xB1, STATE1, STATE1 /* DCHG */ + /* STATE0: ABEF (msb-to-lsb: 3,2,1,0) */ + /* STATE1: CDGH */ mova128 STATE0, XMMTMP - pblendw $0xF0, STATE1, STATE0 /* DCBA */ - palignr $8, XMMTMP, STATE1 /* HGFE */ +/* shufps takes dwords 0,1 from *2nd* operand, and dwords 2,3 from 1st one */ + shufps SHUF(3,2,3,2), STATE1, STATE0 /* DCBA */ + shufps SHUF(1,0,1,0), STATE1, XMMTMP /* HGFE */ /* add current hash values to previous ones */ + movu128 76+1*16(%eax), STATE1 + paddd XMMTMP, STATE1 + movu128 STATE1, 76+1*16(%eax) movu128 76+0*16(%eax), XMMTMP paddd XMMTMP, STATE0 - movu128 76+1*16(%eax), XMMTMP movu128 STATE0, 76+0*16(%eax) - paddd XMMTMP, STATE1 - movu128 STATE1, 76+1*16(%eax) ret .size sha256_process_block64_shaNI, .-sha256_process_block64_shaNI |