diff options
author | Keith Randall <khr@golang.org> | 2017-03-14 13:25:12 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2017-03-16 02:44:16 +0000 |
commit | d5dc4905191c3f7cfeb52e93331d10ebd33301f5 (patch) | |
tree | efbe9f8a06b01b0510d8a09fa4edcc4f2c6fb133 /test/intrinsic.dir | |
parent | 16200c73331a679b43efc4699b5806c64a556f09 (diff) | |
download | go-d5dc4905191c3f7cfeb52e93331d10ebd33301f5.tar.gz go-d5dc4905191c3f7cfeb52e93331d10ebd33301f5.zip |
cmd/compile: intrinsics for math/bits.TrailingZerosX
Implement math/bits.TrailingZerosX using intrinsics.
Generally reorganize the intrinsic spec a bit.
The instrinsics data structure is now built at init time.
This will make doing the other functions in math/bits easier.
Update sys.CtzX to return int instead of uint{64,32} so it
matches math/bits.TrailingZerosX.
Improve the intrinsics a bit for amd64. We don't need the CMOV
for <64 bit versions.
Update #18616
Change-Id: Ic1c5339c943f961d830ae56f12674d7b29d4ff39
Reviewed-on: https://go-review.googlesource.com/38155
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'test/intrinsic.dir')
-rw-r--r-- | test/intrinsic.dir/main.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/intrinsic.dir/main.go b/test/intrinsic.dir/main.go index e0c11d0907..4340dd4b11 100644 --- a/test/intrinsic.dir/main.go +++ b/test/intrinsic.dir/main.go @@ -22,7 +22,7 @@ func logf(f string, args ...interface{}) { } } -func test(i, x uint64) { +func test(i int, x uint64) { t := T.Ctz64(x) // ERROR "intrinsic substitution for Ctz64" if i != t { logf("Ctz64(0x%x) expected %d but got %d\n", x, i, t) @@ -36,12 +36,12 @@ func test(i, x uint64) { if i <= 32 { x32 := uint32(x) t32 := T.Ctz32(x32) // ERROR "intrinsic substitution for Ctz32" - if uint32(i) != t32 { + if i != t32 { logf("Ctz32(0x%x) expected %d but got %d\n", x32, i, t32) } x32 = -x32 t32 = T.Ctz32(x32) // ERROR "intrinsic substitution for Ctz32" - if uint32(i) != t32 { + if i != t32 { logf("Ctz32(0x%x) expected %d but got %d\n", x32, i, t32) } } @@ -83,10 +83,10 @@ func main() { logf("ctz64(0) != 64") } - for i := uint64(0); i <= 64; i++ { + for i := 0; i <= 64; i++ { for j := uint64(1); j <= 255; j += 2 { for k := uint64(1); k <= 65537; k += 128 { - x := (j * k) << i + x := (j * k) << uint(i) test(i, x) } } |