From 287451f09ccd6e744473c35d2b7fe41985b7f789 Mon Sep 17 00:00:00 2001 From: limeidan Date: Tue, 10 Feb 2026 19:31:23 +0800 Subject: [PATCH] math/big: optimize the implementation of lshVU on loong64 Change-Id: I1aac166aea4f907a7fb93028a39ef9d1e3888c9c Reviewed-on: https://go-review.googlesource.com/c/go/+/743800 Reviewed-by: Michael Pratt Auto-Submit: Michael Pratt Reviewed-by: Junyang Shao LUCI-TryBot-Result: Go LUCI Reviewed-by: abner chenc --- src/math/big/arith_loong64.s | 6 ++---- src/math/big/internal/asmgen/loong64.go | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/math/big/arith_loong64.s b/src/math/big/arith_loong64.s index b2af925124..ad92f07690 100644 --- a/src/math/big/arith_loong64.s +++ b/src/math/big/arith_loong64.s @@ -162,10 +162,8 @@ TEXT ·lshVU(SB), NOSPLIT, $0 MOVV x_base+24(FP), R6 MOVV z_base+0(FP), R7 // run loop backward - SLLV $3, R4, R8 - ADDVU R8, R6 - SLLV $3, R4, R8 - ADDVU R8, R7 + ALSLV $3, R4, R6, R6 + ALSLV $3, R4, R7, R7 // shift first word into carry MOVV -8(R6), R8 MOVV $64, R9 diff --git a/src/math/big/internal/asmgen/loong64.go b/src/math/big/internal/asmgen/loong64.go index e2d05690ab..104439dacd 100644 --- a/src/math/big/internal/asmgen/loong64.go +++ b/src/math/big/internal/asmgen/loong64.go @@ -40,6 +40,8 @@ var ArchLoong64 = &Arch{ or: "OR", xor: "XOR", + addWords: "ALSLV $3, %[1]s, %[2]s, %[3]s", + jmpZero: "BEQ %s, %s", jmpNonZero: "BNE %s, %s", } -- 2.52.0