[llvm-commits] [PATCH] -fno-strict-overflow/-fwrapv: allow pointer arithmetic to be defined as wrapping instead of undefined on overflow

Chris Lattner clattner at apple.com
Mon Feb 2 12:33:40 PST 2009


On Feb 1, 2009, at 12:32 PM, Török Edwin wrote:

> Hi,
>
> gcc provides -fwrapv and -fno-strict-overflow that allows pointer +
> unsigned to be treated as possibly wrapping, instead of undefined ->
> can't happen (the default with -fstrict-overflow, -O2, -O3 or -Os).

I think the right way to handle this is to add a "overflow  
characteristic" field to the integer operations.  Each integer  
operation could be "2's complement on overflow" "undefined on  
overflow" "trapping on overflow" or "saturating on overflow".  I think  
it makes sense to capture this directly in the IR on a per-operation  
basis instead of trying to disable optimizations based on a global flag.

If you're interested in tackling this, the first place to start would  
be to split up add into add/fadd and any other operations that work on  
both int/fp that do arithmetic.

-Chris



More information about the llvm-commits mailing list