title: What is the fastest way for bit operations to calculate a parity?
body: <p>My solution (for every bit of the input block, there is such a line):</p>
  <pre><code>*parity ^= (((x[0] &gt;&gt; 30) &amp; 0x00000001) * 0xc3e0d69f);
  </code></pre>
  <p>All types are <em>uint32</em>. This line takes the second bit of the input x, shifts it to the <a href="https://en.wikipedia.org/wiki/Bit_numbering#Bit_significance_and_indexing" rel="nofollow noreferrer">LSB</a> and sets all other bits to zero. Then, the 32-bit parity is XORed with the corresponding parity set for this bit.</p>
  <p>I found that this multiplication solution is the fastest way to do this conditional XOR. Is there a faster way?</p>