diff options
| author | Xiaolin Zhao <zhaoxiaolin@loongson.cn> | 2025-09-03 15:43:21 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-09-05 08:18:04 -0700 |
| commit | 3492e4262b751c5a117a3c77ba5e243b16918e61 (patch) | |
| tree | b2c0596cde53eeda34c3b2f00fc83c16dc9613d0 /test/codegen/arithmetic.go | |
| parent | 459b85ccaa30bbce4c22b2779672dfe402a2b2da (diff) | |
| download | go-3492e4262b751c5a117a3c77ba5e243b16918e61.tar.xz | |
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 <limeidan@loongson.cn>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'test/codegen/arithmetic.go')
| -rw-r--r-- | test/codegen/arithmetic.go | 5 |
1 files changed, 5 insertions, 0 deletions
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 // // ----------------- // |
