[Issue 13474] Discard excess precision for float and double (x87)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Nov 7 02:31:10 PST 2016


https://issues.dlang.org/show_bug.cgi?id=13474

--- Comment #23 from yebblies <yebblies at gmail.com> ---

(In reply to Walter Bright from comment #22)
> 
> So I propose that the fix is to disable optimizing away the assignment to y
> for x87 code gen targets.

Are you suggesting disabling that optimization always, or allowing the
programmer to specify that that particular assignment shouldn't be optimized?

If the latter, I would rather stop supporting targets without xmm regs than
stop producing fast code on Win32 etc.

If the former, I think that's well covered by adding an intrinsic, so the code
becomes:

 double foo(double x, double t, double s, double c) {
    double y = __builtin_that_forces_rounding_to_double(x - t);
    c += y + s;
    return s + c;
 }

And this seems like something that could be handled fairly easily in the dmd
backend.  I think this covers all the cases where rounding must be required.

--


More information about the Digitalmars-d-bugs mailing list