<div dir="ltr">I think your analysis here is spot on.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 24, 2015 at 3:54 PM, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In getPreStartForSignExtend (ScalarEvolution.cpp) we have<br>
<br>
  const SCEV *PreStart = SE->getAddExpr(DiffOps, SA->getNoWrapFlags());<br>
<br>
If I understand the code correctly, we cannot unconditionally transfer<br>
the no-wrap flags from SA to PreStart.  "SCEVAddExpr(X, Step, Y) does<br>
not signed-overflow" does not imply "SCEVAddExpr(X, Y) does not<br>
sign-overflow" [1].<br>
<br>
Note: I've assumed that a SCEVAddExpr(a_0, a_1, a_2 ... a_{n-1}) is<br>
said to sign-overflow if<br>
<br>
  sext(a_0 + a_1 + a_2 .. a_{n-1}) != sext(a_0) + sext(a_1) +<br>
  sext(a_2) .. sext(a_{n-1})<br>
<br>
Is this correct?  This is the only semantics I could think of that<br>
makes sense for a commutative operation.<br>
<br>
-- Sanjoy<br>
<br>
[1]: e.g. X = INT_SIGNED_MAX, Step = -1, Y = 1<br>
</blockquote></div><br></div>