<div dir="ltr">Committed in r187445.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 29, 2013 at 4:20 AM, Jay Foad <span dir="ltr"><<a href="mailto:jay.foad@gmail.com" target="_blank">jay.foad@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="im">On 13 July 2013 23:21, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:<br>
> On Sat, Jul 13, 2013 at 12:03 PM, Nick Lewycky <<a href="mailto:nicholas@mxc.ca">nicholas@mxc.ca</a>> wrote:<br>
>><br>
>> David Majnemer wrote:<br>
>>><br>
>>> Attached is a patch to strengthen isKnownToBeAPowerOfTwo's analysis on<br>
>>> add instructions.<br>
>>><br>
>>> It calls into ComputeMaskedBits to figure out which bits are set on both<br>
>>> add operands and determines if the value is a power-of-two-or-zero or<br>
>>> not.<br>
<br>
</div>The logic looks OK to me.<br>
<br>
I think you could relax this condition this a tiny bit:<br>
<br>
+ APInt ComplementLHSZeroBits = ~LHSZeroBits;<br>
+ if (ComplementLHSZeroBits == ~RHSZeroBits &&<br>
+ ComplementLHSZeroBits.isPowerOf2()) {<br>
<br>
to:<br>
<br>
if ((~(LHSZeroBits & RHSZeroBits)).isPowerOf2())<br>
<br>
but that's mostly a matter of taste. (It would be nice if there was an<br>
APInt::isPowerOf2OrZero.)<br>
<span class="HOEnZb"><font color="#888888"><br>
Jay.<br>
</font></span></blockquote></div><br></div>