diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-02-08 03:29:16 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-02-08 03:29:16 +0100 |
commit | 4923f74e5873b25b8205a4059964cff75ee731a8 (patch) | |
tree | 303d731fc684080fb6438657a235cd7b002d6702 /libbb/hash_md5_sha_x86-64.S.sh | |
parent | c193cbd6dfd095c6b8346bab1ea6ba7106b3e5bb (diff) | |
download | busybox-w32-4923f74e5873b25b8205a4059964cff75ee731a8.tar.gz busybox-w32-4923f74e5873b25b8205a4059964cff75ee731a8.tar.bz2 busybox-w32-4923f74e5873b25b8205a4059964cff75ee731a8.zip |
libbb/sha1: shrink unrolled x86-64 code
function old new delta
sha1_process_block64 3482 3481 -1
.rodata 108460 108412 -48
------------------------------------------------------------------------------
(add/remove: 1/4 grow/shrink: 0/2 up/down: 0/-49) Total: -49 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rwxr-xr-x | libbb/hash_md5_sha_x86-64.S.sh | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/libbb/hash_md5_sha_x86-64.S.sh b/libbb/hash_md5_sha_x86-64.S.sh index fb1e4b57e..a10ac411d 100755 --- a/libbb/hash_md5_sha_x86-64.S.sh +++ b/libbb/hash_md5_sha_x86-64.S.sh | |||
@@ -34,6 +34,7 @@ exec >hash_md5_sha_x86-64.S | |||
34 | xmmT1="%xmm4" | 34 | xmmT1="%xmm4" |
35 | xmmT2="%xmm5" | 35 | xmmT2="%xmm5" |
36 | xmmRCONST="%xmm6" | 36 | xmmRCONST="%xmm6" |
37 | xmmALLRCONST="%xmm7" | ||
37 | T=`printf '\t'` | 38 | T=`printf '\t'` |
38 | 39 | ||
39 | # SSE instructions are longer than 4 bytes on average. | 40 | # SSE instructions are longer than 4 bytes on average. |
@@ -125,6 +126,7 @@ sha1_process_block64: | |||
125 | # xmm0..xmm3: W[] | 126 | # xmm0..xmm3: W[] |
126 | # xmm4,xmm5: temps | 127 | # xmm4,xmm5: temps |
127 | # xmm6: current round constant | 128 | # xmm6: current round constant |
129 | # xmm7: all round constants | ||
128 | # -64(%rsp): area for passing RCONST + W[] from vector to integer units | 130 | # -64(%rsp): area for passing RCONST + W[] from vector to integer units |
129 | 131 | ||
130 | movl 80(%rdi), %eax # a = ctx->hash[0] | 132 | movl 80(%rdi), %eax # a = ctx->hash[0] |
@@ -133,16 +135,17 @@ sha1_process_block64: | |||
133 | movl 92(%rdi), %edx # d = ctx->hash[3] | 135 | movl 92(%rdi), %edx # d = ctx->hash[3] |
134 | movl 96(%rdi), %ebp # e = ctx->hash[4] | 136 | movl 96(%rdi), %ebp # e = ctx->hash[4] |
135 | 137 | ||
136 | movaps rconst0x5A827999(%rip), $xmmRCONST | 138 | movaps sha1const(%rip), $xmmALLRCONST |
139 | pshufd \$0x00, $xmmALLRCONST, $xmmRCONST | ||
137 | 140 | ||
138 | # Load W[] to xmm registers, byteswapping on the fly. | 141 | # Load W[] to xmm registers, byteswapping on the fly. |
139 | # | 142 | # |
140 | # For iterations 0..15, we pass W[] in rsi,r8..r14 | 143 | # For iterations 0..15, we pass W[] in rsi,r8..r14 |
141 | # for use in RD1A's instead of spilling them to stack. | 144 | # for use in RD1As instead of spilling them to stack. |
142 | # We lose parallelized addition of RCONST, but LEA | 145 | # We lose parallelized addition of RCONST, but LEA |
143 | # can do two additions at once, so it's probably a wash. | 146 | # can do two additions at once, so it is probably a wash. |
144 | # (We use rsi instead of rN because this makes two | 147 | # (We use rsi instead of rN because this makes two |
145 | # LEAs in two first RD1A's shorter by one byte). | 148 | # LEAs in two first RD1As shorter by one byte). |
146 | movq 4*0(%rdi), %rsi | 149 | movq 4*0(%rdi), %rsi |
147 | movq 4*2(%rdi), %r8 | 150 | movq 4*2(%rdi), %r8 |
148 | bswapq %rsi | 151 | bswapq %rsi |
@@ -359,7 +362,7 @@ RD1A bx cx dx bp ax 4; RD1A ax bx cx dx bp 5; RD1A bp ax bx cx dx 6; RD1A dx | |||
359 | a=`PREP %xmm0 %xmm1 %xmm2 %xmm3 "-64+16*0(%rsp)"` | 362 | a=`PREP %xmm0 %xmm1 %xmm2 %xmm3 "-64+16*0(%rsp)"` |
360 | b=`RD1A cx dx bp ax bx 8; RD1A bx cx dx bp ax 9; RD1A ax bx cx dx bp 10; RD1A bp ax bx cx dx 11;` | 363 | b=`RD1A cx dx bp ax bx 8; RD1A bx cx dx bp ax 9; RD1A ax bx cx dx bp 10; RD1A bp ax bx cx dx 11;` |
361 | INTERLEAVE "$a" "$b" | 364 | INTERLEAVE "$a" "$b" |
362 | a=`echo " movaps rconst0x6ED9EBA1(%rip), $xmmRCONST" | 365 | a=`echo " pshufd \\$0x55, $xmmALLRCONST, $xmmRCONST" |
363 | PREP %xmm1 %xmm2 %xmm3 %xmm0 "-64+16*1(%rsp)"` | 366 | PREP %xmm1 %xmm2 %xmm3 %xmm0 "-64+16*1(%rsp)"` |
364 | b=`RD1A dx bp ax bx cx 12; RD1A cx dx bp ax bx 13; RD1A bx cx dx bp ax 14; RD1A ax bx cx dx bp 15;` | 367 | b=`RD1A dx bp ax bx cx 12; RD1A cx dx bp ax bx 13; RD1A bx cx dx bp ax 14; RD1A ax bx cx dx bp 15;` |
365 | INTERLEAVE "$a" "$b" | 368 | INTERLEAVE "$a" "$b" |
@@ -378,7 +381,7 @@ INTERLEAVE "$a" "$b" | |||
378 | a=`PREP %xmm1 %xmm2 %xmm3 %xmm0 "-64+16*1(%rsp)"` | 381 | a=`PREP %xmm1 %xmm2 %xmm3 %xmm0 "-64+16*1(%rsp)"` |
379 | b=`RD2 cx dx bp ax bx 28; RD2 bx cx dx bp ax 29; RD2 ax bx cx dx bp 30; RD2 bp ax bx cx dx 31;` | 382 | b=`RD2 cx dx bp ax bx 28; RD2 bx cx dx bp ax 29; RD2 ax bx cx dx bp 30; RD2 bp ax bx cx dx 31;` |
380 | INTERLEAVE "$a" "$b" | 383 | INTERLEAVE "$a" "$b" |
381 | a=`echo " movaps rconst0x8F1BBCDC(%rip), $xmmRCONST" | 384 | a=`echo " pshufd \\$0xaa, $xmmALLRCONST, $xmmRCONST" |
382 | PREP %xmm2 %xmm3 %xmm0 %xmm1 "-64+16*2(%rsp)"` | 385 | PREP %xmm2 %xmm3 %xmm0 %xmm1 "-64+16*2(%rsp)"` |
383 | b=`RD2 dx bp ax bx cx 32; RD2 cx dx bp ax bx 33; RD2 bx cx dx bp ax 34; RD2 ax bx cx dx bp 35;` | 386 | b=`RD2 dx bp ax bx cx 32; RD2 cx dx bp ax bx 33; RD2 bx cx dx bp ax 34; RD2 ax bx cx dx bp 35;` |
384 | INTERLEAVE "$a" "$b" | 387 | INTERLEAVE "$a" "$b" |
@@ -397,7 +400,7 @@ INTERLEAVE "$a" "$b" | |||
397 | a=`PREP %xmm2 %xmm3 %xmm0 %xmm1 "-64+16*2(%rsp)"` | 400 | a=`PREP %xmm2 %xmm3 %xmm0 %xmm1 "-64+16*2(%rsp)"` |
398 | b=`RD3 cx dx bp ax bx 48; RD3 bx cx dx bp ax 49; RD3 ax bx cx dx bp 50; RD3 bp ax bx cx dx 51;` | 401 | b=`RD3 cx dx bp ax bx 48; RD3 bx cx dx bp ax 49; RD3 ax bx cx dx bp 50; RD3 bp ax bx cx dx 51;` |
399 | INTERLEAVE "$a" "$b" | 402 | INTERLEAVE "$a" "$b" |
400 | a=`echo " movaps rconst0xCA62C1D6(%rip), $xmmRCONST" | 403 | a=`echo " pshufd \\$0xff, $xmmALLRCONST, $xmmRCONST" |
401 | PREP %xmm3 %xmm0 %xmm1 %xmm2 "-64+16*3(%rsp)"` | 404 | PREP %xmm3 %xmm0 %xmm1 %xmm2 "-64+16*3(%rsp)"` |
402 | b=`RD3 dx bp ax bx cx 52; RD3 cx dx bp ax bx 53; RD3 bx cx dx bp ax 54; RD3 ax bx cx dx bp 55;` | 405 | b=`RD3 dx bp ax bx cx 52; RD3 cx dx bp ax bx 53; RD3 bx cx dx bp ax 54; RD3 ax bx cx dx bp 55;` |
403 | INTERLEAVE "$a" "$b" | 406 | INTERLEAVE "$a" "$b" |
@@ -439,25 +442,10 @@ echo " | |||
439 | 442 | ||
440 | .section .rodata.cst16.sha1const, \"aM\", @progbits, 16 | 443 | .section .rodata.cst16.sha1const, \"aM\", @progbits, 16 |
441 | .balign 16 | 444 | .balign 16 |
442 | rconst0x5A827999: | 445 | sha1const: |
443 | .long 0x5A827999 | 446 | .long 0x5A827999 |
444 | .long 0x5A827999 | ||
445 | .long 0x5A827999 | ||
446 | .long 0x5A827999 | ||
447 | rconst0x6ED9EBA1: | ||
448 | .long 0x6ED9EBA1 | ||
449 | .long 0x6ED9EBA1 | ||
450 | .long 0x6ED9EBA1 | ||
451 | .long 0x6ED9EBA1 | 447 | .long 0x6ED9EBA1 |
452 | rconst0x8F1BBCDC: | ||
453 | .long 0x8F1BBCDC | 448 | .long 0x8F1BBCDC |
454 | .long 0x8F1BBCDC | ||
455 | .long 0x8F1BBCDC | ||
456 | .long 0x8F1BBCDC | ||
457 | rconst0xCA62C1D6: | ||
458 | .long 0xCA62C1D6 | ||
459 | .long 0xCA62C1D6 | ||
460 | .long 0xCA62C1D6 | ||
461 | .long 0xCA62C1D6 | 449 | .long 0xCA62C1D6 |
462 | 450 | ||
463 | #endif" | 451 | #endif" |