diff options
| author | Meng Zhuo <mengzhuo@iscas.ac.cn> | 2025-11-18 09:53:21 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-11-21 12:40:29 -0800 |
| commit | e7d47ac33d71666863509334192a03da90d4acab (patch) | |
| tree | 301ebd9e4c05c76717d4f4fa0786dceac59fadd8 /test/codegen/arithmetic.go | |
| parent | 35d2712b324af111816e9d637032cbbb8eaeedc7 (diff) | |
| download | go-e7d47ac33d71666863509334192a03da90d4acab.tar.xz | |
cmd/compile: simplify negative on multiplication
goos: linux
goarch: amd64
pkg: cmd/compile/internal/test
cpu: AMD EPYC 7532 32-Core Processor
│ simplify_base │ simplify_new │
│ sec/op │ sec/op vs base │
SimplifyNegMul 623.0n ± 0% 319.3n ± 1% -48.75% (p=0.000 n=10)
goos: linux
goarch: riscv64
pkg: cmd/compile/internal/test
cpu: Spacemit(R) X60
│ simplify.base │ simplify.new │
│ sec/op │ sec/op vs base │
SimplifyNegMul 10.928µ ± 0% 6.432µ ± 0% -41.14% (p=0.000 n=10)
Change-Id: I1d9393cd19a0b948a5d3a512d627cdc0cf0b38be
Reviewed-on: https://go-review.googlesource.com/c/go/+/721520
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/arithmetic.go')
| -rw-r--r-- | test/codegen/arithmetic.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index 9443d812dc..29764bf817 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -337,11 +337,26 @@ func Mul32(a, b int32) int64 { // arm64:"SMULL" -"MOVW" return int64(a) * int64(b) } + func Mul32U(a, b uint32) uint64 { // arm64:"UMULL" -"MOVWU" return uint64(a) * uint64(b) } +func SimplifyNegMulConst(a int) int { + // amd64:-"NEGQ" + // arm64:"MOVD [$]11" "MUL" -"NEG" + // riscv64:"MOV [$]11" "MUL" -"NEG" + return -(a * -11) +} + +func SimplifyNegMul(a, b int) int { + // amd64:-"NEGQ" + // arm64:"MUL" -"NEG" + // riscv64:"MUL" -"NEG" + return -(-a * b) +} + // -------------- // // Division // // -------------- // |
