Sanjiv
2011-May-05 05:48 UTC
[LLVMdev] Does lli know how to interpret arithmetic overflow intrinsics?
Do we have a .ll test cases for arithmetic overflow intrinsics that lli can execute and report any overflow occured? - sanjiv -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110505/3a62c745/attachment.html>
Sanjiv
2011-May-05 06:16 UTC
[LLVMdev] Does lli know how to interpret arithmetic overflow intrinsics?
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 <llvmdev at gmail.com> wrote:> Do we have a .ll test cases for arithmetic overflow intrinsics that lli can > execute and report any overflow occured? > > - sanjiv >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110505/ed57a4b9/attachment.html>
Duncan Sands
2011-May-05 09:12 UTC
[LLVMdev] Does lli know how to interpret arithmetic overflow intrinsics?
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 <llvmdev at gmail.com > <mailto:llvmdev at gmail.com>> 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 > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Apparently Analagous Threads
- [LLVMdev] Does lli know how to interpret arithmetic overflow intrinsics?
- X86ISelLowering: Promote 'add nsw' to a wider type
- X86ISelLowering: Promote 'add nsw' to a wider type
- IR canonicalization: select or bool math?
- [LLVMdev] Does LLVM optimize rudimentary i16 -> i32 conversions