You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
141: Use the _addcarry and _subborrow intrinsics when available r=cuviper a=ejmahler
When compiling for x86_64, with "u64_digit" enabled, some benchmarks are improved by using `_addcarry_u64` instead of the custom-written `adc` function, and using `_subborrow_u64)` instead of the custom-written `sbb` function.
The fib and fib2 benchmarks improved the most, most benchmarks improved a little, and a few were worse within the margin of error.
The only benchmark that did legitimately worse was the `gcd_euclid` family, but there's a comment after those benchmarks saying `// Integer for BigUint now uses Stein for gcd`. the stein benchmarks showed improvements with this change.
Looking at the generated assembly, it was generating adcq instructions both before and after the change, but post-change the code using adc is a little shorter. It's possible that the intrinsic provided just enough of a hint to the compiler that it was able to optimize some things away. The compiler wasn't generating sbb instructions at all, so this adds them -- and once nice thing is that this change eliminates signed->unsigned conversions.
Let me know if you'd prefer a different away to organize the platform-specific code.
Co-authored-by: Elliott Mahler <join.together@gmail.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
0 commit comments