.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / container / intsets / popcnt_generic.go
1 // Copyright 2015 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.
4
5 //go:build (!amd64 || appengine) && !gccgo
6 // +build !amd64 appengine
7 // +build !gccgo
8
9 package intsets
10
11 import "runtime"
12
13 // We compared three algorithms---Hacker's Delight, table lookup,
14 // and AMD64's SSE4.1 hardware POPCNT---on a 2.67GHz Xeon X5550.
15 //
16 // % GOARCH=amd64 go test -run=NONE -bench=Popcount
17 // POPCNT               5.12 ns/op
18 // Table                8.53 ns/op
19 // HackersDelight       9.96 ns/op
20 //
21 // % GOARCH=386 go test -run=NONE -bench=Popcount
22 // Table               10.4  ns/op
23 // HackersDelight       5.23 ns/op
24 //
25 // (AMD64's ABM1 hardware supports ntz and nlz too,
26 // but they aren't critical.)
27
28 // popcount returns the population count (number of set bits) of x.
29 func popcount(x word) int {
30         if runtime.GOARCH == "386" {
31                 return popcountHD(uint32(x))
32         }
33         return popcountTable(x)
34 }