From b4ff4792989853b82150c1dc136ba024f6a09d0a Mon Sep 17 00:00:00 2001 From: Jorropo Date: Sun, 13 Nov 2022 20:41:58 +0100 Subject: [PATCH] cmd/compile: remove manually implemented popcount in _gen/main.go MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I7b4da26bace15c2b632c2dbfe56cc2799bbfdb02 Reviewed-on: https://go-review.googlesource.com/c/go/+/450058 Reviewed-by: Martin Möhrmann Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Run-TryBot: Keith Randall --- src/cmd/compile/internal/ssa/_gen/main.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/ssa/_gen/main.go b/src/cmd/compile/internal/ssa/_gen/main.go index 6a8ae0e45c..f37438796c 100644 --- a/src/cmd/compile/internal/ssa/_gen/main.go +++ b/src/cmd/compile/internal/ssa/_gen/main.go @@ -12,6 +12,7 @@ import ( "fmt" "go/format" "log" + "math/bits" "os" "path" "regexp" @@ -546,12 +547,7 @@ func (a arch) Name() string { // countRegs returns the number of set bits in the register mask. func countRegs(r regMask) int { - n := 0 - for r != 0 { - n += int(r & 1) - r >>= 1 - } - return n + return bits.OnesCount64(uint64(r)) } // for sorting a pair of integers by key -- 2.50.0