]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: intrinsify math/bits/ReverseBytes{32|64} for 386
authorWayne Zuo <wdvxdr@golangcn.org>
Mon, 6 Feb 2023 13:21:52 +0000 (21:21 +0800)
committerWayne Zuo <wdvxdr@golangcn.org>
Wed, 8 Feb 2023 03:43:23 +0000 (03:43 +0000)
The BSWAPL instruction is supported in i486 and newer.
https://github.com/golang/go/wiki/MinimumRequirements#386 says we
support "All Pentium MMX or later". The Pentium is also referred to as
i586, so that we are safe with these instructions.

Change-Id: I6dea1f9d864a45bb07c8f8f35a81cfe16cca216c
Reviewed-on: https://go-review.googlesource.com/c/go/+/465515
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ssagen/ssa.go
test/codegen/mathbits.go

index f31cf29925e83be05a3e8d7d369736fb0549752d..2e2a6b411b791b1a4e5da4460bae6455639cd38d 100644 (file)
@@ -4000,10 +4000,10 @@ func InitTables() {
                },
                sys.ARM64, sys.PPC64)
 
-       /* Use only on Power10 as the new byte reverse instructions that Power10 provide
-          make it worthwhile as an intrinsic */
-       brev_arch := []sys.ArchFamily{sys.AMD64, sys.ARM64, sys.ARM, sys.S390X}
+       brev_arch := []sys.ArchFamily{sys.AMD64, sys.I386, sys.ARM64, sys.ARM, sys.S390X}
        if buildcfg.GOPPC64 >= 10 {
+               // Use only on Power10 as the new byte reverse instructions that Power10 provide
+               // make it worthwhile as an intrinsic
                brev_arch = append(brev_arch, sys.PPC64)
        }
        /******** runtime/internal/sys ********/
index 0eed27a61948b6f83b93eaf3e5f2ede147bf6d38..86a44d7c9359a9c135daa5c25708ce277447bbbe 100644 (file)
@@ -189,6 +189,7 @@ func OnesCount8(n uint8) int {
 
 func ReverseBytes(n uint) uint {
        // amd64:"BSWAPQ"
+       // 386:"BSWAPL"
        // s390x:"MOVDBR"
        // arm64:"REV"
        return bits.ReverseBytes(n)
@@ -196,6 +197,7 @@ func ReverseBytes(n uint) uint {
 
 func ReverseBytes64(n uint64) uint64 {
        // amd64:"BSWAPQ"
+       // 386:"BSWAPL"
        // s390x:"MOVDBR"
        // arm64:"REV"
        // ppc64x/power10: "BRD"
@@ -204,6 +206,7 @@ func ReverseBytes64(n uint64) uint64 {
 
 func ReverseBytes32(n uint32) uint32 {
        // amd64:"BSWAPL"
+       // 386:"BSWAPL"
        // s390x:"MOVWBR"
        // arm64:"REVW"
        // ppc64x/power10: "BRW"