diff options
| author | Keith Randall <khr@golang.org> | 2016-08-23 10:43:47 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2016-08-23 23:45:12 +0000 |
| commit | 3e270ab80bbbc259402f0ae22b5eb36f4daec426 (patch) | |
| tree | 34836f4f96c46c1bf46ac6a2634b5889d60ae259 /src/runtime | |
| parent | 6394eb378eb6b2c0e691c519b2a6664f930b427e (diff) | |
| download | go-3e270ab80bbbc259402f0ae22b5eb36f4daec426.tar.xz | |
cmd/compile: clean up ctz ops
Now that we have ops that can return 2 results, have BSF return a result
and flags. We can then get rid of the redundant comparison and use CMOV
instead of CMOVconst ops.
Get rid of a bunch of the ops we don't use. Ctz{8,16}, plus all the Clzs,
and CMOVNEs. I don't think we'll ever use them, and they would be easy
to add back if needed.
Change-Id: I8858a1d017903474ea7e4002fc76a6a86e7bd487
Reviewed-on: https://go-review.googlesource.com/27630
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/internal/sys/intrinsics.go | 33 | ||||
| -rw-r--r-- | src/runtime/internal/sys/intrinsics_386.s | 16 | ||||
| -rw-r--r-- | src/runtime/internal/sys/intrinsics_stubs.go | 2 | ||||
| -rw-r--r-- | src/runtime/internal/sys/intrinsics_test.go | 16 |
4 files changed, 0 insertions, 67 deletions
diff --git a/src/runtime/internal/sys/intrinsics.go b/src/runtime/internal/sys/intrinsics.go index 08a062f85a..db2cbecc0e 100644 --- a/src/runtime/internal/sys/intrinsics.go +++ b/src/runtime/internal/sys/intrinsics.go @@ -30,19 +30,6 @@ var deBruijnIdx32 = [32]byte{ 30, 9, 19, 24, 29, 18, 28, 27, } -const deBruijn16 = 0x09af - -var deBruijnIdx16 = [16]byte{ - 0, 1, 2, 5, 3, 9, 6, 11, - 15, 4, 8, 10, 14, 7, 13, 12, -} - -const deBruijn8 = 0x17 - -var deBruijnIdx8 = [8]byte{ - 0, 1, 2, 4, 7, 3, 6, 5, -} - // Ctz64 counts trailing (low-order) zeroes, // and if all are zero, then 64. func Ctz64(x uint64) uint64 { @@ -63,26 +50,6 @@ func Ctz32(x uint32) uint32 { return y + z } -// Ctz16 counts trailing (low-order) zeroes, -// and if all are zero, then 16. -func Ctz16(x uint16) uint16 { - x &= -x // isolate low-order bit - y := x * deBruijn16 >> 12 // extract part of deBruijn sequence - y = uint16(deBruijnIdx16[y]) // convert to bit index - z := (x - 1) >> 11 & 16 // adjustment if zero - return y + z -} - -// Ctz8 counts trailing (low-order) zeroes, -// and if all are zero, then 8. -func Ctz8(x uint8) uint8 { - x &= -x // isolate low-order bit - y := x * deBruijn8 >> 5 // extract part of deBruijn sequence - y = uint8(deBruijnIdx8[y]) // convert to bit index - z := (x - 1) >> 4 & 8 // adjustment if zero - return y + z -} - // Bswap64 returns its input with byte order reversed // 0x0102030405060708 -> 0x0807060504030201 func Bswap64(x uint64) uint64 { diff --git a/src/runtime/internal/sys/intrinsics_386.s b/src/runtime/internal/sys/intrinsics_386.s index 1f48e26492..bc63e5ebdf 100644 --- a/src/runtime/internal/sys/intrinsics_386.s +++ b/src/runtime/internal/sys/intrinsics_386.s @@ -36,22 +36,6 @@ TEXT runtime∕internal∕sys·Ctz32(SB), NOSPLIT, $0-8 MOVL AX, ret+4(FP) RET -TEXT runtime∕internal∕sys·Ctz16(SB), NOSPLIT, $0-6 - MOVW x+0(FP), AX - BSFW AX, AX - JNZ 2(PC) - MOVW $16, AX - MOVW AX, ret+4(FP) - RET - -TEXT runtime∕internal∕sys·Ctz8(SB), NOSPLIT, $0-5 - MOVBLZX x+0(FP), AX - BSFL AX, AX - JNZ 2(PC) - MOVB $8, AX - MOVB AX, ret+4(FP) - RET - TEXT runtime∕internal∕sys·Bswap64(SB), NOSPLIT, $0-16 MOVL x_lo+0(FP), AX MOVL x_hi+4(FP), BX diff --git a/src/runtime/internal/sys/intrinsics_stubs.go b/src/runtime/internal/sys/intrinsics_stubs.go index 079844fda4..d351048f86 100644 --- a/src/runtime/internal/sys/intrinsics_stubs.go +++ b/src/runtime/internal/sys/intrinsics_stubs.go @@ -8,7 +8,5 @@ package sys func Ctz64(x uint64) uint64 func Ctz32(x uint32) uint32 -func Ctz16(x uint16) uint16 -func Ctz8(x uint8) uint8 func Bswap64(x uint64) uint64 func Bswap32(x uint32) uint32 diff --git a/src/runtime/internal/sys/intrinsics_test.go b/src/runtime/internal/sys/intrinsics_test.go index 097631bc1e..1f2c8daa96 100644 --- a/src/runtime/internal/sys/intrinsics_test.go +++ b/src/runtime/internal/sys/intrinsics_test.go @@ -21,22 +21,6 @@ func TestCtz32(t *testing.T) { } } } -func TestCtz16(t *testing.T) { - for i := uint(0); i <= 16; i++ { - x := uint16(5) << i - if got := sys.Ctz16(x); got != uint16(i) { - t.Errorf("Ctz16(%d)=%d, want %d", x, got, i) - } - } -} -func TestCtz8(t *testing.T) { - for i := uint(0); i <= 8; i++ { - x := uint8(5) << i - if got := sys.Ctz8(x); got != uint8(i) { - t.Errorf("Ctz8(%d)=%d, want %d", x, got, i) - } - } -} func TestBswap64(t *testing.T) { x := uint64(0x1122334455667788) |
