I believe you can also do x & -x == x. I'm not sure if that will
be actually faster or slower. You could maybe cut the
instructions down a little with an asm{} block. The compiler
might not figure out that it can re-use a register for x on the
left and x on the right there. You might use popcnt in a
version() block too, so you can use the instruction when you've
got it.
- Re: 0 is not a power of 2 Andrei Alexandrescu via Digitalmars-d
- Re: 0 is not a power of 2 Johan Engelen via Digitalmars-d
- Re: 0 is not a power of 2 Atila Neves via Digitalmars-d
- Re: 0 is not a power of 2 Martin Nowak via Digitalmars-d
- Re: 0 is not a power of 2 Andrei Alexandrescu via Digitalmars-d
- Re: 0 is not a power of 2 John Colvin via Digitalmars-d
- Re: 0 is not a power of 2 safety0ff via Digitalmars-d
- Re: 0 is not a power of 2 John Colvin via Digitalmars-d
- Re: 0 is not a power of 2 Almighty Bob via Digitalmars-d
- Re: 0 is not a power of 2 Almighty Bob via Digitalmars-d
- Re: 0 is not a power of 2 w0rp via Digitalmars-d
- Re: 0 is not a power of 2 Almighty Bob via Digitalmars-d
- Re: 0 is not a power of 2 w0rp via Digitalmars-d
- Re: 0 is not a power of 2 Nicholas Wilson via Digitalmars-d
- Re: 0 is not a power of 2 Steven Schveighoffer via Digitalmars-d
- Re: 0 is not a power of 2 Steven Schveighoffer via Digitalmars-d
- Re: 0 is not a power of 2 Steven Schveighoffer via Digitalmars-d
- Re: 0 is not a power of 2 Matthias Bentrup via Digitalmars-d
- Re: 0 is not a power of 2 Marco Leise via Digitalmars-d
- Re: 0 is not a power of 2 Zoadian via Digitalmars-d
- Re: 0 is not a power of 2 Andrei Alexandrescu via Digitalmars-d
