You might also look at isPowerOfTwo function, and add a few test-cases covered by it. Like this one:<div><pre class="" style="font-family:Fixed,monospace;font-size:13px;border:1px solid rgb(204,204,204);background-color:rgb(245,245,245);margin:4px 8px 4px 2px;padding:4px 6px;color:rgb(0,0,0)">
<span class="" style="color:rgb(128,0,0)">// X & (-X) is always a power of two or zero.</span></pre></div><div><br></div><div>Otherwise LGTM.</div><div>- Kuba</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Dec 11, 2012 at 12:15 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra">Implemented, patch attached.<div class="im"><br><br><div class="gmail_quote">On Mon, Dec 10, 2012 at 2:08 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Instead of the shift matching "isPowerOfTwo" from ValueTracking.h could be used to make the transformation more powerful. It handles the "1 << X" case and many others too.</blockquote>

</div><br></div></div>
</blockquote></div><br></div>