]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fold negation into multiplication on loong64
authorXiaolin Zhao <zhaoxiaolin@loongson.cn>
Tue, 17 Jun 2025 12:47:10 +0000 (20:47 +0800)
committerabner chenc <chenguoqi@loongson.cn>
Wed, 6 Aug 2025 01:02:06 +0000 (18:02 -0700)
commita5527374181c936938676608d469baa41e9abe8b
tree525639db374e5f2fabaf50452b69c9a2788f606f
parente1fd4faf914b914856dfb0be1ad26cd4cef4a9ae
cmd/compile: fold negation into multiplication on loong64

This change also add corresponding benchmark tests and codegen tests.
The performance improvement on CPU Loongson-3A6000-HV is as follows:

goos: linux
goarch: loong64
pkg: cmd/compile/internal/test
cpu: Loongson-3A6000-HV @ 2500.00MHz
        |  bench.old   |              bench.new              |
        |    sec/op    |   sec/op     vs base                |
MulNeg     828.4n ± 0%   655.9n ± 0%  -20.82% (p=0.000 n=10)
Mul2Neg   1062.0n ± 0%   826.8n ± 0%  -22.15% (p=0.000 n=10)
geomean    938.0n        736.4n       -21.49%

Change-Id: Ia999732880ec65be0c66cddc757a4868847e5b15
Reviewed-on: https://go-review.googlesource.com/c/go/+/682535
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
src/cmd/compile/internal/ssa/_gen/LOONG64.rules
src/cmd/compile/internal/ssa/rewriteLOONG64.go
src/cmd/compile/internal/test/bench_test.go
test/codegen/arithmetic.go