From cedfcba3e859316410ae820abc5b43f9bda4e4f6 Mon Sep 17 00:00:00 2001 From: Wayne Zuo Date: Sun, 12 Mar 2023 15:34:20 +0800 Subject: cmd/compile: instrinsify TrailingZeros{8,32,64} for 386 This CL add support for instrinsifying the TrialingZeros{8,32,64} functions for 386 architecture. We need handle the case when the input is 0, which could lead to undefined output from the BSFL instruction. Next CL will remove the assembly code in runtime/internal/sys package. Change-Id: Ic168edf68e81bf69a536102100fdd3f56f0f4a1b Reviewed-on: https://go-review.googlesource.com/c/go/+/475735 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Cherry Mui Run-TryBot: Wayne Zuo TryBot-Result: Gopher Robot --- test/codegen/mathbits.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go index 86a44d7c93..8c971cf760 100644 --- a/test/codegen/mathbits.go +++ b/test/codegen/mathbits.go @@ -293,6 +293,7 @@ func RotateLeftVariable32(n uint32, m int) uint32 { func TrailingZeros(n uint) int { // amd64/v1,amd64/v2:"BSFQ","MOVL\t\\$64","CMOVQEQ" // amd64/v3:"TZCNTQ" + // 386:"BSFL" // arm:"CLZ" // arm64:"RBIT","CLZ" // s390x:"FLOGR" @@ -305,6 +306,7 @@ func TrailingZeros(n uint) int { func TrailingZeros64(n uint64) int { // amd64/v1,amd64/v2:"BSFQ","MOVL\t\\$64","CMOVQEQ" // amd64/v3:"TZCNTQ" + // 386:"BSFL" // arm64:"RBIT","CLZ" // s390x:"FLOGR" // ppc64x/power8:"ANDN","POPCNTD" @@ -322,6 +324,7 @@ func TrailingZeros64Subtract(n uint64) int { func TrailingZeros32(n uint32) int { // amd64/v1,amd64/v2:"BTSQ\\t\\$32","BSFQ" // amd64/v3:"TZCNTL" + // 386:"BSFL" // arm:"CLZ" // arm64:"RBITW","CLZW" // s390x:"FLOGR","MOVWZ" @@ -345,6 +348,7 @@ func TrailingZeros16(n uint16) int { func TrailingZeros8(n uint8) int { // amd64:"BSFL","BTSL\\t\\$8" + // 386:"BSFL" // arm:"ORR\t\\$256","CLZ",-"MOVBU\tR" // arm64:"ORR\t\\$256","RBITW","CLZW",-"MOVBU\tR",-"RBIT\t",-"CLZ\t" // s390x:"FLOGR","OR\t\\$256" -- cgit v1.3