develooper Front page | perl.perl5.porters | Postings from October 2017

Using __builtin_add_overflow and friends for overflow checking

Thread Next
From:
Lukas Mai
Date:
October 23, 2017 21:34
Subject:
Using __builtin_add_overflow and friends for overflow checking
Message ID:
38feab13-03d8-352c-ed24-575a2fe89b96@gmail.com
I think it would be a good idea to use compiler intrinsics for overflow 
checks where available.

I've pushed a branch that implements this at mauke/overflow:
https://perl5.git.perl.org/perl.git/shortlog/refs/heads/mauke/overflow

Dave: I've CC'd you directly because you last worked on this code 
(commit 230ee21f3e366901ce5769d324124c522df7ce8a, "faster add, subtract, 
multiply").

My changes affect pp_add, pp_subtract, and pp_multiply. I think the new 
code is nicer because it's easier to understand than all the low-level 
bit fiddling, and it passes all tests on my machine. However, I haven't 
done any benchmarks to see how it affects performance (if at all).

Things I need help with:

- code review
- testing on different platforms / architectures
- benchmarks (compared to a17768d7c7b82c136fbeacd85db3451973a8007a)

-- 
Lukas Mai <plokinom@gmail.com>

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About