`,
pos: []string{"\tROLW\t\\$8,"},
},
- {
- fn: `
- func pop1(x uint64) int {
- return bits.OnesCount64(x)
- }`,
- pos: []string{"\tPOPCNTQ\t", "support_popcnt"},
- },
- {
- fn: `
- func pop2(x uint32) int {
- return bits.OnesCount32(x)
- }`,
- pos: []string{"\tPOPCNTL\t", "support_popcnt"},
- },
- {
- fn: `
- func pop3(x uint16) int {
- return bits.OnesCount16(x)
- }`,
- pos: []string{"\tPOPCNTL\t", "support_popcnt"},
- },
- {
- fn: `
- func pop4(x uint) int {
- return bits.OnesCount(x)
- }`,
- pos: []string{"\tPOPCNTQ\t", "support_popcnt"},
- },
// multiplication merging tests
{
fn: `
`,
pos: []string{"TBZ"},
},
- {
- fn: `
- func $(x uint64) int {
- return bits.OnesCount64(x)
- }
- `,
- pos: []string{"\tVCNT\t", "\tVUADDLV\t"},
- },
- {
- fn: `
- func $(x uint32) int {
- return bits.OnesCount32(x)
- }
- `,
- pos: []string{"\tVCNT\t", "\tVUADDLV\t"},
- },
- {
- fn: `
- func $(x uint16) int {
- return bits.OnesCount16(x)
- }
- `,
- pos: []string{"\tVCNT\t", "\tVUADDLV\t"},
- },
// Load-combining tests.
{
fn: `
return bits.Len8(n)
}
+// -------------------- //
+// bits.OnesCount //
+// -------------------- //
+
+func OnesCount(n uint) int {
+ //amd64:"POPCNTQ",".*support_popcnt"
+ //arm64:"VCNT","VUADDLV"
+ return bits.OnesCount(n)
+}
+
+func OnesCount64(n uint64) int {
+ //amd64:"POPCNTQ",".*support_popcnt"
+ //arm64:"VCNT","VUADDLV"
+ return bits.OnesCount64(n)
+}
+
+func OnesCount32(n uint32) int {
+ //amd64:"POPCNTL",".*support_popcnt"
+ //arm64:"VCNT","VUADDLV"
+ return bits.OnesCount32(n)
+}
+
+func OnesCount16(n uint16) int {
+ //amd64:"POPCNTL",".*support_popcnt"
+ //arm64:"VCNT","VUADDLV"
+ return bits.OnesCount16(n)
+}
+
// ------------------------ //
// bits.TrailingZeros //
// ------------------------ //