core.checkedint.addu: Faster (like subu: only one compare-and-branch).#3496
Conversation
|
Thanks for your pull request and interest in making D better, @DoctorNoobingstoneIPresume! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + druntime#3496" |
|
I wish to modify the pull request like this: May I ask what is the best/preferred way to do this, please ? E.g.: (1) New PR (old PR closed with comment pointing to new PR) ? => Single commit, but comments/conversations are lost (or more difficult to reach) ? (2) New commit on the current PR ? But then how to merge as single commit ? (3) Some other suggestion ? |
|
If If |
5b62e56 to
e0a1abf
Compare
|
@thewilsonator Thank you for the assistance ! I hope I have got it right. |
Explanation of why a single compare-and-branch is enough for
addu:For unsigned integrals, if we add
r = x + y:r >= xandr >= y;r < xandr < y.Also, let us look at the implementation of
subu. One compare-and-branch suffices forsubu. It should suffice foradduas well. (-:Testing information 1 (correctness):
Testing information 2 (improvement of generated code):
Comparison of generated machine code (DMD for Win32):
For
uintoverload: Before: 2 cmp instructions, 2 conditional-jump instructions. After: 1 cmp instruction, 1 conditional-jump instruction.For
ulongoverload: Before: 4 cmp instructions, 4 conditional-jump instructions. After: 2 cmp instructions, 2 conditional-jump instructions.Thank you for considering this.