This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Committed] Use special-purpose hash table to speed up walk_tree
On Sat, Oct 16, 2004 at 11:37:41AM -0700, Richard Henderson wrote:
> On Sat, Oct 16, 2004 at 02:34:24PM -0400, Jakub Jelinek wrote:
> > You mean doing the computation in FPU?
>
> Well, it's all constants, so why wouldn't it be folded at compile time?
Because not all hosts have long double that has big enough mantissa
to compute the exact result (nor I think we can portably use math *l
functions)?
Perhaps we can do it as a fallback:
#if HOST_BITS_PER_LONG == 32
const unsigned long A = 0x9e3779b9u;
#elif HOST_BITS_PER_LONG == 64
const unsigned long A = 0x9e3779b97f4a7c16ul;
#else
const double M = (ULONG_MAX + 1.0);
const double B = M / ((sqrt (5) - 1) / 2.0);
const unsigned long A = B - (floor (B / M) * M);
#endif
The last one results in const unsigned long A = 0x9e3779b97f4a7000;
on x86-64, while if done with long double it gives correct
const unsigned long A = 0x9e3779b97f4a7c16; result.
Jakub