Does lli know how to interpret arithmetic overflow intrinsics?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Does lli know how to interpret arithmetic overflow intrinsics?

Sanjiv Gupta
Do we have a .ll test cases for arithmetic overflow intrinsics that lli can execute and report any overflow occured?

- sanjiv

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Does lli know how to interpret arithmetic overflow intrinsics?

Sanjiv Gupta
I understand that overflow behaviours can be different on different hardware. But can we write .ll implementation of these overflow intrinsics, e.g. assuming 0..255 as value range for unsigned i8 ?


- sanjiv

On Thu, May 5, 2011 at 11:18 AM, Sanjiv <[hidden email]> wrote:
Do we have a .ll test cases for arithmetic overflow intrinsics that lli can execute and report any overflow occured?

- sanjiv


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Does lli know how to interpret arithmetic overflow intrinsics?

Duncan Sands
Hi Sanjiv,

> I understand that overflow behaviours can be different on different hardware.
> But can we write .ll implementation of these overflow intrinsics, e.g. assuming
> 0..255 as value range for unsigned i8 ?

I'm not sure I understand what you are asking, but it is perfectly possible to
write generic versions of overflow intrinsics.  For example, if %x and %y have
type iN, and you are interested in signed/unsigned overflow when adding them,
then: (1) sext/zext %x and %y to variables %X and %Y of type i(N+1) (one more
bit); (2) compute %Z = %X + %Y; (3) Check that %Z sexts/zexts its truncation to
type iN, i.e. that "%Z == sext (trunc %Z to iN) to i(N+1)" (likewise for zext).
If not, the computation overflowed.  Likewise for subtraction.  For
multiplication you need to double the number of bits, but otherwise it is the
same.

Ciao, Duncan.

>
>
> - sanjiv
>
> On Thu, May 5, 2011 at 11:18 AM, Sanjiv <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Do we have a .ll test cases for arithmetic overflow intrinsics that lli can
>     execute and report any overflow occured?
>
>     - sanjiv
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev