Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The __popcnt*() builtins are for AMD's Advanced Bit Manipulation (ABM) instructions. See <a href="http://blogs.amd.com/developer/2007/09/26/barcelona-processor-feature-advanced-bit-manipulation-abm/">http://blogs.amd.com/developer/2007/09/26/barcelona-processor-feature-advanced-bit-manipulation-abm/</a></p> <p>The _mm_popcnt_u*() intrinsics are for Intel's implementation, which aren't part of SSE4.2 per se, but were implemented around the same time. See <a href="http://en.wikipedia.org/wiki/SSE4#POPCNT_and_LZCNT">http://en.wikipedia.org/wiki/SSE4#POPCNT_and_LZCNT</a></p> <p>According to <a href="http://chessprogramming.wikispaces.com/Population+Count">http://chessprogramming.wikispaces.com/Population+Count</a> , both implementations are binary compatible, in spite of their different intrinsic names.</p> <p>Intel's <a href="http://download.intel.com/products/processor/manual/325462.pdf">architecture manual</a> states that:</p> <blockquote> <p>Before an application attempts to use the POPCNT instruction, it must check that the processor supports SSE4.2 (if CPUID.01H:ECX.SSE4_2[bit 20] = 1) and POPCNT (if CPUID.01H:ECX.POPCNT[bit 23] = 1).</p> </blockquote> <p>AMD's <a href="http://support.amd.com/us/Processor_TechDocs/24594_APM_v3.pdf">AMD64 Architecture Programmer's Manual Volume 3: General Purpose and System Instructions</a> says</p> <blockquote> <p>Support for the POPCNT instruction is indicated by ECX bit 23 (POPCNT) as returned by CPUID function 0000_0001h. Software MUST check the CPUID bit once per program or library initialization before using the POPCNT instruction, or inconsistent behavior may result.</p> </blockquote> <p>I can't see any reason why popcnt would require the presence of SSE4.2, so I think that checking bit 23 of ECX is sufficient to determine popcnt's presence.</p> <p>AMD's Barcelona, the first AMD CPU to have popcnt, didn't fully implement SSE4, so it's possible that Intel's architecture manual suggests a method for determine presence which will work on Intel CPUs and fail on even qualified AMD CPUs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload