[LLVMdev] Question about nsw and nuw flags

489 views
Skip to first unread message

Douglas do Couto Teixeira

unread,
Jan 12, 2011, 2:31:07 PM1/12/11
to LLVMdev
Hi everybody,

I saw that there are some instructions in the programs in which the flag nsw or nuw is placed. I wonder what rules does LLVM follows to put these flags in some instructions.


Best,

Douglas

Chris Lattner

unread,
Jan 12, 2011, 2:34:13 PM1/12/11
to Douglas do Couto Teixeira, LLVMdev

On Jan 12, 2011, at 11:31 AM, Douglas do Couto Teixeira wrote:

> Hi everybody,
>
> I saw that there are some instructions in the programs in which the flag nsw or nuw is placed. I wonder what rules does LLVM follows to put these flags in some instructions.

Hi Douglas,

The canonical reference for these types of questions is the IR description, here: http://llvm.org/docs/LangRef.html

-Chris
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Brian West

unread,
Jan 13, 2011, 10:51:26 AM1/13/11
to llv...@cs.uiuc.edu
Douglas do Couto Teixeira <douglasdocouto <at> gmail.com> writes:
> Hi everybody,I saw that there are some instructions in the programs in which

the flag nsw or nuw is placed. I wonder what rules does LLVM follows to put
these flags in some instructions.Best,Douglas

Language requirements appears to drive their placement. In C, "signed int"
overflow produces a trap value and undefined behavior. Thus, C "signed int"
operations do not wrap on overflow and get tagged with "nsw" in the LLVM IR.

Brian West

Reply all
Reply to author
Forward
0 new messages