]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add intrinsics for runtime/internal/math on 386 and amd64
authorMartin Möhrmann <moehrmann@google.com>
Sat, 27 Jan 2018 10:55:34 +0000 (11:55 +0100)
committerMartin Möhrmann <moehrmann@google.com>
Mon, 15 Oct 2018 19:04:09 +0000 (19:04 +0000)
commita1ca4893ff755d6b0b3bf4b026196d55251ea846
tree72a39af659aa88e0a62a5da6ef6d45a659fcfc51
parent9f66b41beea82cc613cad9138c10a50f2b3ea137
cmd/compile: add intrinsics for runtime/internal/math on 386 and amd64

Add generic, 386 and amd64 specific ops and SSA rules for multiplication
with overflow and branching based on overflow flags. Use these to intrinsify
runtime/internal/math.MulUinptr.

On amd64
  mul, overflow := math.MulUintptr(a, b)
  if overflow {
is lowered to two instructions:
  MULQ SI
  JO 0x10ee35c

No codegen tests as codegen can not currently test unexported internal runtime
functions.

amd64:
name              old time/op  new time/op  delta
MulUintptr/small  1.16ns ± 5%  0.88ns ± 6%  -24.36%  (p=0.000 n=19+20)
MulUintptr/large  10.7ns ± 1%   1.1ns ± 1%  -89.28%  (p=0.000 n=17+19)

Change-Id: If60739a86f820e5044d677276c21df90d3c7a86a
Reviewed-on: https://go-review.googlesource.com/c/141820
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
12 files changed:
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/gen/386.rules
src/cmd/compile/internal/ssa/gen/386Ops.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/AMD64Ops.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewrite386.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
src/cmd/compile/internal/x86/ssa.go
src/runtime/internal/math/math_test.go