[cfe-dev] [RFC] Introduce overflow builtins

Xi Wang xi.wang at gmail.com
Wed Mar 28 11:56:23 PDT 2012


On Mar 28, 2012, at 9:26 AM, Joerg Sonnenberger wrote:

> On Tue, Mar 27, 2012 at 11:13:11PM -0400, Xi Wang wrote:
>> As Eli said, there's no such thing as llvm.div.with.overflow ---
> 
> Just because it hasn't been done...
> 
>> I am not sure if there's any performance gain from compiler support.
> 
> At least for x86, the same argument applies here as for the other cases:
> you can detect it with a trivial flag compare. An additional branch, if
> you also want to handle divisor of 0.

Which case did you mean?  The same argument holds for signed division,
but probably not for unsigned division and shifts.

If the LLVM IR adds llvm.sdiv.with.overflow, we can definitely add
a corresponding builtin.  I feel like it is better to leave the
rest cases to an overflow library, and have the compiler focus on
providing minimum necessary support for overflow detection (rather
than implementing a complete library itself).

- xi




More information about the cfe-dev mailing list