0 is not a power of 2

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon May 18 22:53:59 PDT 2015


On 5/18/15 10:40 PM, Brian Schott wrote:
> On Tuesday, 19 May 2015 at 05:16:48 UTC, Andrei Alexandrescu wrote:
>> Any ideas for faster code?
>
> Unless I'm mistaken, any uint that's a power of 2 will only have a
> single set bit, so why not use the "popcnt" instruction?
> http://dlang.org/phobos/core_bitop.html#.popcnt

There are complaints it's not that fast, e.g. 
http://danluu.com/assembly-intrinsics/. -- Andrei



More information about the Digitalmars-d mailing list