From af6999e60d498887fceaeca89f4aa88ff35c91df Mon Sep 17 00:00:00 2001 From: limeidan Date: Fri, 19 Sep 2025 11:18:13 +0800 Subject: cmd/compile: implement jump table on loong64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following CL 357330, use jump tables on Loong64. goos: linux goarch: loong64 pkg: cmd/compile/internal/test cpu: Loongson-3A6000-HV @ 2500.00MHz │ old │ new │ │ sec/op │ sec/op vs base │ Switch8Predictable 2.352n ± 0% 2.101n ± 0% -10.65% (p=0.000 n=10) Switch8Unpredictable 11.99n ± 0% 10.25n ± 0% -14.51% (p=0.000 n=10) Switch32Predictable 3.153n ± 0% 1.887n ± 1% -40.14% (p=0.000 n=10) Switch32Unpredictable 12.47n ± 0% 10.22n ± 0% -18.00% (p=0.000 n=10) SwitchStringPredictable 3.162n ± 0% 3.352n ± 0% +6.01% (p=0.000 n=10) SwitchStringUnpredictable 14.70n ± 0% 13.31n ± 0% -9.46% (p=0.000 n=10) SwitchTypePredictable 3.702n ± 0% 2.201n ± 0% -40.55% (p=0.000 n=10) SwitchTypeUnpredictable 16.18n ± 0% 14.48n ± 0% -10.51% (p=0.000 n=10) SwitchInterfaceTypePredictable 7.654n ± 0% 9.680n ± 0% +26.47% (p=0.000 n=10) SwitchInterfaceTypeUnpredictable 22.04n ± 0% 22.44n ± 0% +1.81% (p=0.000 n=10) geomean 7.441n 6.469n -13.07% Change-Id: Id6f30fa73349c60fac17670084daee56973a955f Reviewed-on: https://go-review.googlesource.com/c/go/+/705396 LUCI-TryBot-Result: Go LUCI Reviewed-by: Junyang Shao Reviewed-by: Michael Knyszek Reviewed-by: abner chenc --- test/codegen/switch.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/switch.go b/test/codegen/switch.go index 509343110a..1a66a5ddf8 100644 --- a/test/codegen/switch.go +++ b/test/codegen/switch.go @@ -25,6 +25,7 @@ func f(x string) int { func square(x int) int { // amd64:`JMP\s\(.*\)\(.*\)$` // arm64:`MOVD\s\(R.*\)\(R.*<<3\)`,`JMP\s\(R.*\)$` + // loong64: `ALSLV`,`MOVV`,`JMP` switch x { case 1: return 1 @@ -51,6 +52,7 @@ func square(x int) int { func length(x string) int { // amd64:`JMP\s\(.*\)\(.*\)$` // arm64:`MOVD\s\(R.*\)\(R.*<<3\)`,`JMP\s\(R.*\)$` + // loong64:`ALSLV`,`MOVV`,`JMP` switch x { case "a": return 1 -- cgit v1.3