[LLVMdev] [PATH] Add sub.ovf/mul.ovf intrinsics

Eli Friedman eli.friedman at gmail.com
Tue Dec 9 09:53:16 PST 2008


On Tue, Dec 9, 2008 at 6:11 AM, Zoltan Varga <vargaz at gmail.com> wrote:
>> It would be better to implement a target-independent check for
>> overflow for the "Legal" case (like how SADDO does). Hacker's > Delight
>> has some hints on how to do this. It's not easy for the signed case,
>> but is do-able.
>
> It can be lowered to a division + a branch, so it would be
> inefficient, plus it would
> be a lot of work to implement it correctly (for me at least).

If you can get the relevant high product (UMUL_LOHI and friends), it's
a relatively straightforward comparison.  Otherwise, yes, the general
case is quite tricky; inserting a division here is non-trivial.

There's also the special-case of multiplication by a constant: here,
the computation can be done with a single straightforward comparison.

-Eli



More information about the llvm-dev mailing list