This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Simplify pow with constant
On Fri, Aug 4, 2017 at 2:26 PM, Alexander Monakov <amonakov@ispras.ru> wrote:
> On Fri, 4 Aug 2017, Wilco Dijkstra wrote:
>> This patch simplifies pow (C, x) into exp (x * C1), where C1 = log (C).
>
> I don't think you can do that for non-positive C.
Hmm, the question is also how this interacts with other folders like
sqrt (pow (x, y)) -> pow (|x|, y * 0,5)? Also we seem to miss
pow (2, x) -> exp2 (x) and pow (10, x) -> pow10/exp10, those may
be a better fit than exp (log (2/10) * x)? OTOH for fast-math
canonicalization getting rid of exp2/10 and pow10 might be beneficial.
>> Do this only for fast-math as accuracy is reduced. This is much faster
>> since pow is more complex than exp - with a current GLIBC the speedup
>> is more than 7 times for this transformation.
>
> Is it bound to be so on future glibc revisions and non-glibc platforms?
And how is accuracy affected? I think the transform is only reasonable
for log (C) being close to e, 2 or 10 (using exp, exp2 or exp10). Can you
provide an idea on whether there's a systematic error (with glibc) and
how that behaves over the parameter space?
Oh, and what value of C does the benchmark that triggered this have?
Richard.
> Alexander