This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Evaluate pow(x,n) at compile-time


Hi Geoff,
> I think your real_powi is not as accurate as the system pow() routine
> could be, correct?  I don't think we should start folding constants to
> less-accurate values than the system routines would provide.


No.  GCC's real_powi function is likely to be far more accurate than
the system pow.  For example, it is calculated internally with 158+
bit accuracy, and only then rounded to the targets floating point
representation.  All multiplications are monotonic, so we also never
overflow or underflow and later use/need the bits we'd have lost.
This is much like real_sqrt which is also more accurate the FPSQRT
instructions provided on some processors.

Many poor system pow() routines also use exp(n*log(x)) which has
*much* worse precision.

And if this weren't enough, we only constant fold pow(x,n) when the
user specifies "-ffast-math" or "-funsafe-math-optimizations", just
so there are no surprises with the improved accuracy.


[Don't you trust me? :>]

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]