]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: modify switches of strings to use jump table for lengths
authorKeith Randall <khr@golang.org>
Sun, 6 Mar 2022 20:07:54 +0000 (12:07 -0800)
committerKeith Randall <khr@google.com>
Thu, 14 Apr 2022 21:16:11 +0000 (21:16 +0000)
commit3d8cb26504f9e3f5b45b4ea97b55714a25e016c1
tree3520fe5dda3bb7a68f0887cc2f6e7fd671ce4231
parent01b9ae22ed3c0f9c9ea29adbcd23bd97de6d18dd
cmd/compile: modify switches of strings to use jump table for lengths

Reorganize the way we rewrite expression switches on strings, so that
jump tables are naturally used for the outer switch on the string length.

The changes to the prove pass in this CL are required so as to not repeat
the test for string length in each case.

name                         old time/op  new time/op  delta
SwitchStringPredictable    2.28ns ± 9%  2.08ns ± 5%   -9.04%  (p=0.000 n=10+10)
SwitchStringUnpredictable  10.5ns ± 1%   9.5ns ± 1%   -9.08%  (p=0.000 n=9+10)

Update #5496
Update #34381

Change-Id: Ie6846b1dd27f3e472f7c30dfcc598c68d440b997
Reviewed-on: https://go-review.googlesource.com/c/go/+/395714
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ssa/prove.go
src/cmd/compile/internal/test/switch_test.go
src/cmd/compile/internal/walk/switch.go