[llvm-dev] Question regarding nuw and nsw

Finkel, Hal J. via llvm-dev llvm-dev at lists.llvm.org
Sun Dec 2 08:09:36 PST 2018


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
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

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



More information about the llvm-dev mailing list