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

Re: Using __builtin_add_overflow and friends for overflow checking

Thread Previous | Thread Next
From:
James E Keenan
Date:
October 24, 2017 12:35
Subject:
Re: Using __builtin_add_overflow and friends for overflow checking
Message ID:
20171024123511.27868.qmail@lists-nntp.develooper.com
On 10/24/2017 08:22 AM, James E Keenan wrote:
> On 10/23/2017 05:34 PM, Lukas Mai wrote:
>> 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)
>>
> 
> 1. You might want to rename your branch 'smoke-me/mauke/overflow'. 
> Lacking the 'smoke-me/', it won't appear in the drop-down box at 
> http://perl.develop-help.com/?b=blead (even though test-smoke.org will 
> show it).
> 
> 2. Please see these smoke-test reports on FreeBSD-10.3 and FreeBSD-11.0, 
> respectively:
> 
> 10.3: http://perl5.test-smoke.org/report/58864
> 
> I think the one test failure is spurious:  a side effect of resource 
> constraints on this VM on my laptop.
> 
> 11.0: http://perl5.test-smoke.org/report/58869
> 
> Significant failures in t/op/numconvert.t.  Attaching output.
> 
> Thank you very much.
> Jim Keenan
> 

And also in my regular Linux build:

# '-9223372036854775808' ne '-9.22337203685478e+18', 
-1.84467440737096e+19   => I - N P vs I - P
# '-9223372036854775808' ne '-9.22337203685478e+18', 
-1.84467440737096e+19   => I - N P vs I - P
# '-9223372036854775808' ne '-9.22337203685478e+18', 
-9.22337203685478e+18   => I - N P vs I - P
# '-9223372036854775808' ne '-9.22337203685478e+18', 
-9223372036854775808    => I - N P vs I - P
# '-9223372036854775808' ne '-9.22337203685478e+18', 
9223372036854775808 => I - N P vs I - P
# Failed test 104 - at op/numconvert.t line 250
# '-9223372036854775808' ne '-9.22337203685478e+18', 
-9223372036854775808    => N - N P vs N - P
# Failed test 108 - at op/numconvert.t line 250
# '-9223372036854775808' ne '-9.22337203685478e+18', 
-9223372036854775808    => P - N P vs P - P
# Failed test 112 - at op/numconvert.t line 250
op/numconvert.t ..
# max_uv1 = 18446744073709551615, max_uv2 = 18446744073709551615, big_iv 
= -16
# max_uv_less3 = 18446744073709551612
1..1444
# -1.84467440737096e+19 -1.84467440737096e+19 -9.22337203685478e+18 
-9223372036854775808 -1212121212121212121 -979797979797979797 -1 0 1 
979797979797979797 1212121212121212121 9223372036854775808 
9223372036854775809 18446744073709551615 1.84467440737096e+19
ok 1
...
ok 103
not ok 104
ok 105
ok 106
ok 107
not ok 108
ok 109
ok 110
ok 111
not ok 112
ok 113

Thread Previous | 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