-
-
Notifications
You must be signed in to change notification settings - Fork 610
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 core.math.toPrec intrinsics #10654
Conversation
|
Thanks for your pull request, @ibuclaw! 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 fetch digger
dub run digger -- build "master + dmd#10654" |
|
Dependant druntime PR merged. |
|
Added back-end support for precision truncating/extending, based off CastExp. Let's see if it fixes the testsuite agrees with it... |
|
Please also see #10656 which is a much better way to do intrinsics. |
9614e2d to
b684c37
Compare
|
Apparently SIMD is broken, which means I must have messed up the intrinsic name array somehow... |
6a0812a to
9074f1a
Compare
Fixed by moving OPtoPrec to the bottom of the OPER enum... which seems to suggest there's something fishing going on in the dmd backend (bad relative comparison somewhere?). |
|
@thewilsonator - I'd prefer to give this a quick test/port on gdc (ppc64 more specifically) before committing, when/if this pull ever goes green. |
|
Don't worry I won't pull this until at least #10654 (comment) is addressed ;) |
|
OK, it works perfect with GDC. :-P |
c89d594 to
bcc4455
Compare
|
The azure failures likely down to casting from longdouble (soft 80-bit) to real (native 64-bit). There's practically zero need for toPrec!real to do anything really, I'm not even sure returning a |
|
@thewilsonator - I think we're all green now. |
|
@don-clugston-sociomantic - does this sufficiently satisfy https://issues.dlang.org/show_bug.cgi?id=9937 ? Example usage of it, where double precision is forced at specific checkpoints in the CTFE code is found here. |
|
Finally! This is long overdue! It does not say which form of rounding is used. Since the purpose of this to eradicate machine-specific bits, the compiler can do it however it likes, Not sure if 'machine-dependent' is the right word, but it's more than just CPU-dependent, it may depend on the OS as well. |
At runtime, the codegen is indistinguishable from a During CTFE, dmd stores the value as the requested type, which I imagine would be just loading it in the appropriate register. GDC and probably LDC will truncate or extend the representation so that it fits the target type.
It would depend on the default rounding mode for the type. Looking at the list of possible formats, there's only one that instead rounds to zero. If the PR hasn't been merged, I can bundle in the comment in the second toPrec PR I made. |
|
Is this good to go? |
|
Looks good to me. |
Rebase of #7219.
Requires dlang/druntime#2864.