popcnt usage

Todd VanderVeen tdvanderveen at gmail.com
Mon Dec 23 12:18:49 PST 2013


I retract my second concern. I misread a purity error for a CTFE 
error. This does work as expected.

import core.cpuid: hasPopcnt;

/// Returns the number of bits which are set.
uint popcnt(ulong bits) nothrow
{
    version(X86_64) {
       if(hasPopcnt()) {
          asm {
             ....
          }
       }
       else {
          ...
       }
    }
}

Is there any reason that core.cpuid.hasPopcnt() cannot be made 
pure? Hopefully, calling it won't change my processor :)



More information about the Digitalmars-d mailing list