[LLVMdev] Checked arithmetic
Chris Lattner
sabre at nondot.org
Sun Mar 30 10:44:31 PDT 2008
On Mar 26, 2008, at 1:55 PM, Duncan Sands wrote:
> Hi Chris,
>
>>> what's the point? We have this today with apint codegen (if you
>>> turn on
>>> LegalizeTypes). For example, this function
>>
>> The desired code is something like:
>>
>> foo:
>> addl %eax, %ecx
>> jo overflow_happened
>> use(%ecx)
>
> how's an intrinsic going to help with this? Also, is there any chance
> of codegen being capable one day of combining carry arithmetic coming
> from apint and the appropriate conditional branch into a "jo"?
The flow would be:
1) f.e. (or optimizer potentially) produces an intrinsic.
2) intrinsic is propagated by optimizer. If optimizer can prove the
thing doesn't overflow, it can replace with unchecked add, providing
"false" to the overflow flag.
3) SDISel gets the intrinsic, turns into an SDNode
4) Legalize does its thing, allowing a target to custom lower the node
(like x86 would above) or using generic support for it.
-Chris
More information about the llvm-dev
mailing list