[libre-riscv-dev] [Bug 44] IEEE754 FPU inverse-sqrt
bugzilla-daemon at libre-riscv.org
bugzilla-daemon at libre-riscv.org
Mon Jun 24 14:49:25 BST 2019
http://bugs.libre-riscv.org/show_bug.cgi?id=44
--- Comment #29 from Jacob Lifshay <programmerjake at gmail.com> ---
writing this down here so I don't forget:
rsqrt can be calculated by a binary search for 1 by adding powers of 2 (such as
0.5, 0.25, 0.125) to x in the equation 1 = a * x^2 where a is the input to
rsqrt, x starts at 1.0
to evaluate quickly, the next value of a * x^2 can be calculated by addition
from the previous a * x^2 by replacing x with x + 2^b then using the identity:
a * (x + 2^b)^2 = a * x^2 + a * x * 2^(b+1) + a * 2^(2*b) where b is usually a
negative integer that is constant for each pipeline stage.
one benefit of this method is that all the arithmetic can be done exactly and
as a result you know for sure how to round the result.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-riscv-dev
mailing list