[go] crypto/md5: delete loong64/ppc64x asm

0 views
Skip to first unread message

Josh Bleecher Snyder (Gerrit)

unread,
Aug 11, 2026, 6:41:23 PM (9 hours ago) Aug 11
to Filippo Valsorda, goph...@pubsubhelper.golang.org, Josh Bleecher Snyder, golang-co...@googlegroups.com
Attention needed from Filippo Valsorda

Josh Bleecher Snyder has uploaded the change for review

Josh Bleecher Snyder would like Filippo Valsorda to review this change.

Commit message

crypto/md5: delete loong64/ppc64x asm

Their maintainers have confirmed that the performance is comparable.
(Thanks!)

For #49248
Change-Id: I4d93a009f8bc2b09937ec360357b23ef53f65933

Change diff

diff --git a/src/crypto/md5/md5block_decl.go b/src/crypto/md5/md5block_decl.go
index 8a8471c..75d5351 100644
--- a/src/crypto/md5/md5block_decl.go
+++ b/src/crypto/md5/md5block_decl.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

-//go:build (loong64 || ppc64 || ppc64le || riscv64 || s390x) && !purego
+//go:build (riscv64 || s390x) && !purego

package md5

diff --git a/src/crypto/md5/md5block_generic.go b/src/crypto/md5/md5block_generic.go
index 6840dba..47a4d0b 100644
--- a/src/crypto/md5/md5block_generic.go
+++ b/src/crypto/md5/md5block_generic.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

-//go:build (!loong64 && !ppc64 && !ppc64le && !riscv64 && !s390x) || purego
+//go:build (!riscv64 && !s390x) || purego

package md5

diff --git a/src/crypto/md5/md5block_loong64.s b/src/crypto/md5/md5block_loong64.s
deleted file mode 100644
index c16aa23..0000000
--- a/src/crypto/md5/md5block_loong64.s
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-// Loong64 version of md5block.go
-// derived from crypto/md5/md5block_amd64.s
-
-//go:build !purego
-
-#define REGTMP R30
-#define REGTMP1 R12
-#define REGTMP2 R18
-
-#include "textflag.h"
-
-// func block(dig *digest, p []byte)
-TEXT ·block(SB),NOSPLIT,$0-32
- MOVV dig+0(FP), R4
- MOVV p+8(FP), R5
- MOVV p_len+16(FP), R6
- AND $~63, R6
- BEQ R6, zero
-
- // p_len >= 64
- ADDV R5, R6, R24
- MOVW (0*4)(R4), R7
- MOVW (1*4)(R4), R8
- MOVW (2*4)(R4), R9
- MOVW (3*4)(R4), R10
-
-loop:
- MOVW R7, R14
- MOVW R8, R15
- MOVW R9, R16
- MOVW R10, R17
-
- MOVW (0*4)(R5), R11
- MOVW R10, REGTMP1
-
-// F = ((c ^ d) & b) ^ d
-#define ROUND1(a, b, c, d, index, const, shift) \
- ADDV $const, a; \
- ADD R11, a; \
- MOVW (index*4)(R5), R11; \
- XOR c, REGTMP1; \
- AND b, REGTMP1; \
- XOR d, REGTMP1; \
- ADD REGTMP1, a; \
- ROTR $(32-shift), a; \
- MOVW c, REGTMP1; \
- ADD b, a
-
- ROUND1(R7, R8, R9, R10, 1, 0xd76aa478, 7);
- ROUND1(R10, R7, R8, R9, 2, 0xe8c7b756, 12);
- ROUND1(R9, R10, R7, R8, 3, 0x242070db, 17);
- ROUND1(R8, R9, R10, R7, 4, 0xc1bdceee, 22);
- ROUND1(R7, R8, R9, R10, 5, 0xf57c0faf, 7);
- ROUND1(R10, R7, R8, R9, 6, 0x4787c62a, 12);
- ROUND1(R9, R10, R7, R8, 7, 0xa8304613, 17);
- ROUND1(R8, R9, R10, R7, 8, 0xfd469501, 22);
- ROUND1(R7, R8, R9, R10, 9, 0x698098d8, 7);
- ROUND1(R10, R7, R8, R9, 10, 0x8b44f7af, 12);
- ROUND1(R9, R10, R7, R8, 11, 0xffff5bb1, 17);
- ROUND1(R8, R9, R10, R7, 12, 0x895cd7be, 22);
- ROUND1(R7, R8, R9, R10, 13, 0x6b901122, 7);
- ROUND1(R10, R7, R8, R9, 14, 0xfd987193, 12);
- ROUND1(R9, R10, R7, R8, 15, 0xa679438e, 17);
- ROUND1(R8, R9, R10, R7, 1, 0x49b40821, 22);
-
- MOVW (1*4)(R5), R11
-
-// F = ((b ^ c) & d) ^ c
-#define ROUND2(a, b, c, d, index, const, shift) \
- ADDV $const, a; \
- ADD R11, a; \
- MOVW (index*4)(R5), R11; \
- XOR b, c, REGTMP; \
- AND REGTMP, d, REGTMP; \
- XOR REGTMP, c, REGTMP; \
- ADD REGTMP, a; \
- ROTR $(32-shift), a; \
- ADD b, a
-
- ROUND2(R7, R8, R9, R10, 6, 0xf61e2562, 5);
- ROUND2(R10, R7, R8, R9, 11, 0xc040b340, 9);
- ROUND2(R9, R10, R7, R8, 0, 0x265e5a51, 14);
- ROUND2(R8, R9, R10, R7, 5, 0xe9b6c7aa, 20);
- ROUND2(R7, R8, R9, R10, 10, 0xd62f105d, 5);
- ROUND2(R10, R7, R8, R9, 15, 0x2441453, 9);
- ROUND2(R9, R10, R7, R8, 4, 0xd8a1e681, 14);
- ROUND2(R8, R9, R10, R7, 9, 0xe7d3fbc8, 20);
- ROUND2(R7, R8, R9, R10, 14, 0x21e1cde6, 5);
- ROUND2(R10, R7, R8, R9, 3, 0xc33707d6, 9);
- ROUND2(R9, R10, R7, R8, 8, 0xf4d50d87, 14);
- ROUND2(R8, R9, R10, R7, 13, 0x455a14ed, 20);
- ROUND2(R7, R8, R9, R10, 2, 0xa9e3e905, 5);
- ROUND2(R10, R7, R8, R9, 7, 0xfcefa3f8, 9);
- ROUND2(R9, R10, R7, R8, 12, 0x676f02d9, 14);
- ROUND2(R8, R9, R10, R7, 5, 0x8d2a4c8a, 20);
-
- MOVW (5*4)(R5), R11
- MOVW R9, REGTMP1
-
-// F = b ^ c ^ d
-#define ROUND3(a, b, c, d, index, const, shift) \
- ADDV $const, a; \
- ADD R11, a; \
- MOVW (index*4)(R5), R11; \
- XOR d, REGTMP1; \
- XOR b, REGTMP1; \
- ADD REGTMP1, a; \
- ROTR $(32-shift), a; \
- MOVW b, REGTMP1; \
- ADD b, a
-
- ROUND3(R7, R8, R9, R10, 8, 0xfffa3942, 4);
- ROUND3(R10, R7, R8, R9, 11, 0x8771f681, 11);
- ROUND3(R9, R10, R7, R8, 14, 0x6d9d6122, 16);
- ROUND3(R8, R9, R10, R7, 1, 0xfde5380c, 23);
- ROUND3(R7, R8, R9, R10, 4, 0xa4beea44, 4);
- ROUND3(R10, R7, R8, R9, 7, 0x4bdecfa9, 11);
- ROUND3(R9, R10, R7, R8, 10, 0xf6bb4b60, 16);
- ROUND3(R8, R9, R10, R7, 13, 0xbebfbc70, 23);
- ROUND3(R7, R8, R9, R10, 0, 0x289b7ec6, 4);
- ROUND3(R10, R7, R8, R9, 3, 0xeaa127fa, 11);
- ROUND3(R9, R10, R7, R8, 6, 0xd4ef3085, 16);
- ROUND3(R8, R9, R10, R7, 9, 0x4881d05, 23);
- ROUND3(R7, R8, R9, R10, 12, 0xd9d4d039, 4);
- ROUND3(R10, R7, R8, R9, 15, 0xe6db99e5, 11);
- ROUND3(R9, R10, R7, R8, 2, 0x1fa27cf8, 16);
- ROUND3(R8, R9, R10, R7, 0, 0xc4ac5665, 23);
-
- MOVW (0*4)(R5), R11
- MOVV $0xffffffff, REGTMP2
- XOR R10, REGTMP2, REGTMP1 // REGTMP1 = ~d
-
-// F = c ^ (b | (~d))
-#define ROUND4(a, b, c, d, index, const, shift) \
- ADDV $const, a; \
- ADD R11, a; \
- MOVW (index*4)(R5), R11; \
- OR b, REGTMP1; \
- XOR c, REGTMP1; \
- ADD REGTMP1, a; \
- ROTR $(32-shift), a; \
- MOVV $0xffffffff, REGTMP2; \
- XOR c, REGTMP2, REGTMP1; \
- ADD b, a
-
- ROUND4(R7, R8, R9, R10, 7, 0xf4292244, 6);
- ROUND4(R10, R7, R8, R9, 14, 0x432aff97, 10);
- ROUND4(R9, R10, R7, R8, 5, 0xab9423a7, 15);
- ROUND4(R8, R9, R10, R7, 12, 0xfc93a039, 21);
- ROUND4(R7, R8, R9, R10, 3, 0x655b59c3, 6);
- ROUND4(R10, R7, R8, R9, 10, 0x8f0ccc92, 10);
- ROUND4(R9, R10, R7, R8, 1, 0xffeff47d, 15);
- ROUND4(R8, R9, R10, R7, 8, 0x85845dd1, 21);
- ROUND4(R7, R8, R9, R10, 15, 0x6fa87e4f, 6);
- ROUND4(R10, R7, R8, R9, 6, 0xfe2ce6e0, 10);
- ROUND4(R9, R10, R7, R8, 13, 0xa3014314, 15);
- ROUND4(R8, R9, R10, R7, 4, 0x4e0811a1, 21);
- ROUND4(R7, R8, R9, R10, 11, 0xf7537e82, 6);
- ROUND4(R10, R7, R8, R9, 2, 0xbd3af235, 10);
- ROUND4(R9, R10, R7, R8, 9, 0x2ad7d2bb, 15);
- ROUND4(R8, R9, R10, R7, 0, 0xeb86d391, 21);
-
- ADD R14, R7
- ADD R15, R8
- ADD R16, R9
- ADD R17, R10
-
- ADDV $64, R5
- BNE R5, R24, loop
-
- MOVW R7, (0*4)(R4)
- MOVW R8, (1*4)(R4)
- MOVW R9, (2*4)(R4)
- MOVW R10, (3*4)(R4)
-zero:
- RET
diff --git a/src/crypto/md5/md5block_ppc64x.s b/src/crypto/md5/md5block_ppc64x.s
deleted file mode 100644
index 49a3695..0000000
--- a/src/crypto/md5/md5block_ppc64x.s
+++ /dev/null
@@ -1,212 +0,0 @@
-// Original source:
-// http://www.zorinaq.com/papers/md5-amd64.html
-// http://www.zorinaq.com/papers/md5-amd64.tar.bz2
-//
-// MD5 optimized for ppc64le using Go's assembler for
-// ppc64le, based on md5block_amd64.s implementation by
-// the Go authors.
-//
-// Author: Marc Bevand <bevand_m (at) epita.fr>
-// Licence: I hereby disclaim the copyright on this code and place it
-// in the public domain.
-
-//go:build (ppc64 || ppc64le) && !purego
-
-#include "textflag.h"
-
-// ENDIAN_MOVE generates the appropriate
-// 4 byte load for big or little endian.
-// The 4 bytes at ptr+off is loaded into dst.
-// The idx reg is only needed for big endian
-// and is clobbered when used.
-#ifdef GOARCH_ppc64le
-#define ENDIAN_MOVE(off, ptr, dst, idx) \
- MOVWZ off(ptr),dst
-#else
-#define ENDIAN_MOVE(off, ptr, dst, idx) \
- MOVD $off,idx; \
- MOVWBR (idx)(ptr), dst
-#endif
-
-#define M00 R18
-#define M01 R19
-#define M02 R20
-#define M03 R24
-#define M04 R25
-#define M05 R26
-#define M06 R27
-#define M07 R28
-#define M08 R29
-#define M09 R21
-#define M10 R11
-#define M11 R8
-#define M12 R7
-#define M13 R12
-#define M14 R23
-#define M15 R10
-
-#define ROUND1(a, b, c, d, index, const, shift) \
- ADD $const, index, R9; \
- ADD R9, a; \
- AND b, c, R9; \
- ANDN b, d, R31; \
- OR R9, R31, R9; \
- ADD R9, a; \
- ROTLW $shift, a; \
- ADD b, a;
-
-#define ROUND2(a, b, c, d, index, const, shift) \
- ADD $const, index, R9; \
- ADD R9, a; \
- AND b, d, R31; \
- ANDN d, c, R9; \
- OR R9, R31; \
- ADD R31, a; \
- ROTLW $shift, a; \
- ADD b, a;
-
-#define ROUND3(a, b, c, d, index, const, shift) \
- ADD $const, index, R9; \
- ADD R9, a; \
- XOR d, c, R31; \
- XOR b, R31; \
- ADD R31, a; \
- ROTLW $shift, a; \
- ADD b, a;
-
-#define ROUND4(a, b, c, d, index, const, shift) \
- ADD $const, index, R9; \
- ADD R9, a; \
- ORN d, b, R31; \
- XOR c, R31; \
- ADD R31, a; \
- ROTLW $shift, a; \
- ADD b, a;
-
-
-TEXT ·block(SB),NOSPLIT,$0-32
- MOVD dig+0(FP), R10
- MOVD p+8(FP), R6
- MOVD p_len+16(FP), R5
-
- // We assume p_len >= 64
- SRD $6, R5
- MOVD R5, CTR
-
- MOVWZ 0(R10), R22
- MOVWZ 4(R10), R3
- MOVWZ 8(R10), R4
- MOVWZ 12(R10), R5
-
-loop:
- MOVD R22, R14
- MOVD R3, R15
- MOVD R4, R16
- MOVD R5, R17
-
- ENDIAN_MOVE( 0,R6,M00,M15)
- ENDIAN_MOVE( 4,R6,M01,M15)
- ENDIAN_MOVE( 8,R6,M02,M15)
- ENDIAN_MOVE(12,R6,M03,M15)
-
- ROUND1(R22,R3,R4,R5,M00,0xd76aa478, 7);
- ROUND1(R5,R22,R3,R4,M01,0xe8c7b756,12);
- ROUND1(R4,R5,R22,R3,M02,0x242070db,17);
- ROUND1(R3,R4,R5,R22,M03,0xc1bdceee,22);
-
- ENDIAN_MOVE(16,R6,M04,M15)
- ENDIAN_MOVE(20,R6,M05,M15)
- ENDIAN_MOVE(24,R6,M06,M15)
- ENDIAN_MOVE(28,R6,M07,M15)
-
- ROUND1(R22,R3,R4,R5,M04,0xf57c0faf, 7);
- ROUND1(R5,R22,R3,R4,M05,0x4787c62a,12);
- ROUND1(R4,R5,R22,R3,M06,0xa8304613,17);
- ROUND1(R3,R4,R5,R22,M07,0xfd469501,22);
-
- ENDIAN_MOVE(32,R6,M08,M15)
- ENDIAN_MOVE(36,R6,M09,M15)
- ENDIAN_MOVE(40,R6,M10,M15)
- ENDIAN_MOVE(44,R6,M11,M15)
-
- ROUND1(R22,R3,R4,R5,M08,0x698098d8, 7);
- ROUND1(R5,R22,R3,R4,M09,0x8b44f7af,12);
- ROUND1(R4,R5,R22,R3,M10,0xffff5bb1,17);
- ROUND1(R3,R4,R5,R22,M11,0x895cd7be,22);
-
- ENDIAN_MOVE(48,R6,M12,M15)
- ENDIAN_MOVE(52,R6,M13,M15)
- ENDIAN_MOVE(56,R6,M14,M15)
- ENDIAN_MOVE(60,R6,M15,M15)
-
- ROUND1(R22,R3,R4,R5,M12,0x6b901122, 7);
- ROUND1(R5,R22,R3,R4,M13,0xfd987193,12);
- ROUND1(R4,R5,R22,R3,M14,0xa679438e,17);
- ROUND1(R3,R4,R5,R22,M15,0x49b40821,22);
-
- ROUND2(R22,R3,R4,R5,M01,0xf61e2562, 5);
- ROUND2(R5,R22,R3,R4,M06,0xc040b340, 9);
- ROUND2(R4,R5,R22,R3,M11,0x265e5a51,14);
- ROUND2(R3,R4,R5,R22,M00,0xe9b6c7aa,20);
- ROUND2(R22,R3,R4,R5,M05,0xd62f105d, 5);
- ROUND2(R5,R22,R3,R4,M10, 0x2441453, 9);
- ROUND2(R4,R5,R22,R3,M15,0xd8a1e681,14);
- ROUND2(R3,R4,R5,R22,M04,0xe7d3fbc8,20);
- ROUND2(R22,R3,R4,R5,M09,0x21e1cde6, 5);
- ROUND2(R5,R22,R3,R4,M14,0xc33707d6, 9);
- ROUND2(R4,R5,R22,R3,M03,0xf4d50d87,14);
- ROUND2(R3,R4,R5,R22,M08,0x455a14ed,20);
- ROUND2(R22,R3,R4,R5,M13,0xa9e3e905, 5);
- ROUND2(R5,R22,R3,R4,M02,0xfcefa3f8, 9);
- ROUND2(R4,R5,R22,R3,M07,0x676f02d9,14);
- ROUND2(R3,R4,R5,R22,M12,0x8d2a4c8a,20);
-
- ROUND3(R22,R3,R4,R5,M05,0xfffa3942, 4);
- ROUND3(R5,R22,R3,R4,M08,0x8771f681,11);
- ROUND3(R4,R5,R22,R3,M11,0x6d9d6122,16);
- ROUND3(R3,R4,R5,R22,M14,0xfde5380c,23);
- ROUND3(R22,R3,R4,R5,M01,0xa4beea44, 4);
- ROUND3(R5,R22,R3,R4,M04,0x4bdecfa9,11);
- ROUND3(R4,R5,R22,R3,M07,0xf6bb4b60,16);
- ROUND3(R3,R4,R5,R22,M10,0xbebfbc70,23);
- ROUND3(R22,R3,R4,R5,M13,0x289b7ec6, 4);
- ROUND3(R5,R22,R3,R4,M00,0xeaa127fa,11);
- ROUND3(R4,R5,R22,R3,M03,0xd4ef3085,16);
- ROUND3(R3,R4,R5,R22,M06, 0x4881d05,23);
- ROUND3(R22,R3,R4,R5,M09,0xd9d4d039, 4);
- ROUND3(R5,R22,R3,R4,M12,0xe6db99e5,11);
- ROUND3(R4,R5,R22,R3,M15,0x1fa27cf8,16);
- ROUND3(R3,R4,R5,R22,M02,0xc4ac5665,23);
-
- ROUND4(R22,R3,R4,R5,M00,0xf4292244, 6);
- ROUND4(R5,R22,R3,R4,M07,0x432aff97,10);
- ROUND4(R4,R5,R22,R3,M14,0xab9423a7,15);
- ROUND4(R3,R4,R5,R22,M05,0xfc93a039,21);
- ROUND4(R22,R3,R4,R5,M12,0x655b59c3, 6);
- ROUND4(R5,R22,R3,R4,M03,0x8f0ccc92,10);
- ROUND4(R4,R5,R22,R3,M10,0xffeff47d,15);
- ROUND4(R3,R4,R5,R22,M01,0x85845dd1,21);
- ROUND4(R22,R3,R4,R5,M08,0x6fa87e4f, 6);
- ROUND4(R5,R22,R3,R4,M15,0xfe2ce6e0,10);
- ROUND4(R4,R5,R22,R3,M06,0xa3014314,15);
- ROUND4(R3,R4,R5,R22,M13,0x4e0811a1,21);
- ROUND4(R22,R3,R4,R5,M04,0xf7537e82, 6);
- ROUND4(R5,R22,R3,R4,M11,0xbd3af235,10);
- ROUND4(R4,R5,R22,R3,M02,0x2ad7d2bb,15);
- ROUND4(R3,R4,R5,R22,M09,0xeb86d391,21);
-
- ADD R14, R22
- ADD R15, R3
- ADD R16, R4
- ADD R17, R5
- ADD $64, R6
- BDNZ loop
-
-end:
- MOVD dig+0(FP), R10
- MOVWZ R22, 0(R10)
- MOVWZ R3, 4(R10)
- MOVWZ R4, 8(R10)
- MOVWZ R5, 12(R10)
-
- RET

Change information

Files:
  • M src/crypto/md5/md5block_decl.go
  • M src/crypto/md5/md5block_generic.go
  • D src/crypto/md5/md5block_loong64.s
  • D src/crypto/md5/md5block_ppc64x.s
Change size: L
Delta: 4 files changed, 2 insertions(+), 394 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Filippo Valsorda
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4d93a009f8bc2b09937ec360357b23ef53f65933
Gerrit-Change-Number: 813540
Gerrit-PatchSet: 1
Gerrit-Owner: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Attention: Filippo Valsorda <fil...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Jorropo (Gerrit)

unread,
Aug 11, 2026, 7:32:09 PM (8 hours ago) Aug 11
to Josh Bleecher Snyder, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Filippo Valsorda, golang-co...@googlegroups.com
Attention needed from Filippo Valsorda and Josh Bleecher Snyder

Jorropo voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Filippo Valsorda
  • Josh Bleecher Snyder
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4d93a009f8bc2b09937ec360357b23ef53f65933
Gerrit-Change-Number: 813540
Gerrit-PatchSet: 1
Gerrit-Owner: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Attention: Filippo Valsorda <fil...@golang.org>
Gerrit-Attention: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Comment-Date: Tue, 11 Aug 2026 23:32:02 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages