aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-02-09 01:30:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2022-02-09 01:30:23 +0100
commit461a994b09c5022b93bccccf903b39438d61bbf1 (patch)
tree81c00839ff70b8e95b3a0511e7f6d50b0fcc320e
parentc0ff0d4528d718c20b9ca2290bd10d59e9f794a3 (diff)
downloadbusybox-w32-461a994b09c5022b93bccccf903b39438d61bbf1.tar.gz
busybox-w32-461a994b09c5022b93bccccf903b39438d61bbf1.tar.bz2
busybox-w32-461a994b09c5022b93bccccf903b39438d61bbf1.zip
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>
-rw-r--r--libbb/hash_md5_sha256_x86-32_shaNI.S29
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 @@
34 34
35#define XMMTMP %xmm7 35#define XMMTMP %xmm7
36 36
37#define SHUF(a,b,c,d) $(a+(b<<2)+(c<<4)+(d<<6))
38
37 .balign 8 # allow decoders to fetch at least 2 first insns 39 .balign 8 # allow decoders to fetch at least 2 first insns
38sha256_process_block64_shaNI: 40sha256_process_block64_shaNI:
39 movu128 76+0*16(%eax), STATE0
40 movu128 76+1*16(%eax), STATE1
41 41
42 shuf128_32 $0xB1, STATE0, STATE0 /* CDAB */ 42 movu128 76+0*16(%eax), STATE1 /* DCBA (msb-to-lsb: 3,2,1,0) */
43 shuf128_32 $0x1B, STATE1, STATE1 /* EFGH */ 43 movu128 76+1*16(%eax), STATE0 /* HGFE */
44/* shufps takes dwords 0,1 from *2nd* operand, and dwords 2,3 from 1st one */
44 mova128 STATE0, XMMTMP 45 mova128 STATE0, XMMTMP
45 palignr $8, STATE1, STATE0 /* ABEF */ 46 shufps SHUF(1,0,1,0), STATE1, STATE0 /* ABEF */
46 pblendw $0xF0, XMMTMP, STATE1 /* CDGH */ 47 shufps SHUF(3,2,3,2), STATE1, XMMTMP /* CDGH */
48 mova128 XMMTMP, STATE1
47 49
48/* XMMTMP holds flip mask from here... */ 50/* XMMTMP holds flip mask from here... */
49 mova128 PSHUFFLE_BSWAP32_FLIP_MASK, XMMTMP 51 mova128 PSHUFFLE_BSWAP32_FLIP_MASK, XMMTMP
@@ -231,18 +233,19 @@ sha256_process_block64_shaNI:
231 sha256rnds2 STATE1, STATE0 233 sha256rnds2 STATE1, STATE0
232 234
233 /* Write hash values back in the correct order */ 235 /* Write hash values back in the correct order */
234 shuf128_32 $0x1B, STATE0, STATE0 /* FEBA */ 236 /* STATE0: ABEF (msb-to-lsb: 3,2,1,0) */
235 shuf128_32 $0xB1, STATE1, STATE1 /* DCHG */ 237 /* STATE1: CDGH */
236 mova128 STATE0, XMMTMP 238 mova128 STATE0, XMMTMP
237 pblendw $0xF0, STATE1, STATE0 /* DCBA */ 239/* shufps takes dwords 0,1 from *2nd* operand, and dwords 2,3 from 1st one */
238 palignr $8, XMMTMP, STATE1 /* HGFE */ 240 shufps SHUF(3,2,3,2), STATE1, STATE0 /* DCBA */
241 shufps SHUF(1,0,1,0), STATE1, XMMTMP /* HGFE */
239 /* add current hash values to previous ones */ 242 /* add current hash values to previous ones */
243 movu128 76+1*16(%eax), STATE1
244 paddd XMMTMP, STATE1
245 movu128 STATE1, 76+1*16(%eax)
240 movu128 76+0*16(%eax), XMMTMP 246 movu128 76+0*16(%eax), XMMTMP
241 paddd XMMTMP, STATE0 247 paddd XMMTMP, STATE0
242 movu128 76+1*16(%eax), XMMTMP
243 movu128 STATE0, 76+0*16(%eax) 248 movu128 STATE0, 76+0*16(%eax)
244 paddd XMMTMP, STATE1
245 movu128 STATE1, 76+1*16(%eax)
246 249
247 ret 250 ret
248 .size sha256_process_block64_shaNI, .-sha256_process_block64_shaNI 251 .size sha256_process_block64_shaNI, .-sha256_process_block64_shaNI