[llvm-dev] Question regarding nuw and nsw

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Question regarding nuw and nsw

Alberto Barbaro via llvm-dev
Hello,

in the language reference some instructions have the following note :
´nuw and nsw stand for “No Unsigned Wrap” and “No Signed Wrap”,
respectively. If the nuw and/or nsw keywords are present, the result
value of the add is a poison value if unsigned and/or signed overflow,
respectively, occurs.´

I understand how integer overflow works generally but i am not sure
whats the difference between Unsigned and Signed Wrap. Could someone
explain this ?

Thank you


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Question regarding nuw and nsw

Alberto Barbaro via llvm-dev
On 12/2/18 9:30 AM, via llvm-dev wrote:

> Hello,
>
> in the language reference some instructions have the following note :
> ´nuw and nsw stand for “No Unsigned Wrap” and “No Signed Wrap”,
> respectively. If the nuw and/or nsw keywords are present, the result
> value of the add is a poison value if unsigned and/or signed overflow,
> respectively, occurs.´
>
> I understand how integer overflow works generally but i am not sure
> whats the difference between Unsigned and Signed Wrap. Could someone
> explain this ?

Unsigned integer overflow occurs when the result of the operation,
interpreted over the integers, would fall outside the representable
range of the type when it represents an unsigned integer (e.g., [0,
UINT_MAX]).

Signed integer overflow occurs when the result of the operation,
interpreted over the integers, would fall outside the representable
range of the type when it represents an signed integer (e.g., [INT_MIN,
INT_MAX]).

 -Hal

>
> Thank you
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev