https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82479
Bug ID: 82479 Summary: missing popcount builtin detection Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: kugan at gcc dot gnu.org Target Milestone: --- gcc does not have support to detect builtin pop count. As a results, gcc generates bad code for int PopCount (long b) { int c = 0; while (b) { b &= b - 1; c++; } return c; } clang seems to do that and generates (for aarch64): _Z8PopCounty: fmov d0, x0 cnt v0.8b, v0.8b uaddlv h0, v0.8b fmov w0, s0 ret