package main
import "math/bits"
func f(x uint64) int {
r := 0
for range 5 {
r += bits.OnesCount64(x)
}
return r
}
GOAMD64=v1 go build -gcflags=-S test.go
In the assembly output, the POPCNTQ instruction has been lifted to before the start of the loop. We can't do that, unless we also lift the x86HasPOPCNT test that wraps POPCNTQ instructions in v1 mode.
This is a consequence of https://go-review.googlesource.com/c/go/+/697235 . Maybe we should revert it. (It was also responsible for #78892. I'm not sure what else might be lurking.)
In the assembly output, the
POPCNTQinstruction has been lifted to before the start of the loop. We can't do that, unless we also lift thex86HasPOPCNTtest that wrapsPOPCNTQinstructions in v1 mode.This is a consequence of https://go-review.googlesource.com/c/go/+/697235 . Maybe we should revert it. (It was also responsible for #78892. I'm not sure what else might be lurking.)