aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorXiaolin Zhao <zhaoxiaolin@loongson.cn>2025-08-12 19:23:46 +0800
committerGopher Robot <gobot@golang.org>2025-08-13 07:20:08 -0700
commit9763ece873293c05560444cd6c6b8ea4cd2af1b4 (patch)
treee804d3e2423b3f00d01887546fa8bbabf9fbaef6 /src/cmd
parentf10a82b76ff92b3c506203485b158191de4b3090 (diff)
downloadgo-9763ece873293c05560444cd6c6b8ea4cd2af1b4.tar.xz
cmd/compile: absorb NEGV into branch on loong64
Removes 132 instructions from the go binary on loong64. Change-Id: Ia02dc305b12f63a64f3f48d120ef852d45cc2a7b Reviewed-on: https://go-review.googlesource.com/c/go/+/695115 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/compile/internal/ssa/_gen/LOONG64.rules4
-rw-r--r--src/cmd/compile/internal/ssa/rewriteLOONG64.go16
2 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/_gen/LOONG64.rules b/src/cmd/compile/internal/ssa/_gen/LOONG64.rules
index 4c19507628..efeeca652c 100644
--- a/src/cmd/compile/internal/ssa/_gen/LOONG64.rules
+++ b/src/cmd/compile/internal/ssa/_gen/LOONG64.rules
@@ -951,6 +951,10 @@
(GEZ (MOVVconst [c]) yes no) && c >= 0 => (First yes no)
(GEZ (MOVVconst [c]) yes no) && c < 0 => (First no yes)
+// absorb NEGV into branches
+(EQZ (NEGV x) yes no) => (EQZ x yes no)
+(NEZ (NEGV x) yes no) => (NEZ x yes no)
+
// Convert branch with zero to more optimal branch zero.
(BEQ (MOVVconst [0]) cond yes no) => (EQZ cond yes no)
(BEQ cond (MOVVconst [0]) yes no) => (EQZ cond yes no)
diff --git a/src/cmd/compile/internal/ssa/rewriteLOONG64.go b/src/cmd/compile/internal/ssa/rewriteLOONG64.go
index 3065e2c315..6f29588f9a 100644
--- a/src/cmd/compile/internal/ssa/rewriteLOONG64.go
+++ b/src/cmd/compile/internal/ssa/rewriteLOONG64.go
@@ -11808,6 +11808,14 @@ func rewriteBlockLOONG64(b *Block) bool {
b.swapSuccessors()
return true
}
+ // match: (EQZ (NEGV x) yes no)
+ // result: (EQZ x yes no)
+ for b.Controls[0].Op == OpLOONG64NEGV {
+ v_0 := b.Controls[0]
+ x := v_0.Args[0]
+ b.resetWithControl(BlockLOONG64EQZ, x)
+ return true
+ }
case BlockLOONG64GEZ:
// match: (GEZ (MOVVconst [c]) yes no)
// cond: c >= 0
@@ -12135,6 +12143,14 @@ func rewriteBlockLOONG64(b *Block) bool {
b.Reset(BlockFirst)
return true
}
+ // match: (NEZ (NEGV x) yes no)
+ // result: (NEZ x yes no)
+ for b.Controls[0].Op == OpLOONG64NEGV {
+ v_0 := b.Controls[0]
+ x := v_0.Args[0]
+ b.resetWithControl(BlockLOONG64NEZ, x)
+ return true
+ }
}
return false
}