diff options
author | Ben Shi <powerman1st@163.com> | 2019-08-02 02:20:38 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-08-28 15:41:58 +0000 |
commit | 3cfd003a8a89c6662b4b63d837a8cfae95e6762a (patch) | |
tree | 6df2765928100a13e6e1f01d8335c1e865f08ac6 /src/cmd/compile/internal/ssa/rewriteARM.go | |
parent | c683ab8128e3d26a9894f315793b32fb80e4b5b3 (diff) | |
download | go-3cfd003a8a89c6662b4b63d837a8cfae95e6762a.tar.gz go-3cfd003a8a89c6662b4b63d837a8cfae95e6762a.zip |
cmd/compile: optimize ARM's math.bits.RotateLeft32
This CL optimizes math.bits.RotateLeft32 to inline
"MOVW Rx@>Ry, Rd" on ARM.
The benchmark results of math/bits show some improvements.
name old time/op new time/op delta
RotateLeft-4 9.42ns ± 0% 6.91ns ± 0% -26.66% (p=0.000 n=40+33)
RotateLeft8-4 8.79ns ± 0% 8.79ns ± 0% -0.04% (p=0.000 n=40+31)
RotateLeft16-4 8.79ns ± 0% 8.79ns ± 0% -0.04% (p=0.000 n=40+32)
RotateLeft32-4 8.16ns ± 0% 7.54ns ± 0% -7.68% (p=0.000 n=40+40)
RotateLeft64-4 15.7ns ± 0% 15.7ns ± 0% ~ (all equal)
updates #31265
Change-Id: I77bc1c2c702d5323fc7cad5264a8e2d5666bf712
Reviewed-on: https://go-review.googlesource.com/c/go/+/188697
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteARM.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/rewriteARM.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteARM.go b/src/cmd/compile/internal/ssa/rewriteARM.go index 8b569781c5..78227c1b1f 100644 --- a/src/cmd/compile/internal/ssa/rewriteARM.go +++ b/src/cmd/compile/internal/ssa/rewriteARM.go @@ -20242,6 +20242,7 @@ func rewriteValueARM_OpRotateLeft16_0(v *Value) bool { return false } func rewriteValueARM_OpRotateLeft32_0(v *Value) bool { + b := v.Block // match: (RotateLeft32 x (MOVWconst [c])) // cond: // result: (SRRconst [-c&31] x) @@ -20258,7 +20259,20 @@ func rewriteValueARM_OpRotateLeft32_0(v *Value) bool { v.AddArg(x) return true } - return false + // match: (RotateLeft32 x y) + // cond: + // result: (SRR x (RSBconst [0] <y.Type> y)) + for { + y := v.Args[1] + x := v.Args[0] + v.reset(OpARMSRR) + v.AddArg(x) + v0 := b.NewValue0(v.Pos, OpARMRSBconst, y.Type) + v0.AuxInt = 0 + v0.AddArg(y) + v.AddArg(v0) + return true + } } func rewriteValueARM_OpRotateLeft8_0(v *Value) bool { b := v.Block |