[llvm-commits] [llvm] r59756 - /llvm/trunk/include/llvm/Intrinsics.td
Chris Lattner
clattner at apple.com
Fri Nov 21 08:52:49 PST 2008
On Nov 21, 2008, at 12:42 AM, Duncan Sands wrote:
> Hi Bill,
>
>> Introduce two new "add" intrinsics. These return the sum plus a bit
>> indicating
>> that an overflow/carry occured. These are converted into ISD::
>> [SU]ADDO nodes,
>> which are lowered in a target-independent way into something sane.
>> Eventually,
>> each target can implement their own method of checking the overflow/
>> carry flags.
>
> are these really needed? Suppose you want to do 32 bit addition of
> x and y.
> Zero extend x and y to i33. Do the addition in i33 and check the
> top bit.
> If it is non-zero then there was a carry/overflow. In codegen this
> gets turned
> into an ADDC node (sounds a lot like your ADDO node...), and on x86
> at least
> turns by magic into a check on the carry flag. So at first glance
> it seems that
> everything is already supported.
This doesn't work for all operations. To know if a signed add
overflowed, you have to xor together the new sign bit and the carry
out. I doubt the right code would be generated for this.
Lets not even get into multiply etc ;-)
-Chris
More information about the llvm-commits
mailing list