]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: simplify specific addition operations using the ADDV16 instruction
authorXiaolin Zhao <zhaoxiaolin@loongson.cn>
Wed, 3 Sep 2025 07:43:21 +0000 (15:43 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 5 Sep 2025 15:18:04 +0000 (08:18 -0700)
commit3492e4262b751c5a117a3c77ba5e243b16918e61
treeb2c0596cde53eeda34c3b2f00fc83c16dc9613d0
parent459b85ccaa30bbce4c22b2779672dfe402a2b2da
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>
src/cmd/compile/internal/loong64/ssa.go
src/cmd/compile/internal/ssa/_gen/LOONG64.rules
src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteLOONG64.go
test/codegen/arithmetic.go