1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 T "runtime/internal/sys"
12 var A = []uint64{0x0102030405060708, 0x1122334455667788}
13 var B = []uint64{0x0807060504030201, 0x8877665544332211}
17 func logf(f string, args ...interface{}) {
19 fmt.Printf(f, args...)
20 if errors > 100 { // 100 is enough spewage
21 panic("100 errors is plenty is enough")
25 func test(i int, x uint64) {
26 t := T.TrailingZeros64(x) // ERROR "intrinsic substitution for TrailingZeros64"
28 logf("TrailingZeros64(0x%x) expected %d but got %d\n", x, i, t)
31 t = T.TrailingZeros64(x) // ERROR "intrinsic substitution for TrailingZeros64"
33 logf("TrailingZeros64(0x%x) expected %d but got %d\n", x, i, t)
38 t32 := T.TrailingZeros32(x32) // ERROR "intrinsic substitution for TrailingZeros32"
40 logf("TrailingZeros32(0x%x) expected %d but got %d\n", x32, i, t32)
43 t32 = T.TrailingZeros32(x32) // ERROR "intrinsic substitution for TrailingZeros32"
45 logf("TrailingZeros32(0x%x) expected %d but got %d\n", x32, i, t32)
51 // Test Bswap first because the other test relies on it
52 // working correctly (to implement bit reversal).
56 X := T.Bswap64(x) // ERROR "intrinsic substitution for Bswap64"
57 Y := T.Bswap64(y) // ERROR "intrinsic substitution for Bswap64"
59 logf("Bswap64(0x%08x) expected 0x%08x but got 0x%08x\n", x, y, X)
62 logf("Bswap64(0x%08x) expected 0x%08x but got 0x%08x\n", y, x, Y)
66 y32 := uint32(Y >> 32)
68 X32 := T.Bswap32(x32) // ERROR "intrinsic substitution for Bswap32"
69 Y32 := T.Bswap32(y32) // ERROR "intrinsic substitution for Bswap32"
71 logf("Bswap32(0x%08x) expected 0x%08x but got 0x%08x\n", x32, y32, X32)
74 logf("Bswap32(0x%08x) expected 0x%08x but got 0x%08x\n", y32, x32, Y32)
78 // Zero is a special case, be sure it is done right.
79 if T.TrailingZeros32(0) != 32 { // ERROR "intrinsic substitution for TrailingZeros32"
80 logf("TrailingZeros32(0) != 32")
82 if T.TrailingZeros64(0) != 64 { // ERROR "intrinsic substitution for TrailingZeros64"
83 logf("TrailingZeros64(0) != 64")
86 for i := 0; i <= 64; i++ {
87 for j := uint64(1); j <= 255; j += 2 {
88 for k := uint64(1); k <= 65537; k += 128 {
89 x := (j * k) << uint(i)