diff options
| author | Julian Zhu <jz531210@gmail.com> | 2025-05-17 00:14:31 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-05-16 11:06:06 -0700 |
| commit | 8097cf14d20b547a615aae7d1b738a6aa563aa31 (patch) | |
| tree | 3ce28cef1766920bb872a4cd5cbac352a340079e /test/codegen/arithmetic.go | |
| parent | 07a279794dff7ef3371710f1de4b3f9fc4ef4987 (diff) | |
| download | go-8097cf14d20b547a615aae7d1b738a6aa563aa31.tar.xz | |
cmd/compile: fold negation into addition/subtraction on mips64x
Fold negation into addition/subtraction and avoid double negation.
file before after Δ %
addr2line 4007310 4007470 +160 +0.004%
asm 7007636 7007436 -200 -0.003%
buildid 3839268 3838972 -296 -0.008%
cgo 6353466 6352738 -728 -0.011%
compile 30426920 30426896 -24 -0.000%
cover 7005408 7004744 -664 -0.009%
dist 4651192 4650872 -320 -0.007%
doc 10606050 10606034 -16 -0.000%
fix 4446414 4446390 -24 -0.001%
link 9237736 9237024 -712 -0.008%
nm 3999107 3999323 +216 +0.005%
objdump 6762424 6762144 -280 -0.004%
pack 3270757 3270493 -264 -0.008%
pprof 19428299 19361939 -66360 -0.342%
test2json 3717345 3717217 -128 -0.003%
trace 17382273 17381657 -616 -0.004%
vet 10689481 10688985 -496 -0.005%
go 19118769 19118609 -160 -0.001%
total 171949855 171878943 -70912 -0.041%
Change-Id: I35c1f264d216c214ea3f56252a9ddab8ea850fa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/673555
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'test/codegen/arithmetic.go')
| -rw-r--r-- | test/codegen/arithmetic.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index d02154bd3c..1023a62bee 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -92,6 +92,7 @@ func SubFromConst(a int) int { func SubFromConstNeg(a int) int { // loong64: "ADDV[U]\t\\$40" + // mips64: "ADDV[U]\t\\$40" // ppc64x: `ADD\t[$]40,\sR[0-9]+,\sR` // riscv64: "ADDI\t\\$40",-"NEG" c := 40 - (-a) @@ -100,6 +101,7 @@ func SubFromConstNeg(a int) int { func SubSubFromConst(a int) int { // loong64: "ADDV[U]\t\\$20" + // mips64: "ADDV[U]\t\\$20" // ppc64x: `ADD\t[$]20,\sR[0-9]+,\sR` // riscv64: "ADDI\t\\$20",-"NEG" c := 40 - (20 - a) @@ -115,6 +117,7 @@ func AddSubFromConst(a int) int { func NegSubFromConst(a int) int { // loong64: "ADDV[U]\t\\$-20" + // mips64: "ADDV[U]\t\\$-20" // ppc64x: `ADD\t[$]-20,\sR[0-9]+,\sR` // riscv64: "ADDI\t\\$-20" c := -(20 - a) @@ -123,6 +126,7 @@ func NegSubFromConst(a int) int { func NegAddFromConstNeg(a int) int { // loong64: "ADDV[U]\t\\$-40","SUBV" + // mips64: "ADDV[U]\t\\$-40","SUBV" // ppc64x: `SUBC\tR[0-9]+,\s[$]40,\sR` // riscv64: "ADDI\t\\$-40","NEG" c := -(-40 + a) @@ -132,6 +136,7 @@ func NegAddFromConstNeg(a int) int { func SubSubNegSimplify(a, b int) int { // amd64:"NEGQ" // loong64:"SUBV" + // mips64:"SUBV" // ppc64x:"NEG" // riscv64:"NEG",-"SUB" r := (a - b) - a @@ -141,6 +146,7 @@ func SubSubNegSimplify(a, b int) int { func SubAddSimplify(a, b int) int { // amd64:-"SUBQ",-"ADDQ" // loong64:-"SUBV",-"ADDV" + // mips64:-"SUBV",-"ADDV" // ppc64x:-"SUB",-"ADD" // riscv64:-"SUB",-"ADD" r := a + (b - a) @@ -149,6 +155,7 @@ func SubAddSimplify(a, b int) int { func SubAddSimplify2(a, b, c int) (int, int, int, int, int, int) { // amd64:-"ADDQ" + // mips64:"SUBV",-"ADDV" // loong64:"SUBV",-"ADDV" r := (a + b) - (a + c) // amd64:-"ADDQ" @@ -158,6 +165,7 @@ func SubAddSimplify2(a, b, c int) (int, int, int, int, int, int) { // amd64:-"ADDQ" r3 := (b + a) - (c + a) // amd64:-"SUBQ" + // mips64:"ADDV",-"SUBV" // loong64:"ADDV",-"SUBV" r4 := (a - c) + (c + b) // amd64:-"SUBQ" @@ -168,6 +176,7 @@ func SubAddSimplify2(a, b, c int) (int, int, int, int, int, int) { func SubAddNegSimplify(a, b int) int { // amd64:"NEGQ",-"ADDQ",-"SUBQ" // loong64:"SUBV",-"ADDV" + // mips64:"SUBV",-"ADDV" // ppc64x:"NEG",-"ADD",-"SUB" // riscv64:"NEG",-"ADD",-"SUB" r := a - (b + a) @@ -177,6 +186,7 @@ func SubAddNegSimplify(a, b int) int { func AddAddSubSimplify(a, b, c int) int { // amd64:-"SUBQ" // loong64:"ADDV",-"SUBV" + // mips64:"ADDV",-"SUBV" // ppc64x:-"SUB" // riscv64:"ADD","ADD",-"SUB" r := a + (b + (c - a)) |
