<div class="gmail_quote">On 10 August 2011 12:37, Pranav Bhandarkar <span dir="ltr"><<a href="mailto:pranavb@codeaurora.org">pranavb@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi Nick,<br>
<div class="im"><br>
>>Thanks for working on this! Firstly, I have a high-level question: why<br>
can't (X +nsw (C1 +nsw C2) always become (X +nsw C3)? Your patch spends a<br>
lot of time verifying that >>overflow couldn't occur, but you're given an<br>
assumption a priori that it can't because the nsw flag is present.<br>
<br>
</div>The reason is that 127 (C1) + 2 (C2) = 129 (C3) is not strictly true always.<br>
For instance, when the type is i8, then C3 is -127.</blockquote><div><br></div><div>127 + 2 = 129 remains true with i8 values, because i8 -127 = i8 129. They have the same bit pattern.</div><div><br></div><div>Can you pick values for X, C1 and C2 which still satisfy the +nsw relationship between each other that can't be converted into X +nsw C3 where C3 = C1+C2 (no nsw requirement)? 127 and 2 don't work as counter-examples because that triggers undefined behaviour (it violates the 'nsw' bit present on the add).</div>

<div><br></div><div>Nick</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> Then we cannot guarantee<br>
the nsw flag for the values of x that we could before this combination (e.g<br>
x=-10). Adding the 'nsw' flag in this would mean that the semantics are not<br>
preserved in the strictest sense of the term. Does this address your<br>
question?<br></blockquote><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">>>Sure it can overflow the unsigned wrap point (crossing between -1 to 0)<br>
but when merging two adds or two subs, does that ever matter?<br>
<br>
</div>I do not think unsigned wrap matters.<br>
<br>
Thanks for your comments, I will incorporate your suggestions on the patch.<br>
Do let me know your thoughts on the reasoning above.<br>
<br>
Pranav<br>
<br>
Qualcomm Innovation Center, Inc is a member of Code Aurora Forum.<br>
<br>
</blockquote></div><br>