]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: declare runtime bit func aliases after math/bits intrinsics
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 20 Mar 2020 15:26:46 +0000 (15:26 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 23 Mar 2020 15:52:57 +0000 (15:52 +0000)
Currently runtime/internal/sys bit-manipulation functions are aliased to
math/bits functions, which are intrinsified. Unfortunately these aliases
are declared before the intrinsified versions are generated, resulting
in the generic version of the code being copied over.

This change moves the aliases for bit operations in runtime/internal/sys
after the addF calls to generate those intrinsics in SSA, so that the
intrinsified SSA representation of those functions actually get copied
over.

This should improve the overall performance of the runtime (especially
the page allocator) since these bit operations will actually be
intrinsified now.

Change-Id: I4377da13f9a7bb6aee608e50df0297148bf8f806
Reviewed-on: https://go-review.googlesource.com/c/go/+/224437
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/ssa.go

index d5a5614ba2f94738c417cd14555ef3ae307cdc45..76832ca82988c1e3d457737696c69f0716e0fe95 100644 (file)
@@ -3522,13 +3522,6 @@ func init() {
        alias("runtime/internal/atomic", "Casp1", "runtime/internal/atomic", "Cas64", p8...)
        alias("runtime/internal/atomic", "CasRel", "runtime/internal/atomic", "Cas", lwatomics...)
 
-       alias("runtime/internal/sys", "Ctz8", "math/bits", "TrailingZeros8", all...)
-       alias("runtime/internal/sys", "TrailingZeros8", "math/bits", "TrailingZeros8", all...)
-       alias("runtime/internal/sys", "TrailingZeros64", "math/bits", "TrailingZeros64", all...)
-       alias("runtime/internal/sys", "Len8", "math/bits", "Len8", all...)
-       alias("runtime/internal/sys", "Len64", "math/bits", "Len64", all...)
-       alias("runtime/internal/sys", "OnesCount64", "math/bits", "OnesCount64", all...)
-
        /******** math ********/
        addF("math", "Sqrt",
                func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
@@ -3950,6 +3943,13 @@ func init() {
                sys.AMD64)
        alias("math/bits", "Div", "math/bits", "Div64", sys.ArchAMD64)
 
+       alias("runtime/internal/sys", "Ctz8", "math/bits", "TrailingZeros8", all...)
+       alias("runtime/internal/sys", "TrailingZeros8", "math/bits", "TrailingZeros8", all...)
+       alias("runtime/internal/sys", "TrailingZeros64", "math/bits", "TrailingZeros64", all...)
+       alias("runtime/internal/sys", "Len8", "math/bits", "Len8", all...)
+       alias("runtime/internal/sys", "Len64", "math/bits", "Len64", all...)
+       alias("runtime/internal/sys", "OnesCount64", "math/bits", "OnesCount64", all...)
+
        /******** sync/atomic ********/
 
        // Note: these are disabled by flag_race in findIntrinsic below.