title: Can a modern C compiler optimize a combination of bit accesses?
body: <p>I would like <code>var</code> to be unequal <code>FALSE</code> in case one of the bits 1, 3, 5, 7, 9, 11, 13 or 15 of <code>input</code> is set.</p>
  
  <p>One solution which seem to be fairly common is this:</p>
  
  <pre><code>int var = 1 &amp; (input &gt;&gt;  1) ||
            1 &amp; (input &gt;&gt;  3) ||
            1 &amp; (input &gt;&gt;  5) ||
            1 &amp; (input &gt;&gt;  7) ||
            1 &amp; (input &gt;&gt;  9) ||
            1 &amp; (input &gt;&gt; 11) ||
            1 &amp; (input &gt;&gt; 13) ||
            1 &amp; (input &gt;&gt; 15);
  </code></pre>
  
  <p>However, I'm afraid that that would lead the compiler to generate unnecessarily long code.</p>
  
  <p>Following code would also yield the desired result. Would it be more efficient?</p>
  
  <pre><code>int var = input &amp; 0b1010101010101010;
  </code></pre>
  
  <p>Thanks!</p>