title: Is there a better way to any detect bits that are set in a 16-byte array of flags?
body: <pre><code>    ALIGNTO(16) uint8_t noise_frame_flags[16] = { 0 };
  
      // Code detects noise and sets noise_frame_flags omitted
  
      __m128i xmm0            = _mm_load_si128((__m128i*)noise_frame_flags);
      bool    isNoiseToCancel = _mm_extract_epi64(xmm0, 0) | _mm_extract_epi64(xmm0, 1);
  
      if (isNoiseToCancel)
          cancelNoises(audiobuffer, nAudioChannels, audio_samples, noise_frame_flags);
  </code></pre>
  <p>This is a code snippet from my AV Capture tool on Linux. noise_frame_flags here is an array of flags for 16-channel audio. For each channel, the corresponding byte can be either 0 or 1. 1 is indicating that the channel has some noise to cancel. For example, if noise_frame_flags[0] == 1, that means first channel noise flag is set (by the omitted code).</p>
  <p>Even if a single &quot;flag&quot; is set then I need to call <code>cancelNoises</code>. And this code seems to work fine in that matter. As you see I used <code>_mm_load_si128</code> to load a whole array of flags that is correctly aligned and then two <code>_mm_extract_epi64</code> to extract &quot;flags&quot;. My question is there a better way to do this (using pop count maybe)?</p>
  <p>Note: <code>ALIGNTO(16)</code> is a macro expands to correct GCC equivalent but nicer looking.</p>