[Bug 110435] fp64 division gives imprecise results

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat May 11 09:56:08 UTC 2019


https://bugs.freedesktop.org/show_bug.cgi?id=110435

--- Comment #3 from Ruslan Kabatsayev <b7.10110111 at gmail.com> ---
The problem appears to be with lower_rcp from nir_lower_double_ops.c. Namely,
it's supposed to use two Newton-Raphson steps to improve precision of initial
single-precision rcp. But instead of actually doing the steps, it employs FMA
operation, with a mistake.

Namely, the correct expression should be (as noted in the comment, thanks to it
being present):

x_new = x + x * (1 - x*src).

But actual implementation is

ra = nir_ffma(b, ra, nir_ffma(b, ra, src, nir_imm_double(b, -1)), ra),

which is equivalent to

x_new = x - x * (1 - x*src).

Notice the minus sign before the outermost multiplication.

I'm not sure how to change sign of `ra` to check whether this would completely
fix the problem, but at least in an equivalent-code test in C++ I've reproduced
the problem, and the change

    ra=std::fma(ra, std::fma(ra, src, -1.), ra);
to
    ra=std::fma(-ra, std::fma(ra, src, -1.), ra);

made the difference between 1./src and the rcp-via-float in the C++ test go
away (for src=5.44786569377455 I used in the test).

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20190511/456d06a2/attachment.html>


More information about the intel-3d-bugs mailing list