<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 3, 2014 at 2:25 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">WillNotOverflowSignedAdd should return the correct result for any LHS<br>
and RHS. I agree that you found a case where it does not.  I think the<br>
issues is that<br>
<div class=""><br>
 if (ComputeNumSignBits(LHS) > 1 && ComputeNumSignBits(RHS) > 1)<br>
    return true;<br></div></blockquote><div><br></div><div>Yes, the culprit seems to above code this for your patch. i just checked it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">
<br>
</div>Also needs to check that the sign bit is the same, not just hat LHS<br>
and RHS have more then one sign bit.  Checking if that is the root<br>
issue.<br>
<div class=""><div class="h5"><br>
<br></div></div></blockquote><div class="h5"><br>
</div></div>I am not sure if this is only applicable to operands having same sign bit.<br><br></div><div class="gmail_extra">As per comment above this code - <i>Add has the property that adding any two 2's complement numbers can only<br>
   have one carry bit which can change a sign.  As such, if LHS and RHS each<br>   have at least two sign bits, we know that the addition of the two values<br>   will sign extend fine.</i><br></div><div class="gmail_extra">
<br></div><div class="gmail_extra">Because, if we have one of the operand as 111xxxxx......and other operand as 000xxxx....,<br></div><div class="gmail_extra">the code is perfectly applicable in such case even though their sign bit is different. I am not sure if we should discard this case. <br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">Awaiting for your analysis :)<br><br></div><div class="gmail_extra">-- <br>With regards,<br>Suyog Sarda<br>
</div></div>