-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add divmod support #4437
Comments
This would be great. A few of the date conversion algorithms in Datetime utilize divmod. |
Technically this should be |
We can implement any and all of those. |
Should this be closed, given that divrem is implemented now? |
We might want |
|
Understood, because they wouldn't fulfil a nice invariant. divrem(x,y) = (div(x,y),rem(x,y)) Question: That does not seem faster than, well, computing the quotient using div, and the remainder using rem, i.e. essentially doing the work twice. Is there any trickery behind the scenes? If not, it seems trivial to add fldmod(x,y) = (fld(x,y),mod(x,y)) (Oh, except that there is a divrem implementation for BigInts, calling a gmp function, so that should be faster for BigInts) |
I thought this was originally brought up because LLVM has a special instruction for this? |
It's actually the opposite – LLVM does not have a special instruction for this but x86 does both with |
That is correct; the extra checks we need to do seem to prevent LLVM from using a single |
Isn't there anything we can do to make |
Yes; lobby for and hope for an x86-div-with-trap intrinsic in LLVM. |
Or we could potentially patch the bit of the LLVM optimizer that replaces undefined div and rem operations with random values. |
The perennial division discussion aside, do we still want |
Feel free to reopen if there's anything else desired here. |
This was mentioned/planned in the discussion for JuliaLang#4437 but was not implemented at the time.
Related discussion in #4427
The text was updated successfully, but these errors were encountered: