title: Faster way to test if xmm/ymm register is zero?
body: <p>It's fortunate that <code>PTEST</code> <del>does not affect the carry flag, but only sets the (rather awkward) ZF.</del> also affects both CF and ZF. </p>
  
  <p>I've come up with the following sequence to test a large number of values, but I'm unhappy with the poor running time.</p>
  
  <pre><code>              Latency / rThoughput
  setup:
    xor eax,eax       ; na
    vpxor xmm0,xmm0   ; na       ;mask to use for the nand operation of ptest
  work:
    vptest xmm4,xmm0  ; 3   1    ;is xmm4 alive?
    adc eax,eax       ; 1   1    ;move first bit into eax
    vptest xmm5,xmm0  ; 3   1    ;is N alive?
    adc eax,eax       ; 1   1    ;move consecutive bits into eax 
  </code></pre>
  
  <p>I want to have a bitmap of all the non-zero registers in <code>eax</code> (obviously I can combine multiple bitmaps in multiple registers).</p>
  
  <p>So every test has a latency of 3+1 = 4 cycles.<br>
  Some of this can run in parallel by alternating between <code>eax</code>,<code>ecx</code> etc.<br>
  But it's still quite slow.<br>
  Is there a faster way of doing this?  </p>
  
  <p>I need to test 8 xmm/ymm registers in a row. 1 bit per register in a one byte bitmap.  </p>