[llvm-commits] [llvm] r59756 - /llvm/trunk/include/llvm/Intrinsics.td

Bill Wendling isanbard at gmail.com
Fri Nov 21 01:20:21 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.
>
There are multiple ways to do this already - you named one of them.  
It's a convenience tool for people who want to act on an overflow. The  
idea will be that a platform can have its own lowering algorithm that  
will easily recognize an ADDO and lower it into something simple. For  
instance:

	addl %eax, %ecx
	jo overflow
	...

As Chris noted, a "flag" isn't the same as the bool value in the case.  
The value could be stored or whatever . . .

-bw




More information about the llvm-commits mailing list