]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
md5/md4: enable unaligned access fast path on powerpc64
authorScott Boudreaux <121303252+Scottcjn@users.noreply.github.com>
Wed, 18 Mar 2026 15:56:09 +0000 (10:56 -0500)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 21 Mar 2026 22:35:58 +0000 (23:35 +0100)
PowerPC64 (both big-endian and little-endian) supports efficient
unaligned memory access, similar to x86. This extends the existing
fast path that avoids byte-by-byte loads in the MD5 and MD4 SET/GET
macros.

On POWER8 ppc64le, this eliminates 3 shifts + 3 ORs per 32-bit word
load, replacing them with a single lwz (or lwbrx on big-endian).

Co Authored By Claude Opus 4.6 (1M context)

Closes #20985

lib/md4.c
lib/md5.c

index 1ac6ef1c5b7befa694333d5c363ad77d178ded35..c3934ec79d9eb55a2040b83c6119be54eeb26bde 100644 (file)
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -213,7 +213,8 @@ typedef struct md4_ctx MD4_CTX;
  * The check for little-endian architectures that tolerate unaligned memory
  * accesses is an optimization. Nothing will break if it does not work.
  */
-#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
+#if defined(__i386__) || defined(__x86_64__) || \
+    defined(__vax__) || defined(__powerpc64__)
 #define MD4_SET(n) (*(const uint32_t *)(const void *)&ptr[(n) * 4])
 #define MD4_GET(n) MD4_SET(n)
 #else
index c2bd176dc96f6a2d3c7681f51323c401767e5fb9..53d93aa56414046ed624b595cf9e2686bf157aca 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -294,7 +294,8 @@ typedef struct md5_ctx my_md5_ctx;
  * The check for little-endian architectures that tolerate unaligned memory
  * accesses is an optimization. Nothing will break if it does not work.
  */
-#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
+#if defined(__i386__) || defined(__x86_64__) || \
+    defined(__vax__) || defined(__powerpc64__)
 #define MD5_SET(n) (*(const uint32_t *)(const void *)&ptr[(n) * 4])
 #define MD5_GET(n) MD5_SET(n)
 #else