aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewrite386.go
diff options
context:
space:
mode:
authorBen Shi <powerman1st@163.com>2019-08-07 05:20:32 +0000
committerBen Shi <powerman1st@163.com>2019-08-28 02:29:54 +0000
commit22355d6cd2421f13e560f90e77ca04ef816456da (patch)
tree3ed677893926c8f3bbc21e2962d23ac517a31c70 /src/cmd/compile/internal/ssa/rewrite386.go
parente1e4c499f0849af4fca353163e4ffabbda6f9089 (diff)
downloadgo-22355d6cd2421f13e560f90e77ca04ef816456da.tar.gz
go-22355d6cd2421f13e560f90e77ca04ef816456da.zip
cmd/compile: optimize 386's math.bits.TrailingZeros16
This CL optimizes math.bits.TrailingZeros16 on 386 with a pair of BSFL and ORL instrcutions. The case TrailingZeros16-4 of the benchmark test in math/bits shows big improvement. name old time/op new time/op delta TrailingZeros16-4 1.55ns ± 1% 0.87ns ± 1% -43.87% (p=0.000 n=50+49) Change-Id: Ia899975b0e46f45dcd20223b713ed632bc32740b Reviewed-on: https://go-review.googlesource.com/c/go/+/189277 Run-TryBot: Ben Shi <powerman1st@163.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewrite386.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewrite386.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/rewrite386.go b/src/cmd/compile/internal/ssa/rewrite386.go
index 812aa9420d..2336561560 100644
--- a/src/cmd/compile/internal/ssa/rewrite386.go
+++ b/src/cmd/compile/internal/ssa/rewrite386.go
@@ -360,6 +360,8 @@ func rewriteValue386(v *Value) bool {
return rewriteValue386_OpConstBool_0(v)
case OpConstNil:
return rewriteValue386_OpConstNil_0(v)
+ case OpCtz16:
+ return rewriteValue386_OpCtz16_0(v)
case OpCvt32Fto32:
return rewriteValue386_OpCvt32Fto32_0(v)
case OpCvt32Fto64F:
@@ -20783,6 +20785,22 @@ func rewriteValue386_OpConstNil_0(v *Value) bool {
return true
}
}
+func rewriteValue386_OpCtz16_0(v *Value) bool {
+ b := v.Block
+ typ := &b.Func.Config.Types
+ // match: (Ctz16 x)
+ // cond:
+ // result: (BSFL (ORLconst <typ.UInt32> [0x10000] x))
+ for {
+ x := v.Args[0]
+ v.reset(Op386BSFL)
+ v0 := b.NewValue0(v.Pos, Op386ORLconst, typ.UInt32)
+ v0.AuxInt = 0x10000
+ v0.AddArg(x)
+ v.AddArg(v0)
+ return true
+ }
+}
func rewriteValue386_OpCvt32Fto32_0(v *Value) bool {
// match: (Cvt32Fto32 x)
// cond: