<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 28, 2015 at 7:18 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jan 27, 2015, at 6:50 PM, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:<br>> Let's start with a concrete motivating example in C:<br>
> ```<br>
> int isSumGreater(int a, int b) {<br>
> return a + b > a;<br>
> }<br>
> ```<br>
><br>
> The C specification permits us to optimize the comparison in `isSumGreater` to `b > 0` because signed overflow results in undefined behavior. A reasonable translation of `isSumGreater` to LLVM IR could be:<br>
<br>
</span>Typo:<br>
to `b > 0`<br>
should be<br>
to `a + b > 0`<br>
IIUC.<br></blockquote><div><br></div><div>Let a = -10 and b = 1</div><div><br></div><div>a + b > a === -10 + 1 > -10 === -9 > -10 === true</div><div><br></div><div>b > 0 === 1 > 0 === true</div><div><br></div><div>All good.</div><div><br></div><div>Your version:</div><div><br></div><div>a + b > 0 === -10 + 1 > 0 === -9 > 0 === false</div><div><br></div><div>Small problem.</div><div><br></div></div></div></div>