[LLVMdev] suspicious code in getPreStartForSignExtend (ScalarEvolution)

David Majnemer david.majnemer at gmail.com
Sat Jan 24 16:53:42 PST 2015


I think your analysis here is spot on.

On Sat, Jan 24, 2015 at 3:54 PM, Sanjoy Das <sanjoy at playingwithpointers.com>
wrote:

> In getPreStartForSignExtend (ScalarEvolution.cpp) we have
>
>   const SCEV *PreStart = SE->getAddExpr(DiffOps, SA->getNoWrapFlags());
>
> If I understand the code correctly, we cannot unconditionally transfer
> the no-wrap flags from SA to PreStart.  "SCEVAddExpr(X, Step, Y) does
> not signed-overflow" does not imply "SCEVAddExpr(X, Y) does not
> sign-overflow" [1].
>
> Note: I've assumed that a SCEVAddExpr(a_0, a_1, a_2 ... a_{n-1}) is
> said to sign-overflow if
>
>   sext(a_0 + a_1 + a_2 .. a_{n-1}) != sext(a_0) + sext(a_1) +
>   sext(a_2) .. sext(a_{n-1})
>
> Is this correct?  This is the only semantics I could think of that
> makes sense for a commutative operation.
>
> -- Sanjoy
>
> [1]: e.g. X = INT_SIGNED_MAX, Step = -1, Y = 1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150124/7a159022/attachment.html>


More information about the llvm-dev mailing list