-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use BigMul for 32x32=64 in decimal #93345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3fa9604
fab4430
6f04db3
0572988
495a8e5
8c3f5ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,20 +184,7 @@ private static ulong UInt32x32To64(uint a, uint b) | |
|
|
||
| private static void UInt64x64To128(ulong a, ulong b, ref DecCalc result) | ||
| { | ||
| ulong low = UInt32x32To64((uint)a, (uint)b); // lo partial prod | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you delete
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could yes, but:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you measure the performance of this change? Last time I checked, a similar change caused a significant performance regression because the codegen for |
||
| ulong mid = UInt32x32To64((uint)a, (uint)(b >> 32)); // mid 1 partial prod | ||
| ulong high = UInt32x32To64((uint)(a >> 32), (uint)(b >> 32)); | ||
| high += mid >> 32; | ||
| low += mid <<= 32; | ||
| if (low < mid) // test for carry | ||
| high++; | ||
|
|
||
| mid = UInt32x32To64((uint)(a >> 32), (uint)b); | ||
| high += mid >> 32; | ||
| low += mid <<= 32; | ||
| if (low < mid) // test for carry | ||
| high++; | ||
|
|
||
| ulong high = Math.BigMul(a, b, out ulong low); | ||
| if (high > uint.MaxValue) | ||
| Number.ThrowOverflowException(SR.Overflow_Decimal); | ||
| result.Low64 = low; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced, technically speaking, by
Math.BigMul(ulong, ulong, out ulong)as well.Then it can also be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure, NB that overflow check and insertion to DecCalc result are still in body below. Do we prefer to move those around to where this is now called or should i keep this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to keep the extra checks centralized here and just defer the algorithm to Math.BigMul