Re: Is this a missed optimization for popcount implementation?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/7/20 11:03 PM, Jim Wilson wrote:
On Sat, Dec 5, 2020 at 11:48 AM andre maute <andre.maute@xxxxxx> wrote:

I'm wondering why is there a special optimization
for the "trick" code, and why isn't there one for the "naive" code?

Because a bug report was submitted for the example that you are calling
trick code.
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82479
and a patch was written to fix that.  The bug report says this code is
present in spec2017, which is why they wanted it optimized., and why a
volunteer was willing to write the complicated code necessary to perform
this optimization.

Anyways, yes, I'd call this a missing optimization, though likely of
limited interest, unless you can point at a benchmark or important program
that really needs it.  You are welcome to submit a bug report, and maybe
point back at bug 82479.

But in general, you are better off calling __builtin_popcount.

Jim

Thank you Jim for the pointer.
I was triggered watching a youtube video with Matt Godbolt
	https://www.youtube.com/watch?v=w0sz5WbS5AM
about how amazing compilers are.

Wouldn't it be nice if you could tell your colleagues
that you don't have to remember those bit hacking "tricks" anymore.

This might become relevant, if you still have to additionally support
old pre C++11 multiplatform sources.

With your pointer and
https://graphics.stanford.edu/~seander/bithacks.html
this could be a nice beginner project.

Regards Andre




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux