Clear upper bytes of __m128i <p>How do I clear the <code>16 - i</code> upper bytes of a <code>__m128i</code>?</p> <p>I've tried this; it works, but I'm wondering if there is a better (shorter, faster) way:</p> <pre><code>int i = ... // 0 &lt; i &lt; 16 __m128i x = ... __m128i mask = _mm_set_epi8( 0, (i &gt; 14) ? -1 : 0, (i &gt; 13) ? -1 : 0, (i &gt; 12) ? -1 : 0, (i &gt; 11) ? -1 : 0, (i &gt; 10) ? -1 : 0, (i &gt; 9) ? -1 : 0, (i &gt; 8) ? -1 : 0, (i &gt; 7) ? -1 : 0, (i &gt; 6) ? -1 : 0, (i &gt; 5) ? -1 : 0, (i &gt; 4) ? -1 : 0, (i &gt; 3) ? -1 : 0, (i &gt; 2) ? -1 : 0, (i &gt; 1) ? -1 : 0, -1); x = _mm_and_si128(x, mask); </code></pre>