Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-02-09 03:42:49 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2022-02-09 03:42:49 +0300
commit11bcea7ac0ac4b2156c1b2d53f926d789b9792b4 (patch)
treea9fb00915788a924269722c0afa186d4fac5f610 /libbb
parent461a994b09c5022b93bccccf903b39438d61bbf1 (diff)
libbb/sha256: code shrink in 64-bit x86
function old new delta sha256_process_block64_shaNI 701 680 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/hash_md5_sha256_x86-64_shaNI.S25
1 files changed, 14 insertions, 11 deletions
diff --git a/libbb/hash_md5_sha256_x86-64_shaNI.S b/libbb/hash_md5_sha256_x86-64_shaNI.S
index b5c950a9a..bc063b9cc 100644
--- a/libbb/hash_md5_sha256_x86-64_shaNI.S
+++ b/libbb/hash_md5_sha256_x86-64_shaNI.S
@@ -37,16 +37,18 @@
#define ABEF_SAVE %xmm9
#define CDGH_SAVE %xmm10
+#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 80+0*16(%rdi), STATE0
- movu128 80+1*16(%rdi), STATE1
- shuf128_32 $0xB1, STATE0, STATE0 /* CDAB */
- shuf128_32 $0x1B, STATE1, STATE1 /* EFGH */
+ movu128 80+0*16(%rdi), STATE1 /* DCBA (msb-to-lsb: 3,2,1,0) */
+ movu128 80+1*16(%rdi), 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(%rip), XMMTMP
@@ -242,14 +244,15 @@ sha256_process_block64_shaNI:
paddd CDGH_SAVE, STATE1
/* 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 */
movu128 STATE0, 80+0*16(%rdi)
- movu128 STATE1, 80+1*16(%rdi)
+ movu128 XMMTMP, 80+1*16(%rdi)
ret
.size sha256_process_block64_shaNI, .-sha256_process_block64_shaNI