-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Enable u64
limbs in core::num::bignum
#146277
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
Conversation
I’m pretty sure uncommenting this doesn’t actually do anything unless you also update the |
Thanks, I wanted to hear something like this, but I might need little bit more explanations about this
Do I have to replace this pub type Digit32 = u32;
define_bignum!(Big32x40: type=Digit32, n=40); And update this name in other places like imports and tests? |
I don’t know if I can provide much guidance here. I haven’t touched this code in about ten years and the parts I’ve worked on have almost entirely been replaced by now. The only thing I can tell you is that simply replacing the existing u32 limbs with u64 limbs will probably be a performance regression on 32 bit targets. A straight replacement is probably easier to try out (to see if it gives any performance gains) but a version that can happily be merged will probably have to grapple with using different bignum types based on some |
I like your idea with |
It used to be used in the slow paths of dec2flt and flt2dec. From a quick code search on GitHub, only flt2dec is still using it. I don’t know off-hand how to find a benchmark that takes that particular code path. |
I tried a full replacement locally and saw the extensive fallout in tests and constants. It's a much larger change than I initially thought. Given the scope and the risk of regression on 32-bit, I'll keep this PR minimal and just uncommenting the line to clean up the obsolete comment. The architectural shift to |
} | ||
|
||
impl_full_ops! { | ||
u8: add(intrinsics::u8_add_with_overflow), mul/div(u16); |
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.
Speaking of things being stable‚ it looks like full_mul_add
above could just be a call to https://doc.rust-lang.org/nightly/std/primitive.u32.html#method.carrying_mul_add -- which is now stable -- instead of needing to write out the multiplication in $bigty
.
Want to make another PR after this one to do that? 🙂
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.
Sure
Agreed it seems reasonable to just impl the trait for the type -- better than a fixme, at least. @bors r+ rollup |
Enable `u64` limbs in `core::num::bignum` Since `u128` is stable now, I guess, we can safely add this, not sure if this requires tests or anything cc rust-lang#137887
Enable `u64` limbs in `core::num::bignum` Since `u128` is stable now, I guess, we can safely add this, not sure if this requires tests or anything cc rust-lang#137887
Rollup of 11 pull requests Successful merges: - #146277 (Enable `u64` limbs in `core::num::bignum`) - #146976 (constify basic Clone impls) - #147249 (Do two passes of `handle_opaque_type_uses_next`) - #147266 (fix 2 search graph bugs) - #147468 (Implement fs api set_times and set_times_nofollow) - #147497 (`proc_macro` cleanups (3/N)) - #147594 (std: implement `pal::os::exit` for VEXos) - #147596 (Adjust the Arm targets in CI to reflect latest changes) - #147607 (GVN: Invalidate derefs at loop headers) - #147620 (Avoid redundant UB check in RangeFrom slice indexing) - #147647 (Hide vendoring and copyright in GHA group) r? `@ghost` `@rustbot` modify labels: rollup
Enable `u64` limbs in `core::num::bignum` Since `u128` is stable now, I guess, we can safely add this, not sure if this requires tests or anything cc rust-lang#137887
Enable `u64` limbs in `core::num::bignum` Since `u128` is stable now, I guess, we can safely add this, not sure if this requires tests or anything cc rust-lang#137887
Enable `u64` limbs in `core::num::bignum` Since `u128` is stable now, I guess, we can safely add this, not sure if this requires tests or anything cc rust-lang#137887
Enable `u64` limbs in `core::num::bignum` Since `u128` is stable now, I guess, we can safely add this, not sure if this requires tests or anything cc rust-lang#137887
Rollup of 12 pull requests Successful merges: - #146277 (Enable `u64` limbs in `core::num::bignum`) - #146976 (constify basic Clone impls) - #147249 (Do two passes of `handle_opaque_type_uses_next`) - #147266 (fix 2 search graph bugs) - #147497 (`proc_macro` cleanups (3/N)) - #147546 (Suppress unused_parens for labeled break) - #147548 (Fix ICE for never pattern as closure parameters) - #147594 (std: implement `pal::os::exit` for VEXos) - #147596 (Adjust the Arm targets in CI to reflect latest changes) - #147607 (GVN: Invalidate derefs at loop headers) - #147620 (Avoid redundant UB check in RangeFrom slice indexing) - #147647 (Hide vendoring and copyright in GHA group) r? `@ghost` `@rustbot` modify labels: rollup
…cottmcm Replace manual implementation with `carrying_mul_add` cc rust-lang#146277 (comment) r? scottmcm
…cottmcm Replace manual implementation with `carrying_mul_add` cc rust-lang#146277 (comment) r? scottmcm
…cottmcm Replace manual implementation with `carrying_mul_add` cc rust-lang#146277 (comment) r? scottmcm
…cottmcm Replace manual implementation with `carrying_mul_add` cc rust-lang#146277 (comment) r? scottmcm
Rollup merge of #147666 - Kivooeo:full_mud_add-followup, r=scottmcm Replace manual implementation with `carrying_mul_add` cc #146277 (comment) r? scottmcm
Bors hasn't noticed that this was merged. @bors r- |
Replace manual implementation with `carrying_mul_add` cc rust-lang/rust#146277 (comment) r? scottmcm
Since
u128
is stable now, I guess, we can safely add this, not sure if this requires tests or anythingcc #137887