Skip to content

Commit a7f05b3

Browse files
sophie-zhaoabner-chenc
authored andcommitted
cmd/compile: convert branch with zero to more optimal branch zero on loong64
This reduces 7500+ instructions from the go toolchain binary on loong64. file before after Δ % asm 555066 554406 -660 -0.1189% cgo 481480 480764 -716 -0.1487% compile 2475836 2474776 -1060 -0.0428% cover 516536 515788 -748 -0.1448% link 702220 701216 -1004 -0.1430% preprofile 238626 238122 -504 -0.2112% vet 792798 791894 -904 -0.1140% go 1573108 1571676 -1432 -0.0910% gofmt 320578 320042 -536 -0.1672% total 7656248 7648684 -7564 -0.0988% Change-Id: I51b70a1543bc258b7664caa8647e75eecbaf5eed Reviewed-on: https://go-review.googlesource.com/c/go/+/693495 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: abner chenc <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 1718828 commit a7f05b3

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

src/cmd/compile/internal/ssa/_gen/LOONG64.rules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,18 @@
951951
(GEZ (MOVVconst [c]) yes no) && c >= 0 => (First yes no)
952952
(GEZ (MOVVconst [c]) yes no) && c < 0 => (First no yes)
953953

954+
// Convert branch with zero to more optimal branch zero.
955+
(BEQ (MOVVconst [0]) cond yes no) => (EQZ cond yes no)
956+
(BEQ cond (MOVVconst [0]) yes no) => (EQZ cond yes no)
957+
(BNE (MOVVconst [0]) cond yes no) => (NEZ cond yes no)
958+
(BNE cond (MOVVconst [0]) yes no) => (NEZ cond yes no)
959+
(BLT (MOVVconst [0]) cond yes no) => (GTZ cond yes no)
960+
(BLT cond (MOVVconst [0]) yes no) => (LTZ cond yes no)
961+
(BLTU (MOVVconst [0]) cond yes no) => (NEZ cond yes no)
962+
(BGE (MOVVconst [0]) cond yes no) => (LEZ cond yes no)
963+
(BGE cond (MOVVconst [0]) yes no) => (GEZ cond yes no)
964+
(BGEU (MOVVconst [0]) cond yes no) => (EQZ cond yes no)
965+
954966
// Arch-specific inlining for small or disjoint runtime.memmove
955967
// Match post-lowering calls, register version.
956968
(SelectN [0] call:(CALLstatic {sym} dst src (MOVVconst [sz]) mem))

src/cmd/compile/internal/ssa/rewriteLOONG64.go

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)