[git commit] libbb/sha1: add a comment

Denys Vlasenko vda.linux at googlemail.com
Sat Jan 8 21:43:24 UTC 2022


commit: https://git.busybox.net/busybox/commit/?id=143356876b5712c28b8af61ea9144959a4dc6a5b
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libbb/hash_md5_sha_x86-64.S.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/libbb/hash_md5_sha_x86-64.S.sh b/libbb/hash_md5_sha_x86-64.S.sh
index eef009590..901896e6e 100755
--- a/libbb/hash_md5_sha_x86-64.S.sh
+++ b/libbb/hash_md5_sha_x86-64.S.sh
@@ -6,6 +6,28 @@
 # also contains the diff of the generated file.
 exec >hash_md5_sha_x86-64.S
 
+# There is a way to use XMM registers (which always exist for x86-64!) for W[]
+# For example, if we load W as follows:
+#	%xmm0:  w[0x0] w[0x1] w[0x2] w[0x3]
+#	%xmm4:  w[0x4] w[0x5] w[0x6] w[0x7]
+#	%xmm8:  w[0x8] w[0x9] w[0xa] w[0xb]
+#	%xmm12: w[0xc] w[0xd] w[0xe] w[0xf]
+# then the xor'ing operation to generate next W[0..3] is:
+#	movaps	%xmm0, %xmmT2
+#	palignr	$0x8, %xmm4, %xmmT2 # form (w[0x2],w[0x3],w[0x4],w[0x5])
+#	# Right-shifts xmm4:xmmT2 by 8 bytes. Writes shifted result to xmmT2. SSSE3 insn.
+#	movaps	%xmm0, %xmmT13
+#	palignr $0x4,%xmm0,%xmmT13 # form (w[0xd],w[0xe],w[0xf],w[0x0])
+#	xmm0 = xmm0 ^ t2 ^ xmm8 ^ t13
+#	xmm0 = rol32(xmm0,1)	# no such insn, have to use pslld+psrld+or
+# and then results can be extracted for use:
+#	movd	%xmm0, %esi	# new W[0]
+#	pextrd	$1, %xmm0, %esi	# new W[1]
+#	# SSE4.1 insn. Can use EXTRACTPS (also SSE4.1)
+#	pextrd	$2, %xmm0, %esi	# new W[2]
+#	pextrd	$3, %xmm0, %esi	# new W[3]
+# ... but this requires SSE4.1 and SSSE3, which are not universally available on x86-64.
+
 echo \
 '### Generated by hash_md5_sha_x86-64.S.sh ###
 


More information about the busybox-cvs mailing list