From 3492e4262b751c5a117a3c77ba5e243b16918e61 Mon Sep 17 00:00:00 2001 From: Xiaolin Zhao Date: Wed, 3 Sep 2025 15:43:21 +0800 Subject: cmd/compile: simplify specific addition operations using the ADDV16 instruction On loong64, the addi.d instruction can only directly handle 12-bit immediate numbers. If a larger immediate number needs to be processed, it must first be placed in a register, and then the add.d instruction is used to complete the processing of the larger immediate number. If a larger immediate number c satisfies is32Bit(c) && c&0xffff == 0, then the ADDV16 instruction can be used to complete the addition operation. Removes 164 instructions from the go binary on loong64. Change-Id: I404de93cc4eaaa12fe424f5a0d61b03231215d1a Reviewed-on: https://go-review.googlesource.com/c/go/+/700536 Reviewed-by: Meidan Li Reviewed-by: Keith Randall Reviewed-by: Keith Randall Auto-Submit: Michael Pratt Reviewed-by: abner chenc LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt --- test/codegen/arithmetic.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/codegen/arithmetic.go') diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index beabfe24eb..7055db3dc9 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -51,6 +51,11 @@ func AddLargeConst(a uint64, out []uint64) { out[9] = a - 32769 } +func AddLargeConst2(a int, out []int) { + // loong64: -"ADDVU","ADDV16" + out[0] = a + 0x10000 +} + // ----------------- // // Subtraction // // ----------------- // -- cgit v1.3-6-g1900