This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: thoughts on expand_builtin_mathfn
- From: Geoffrey Keating <geoffk at geoffk dot org>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 21 Jul 2004 16:39:30 -0700
- Subject: Re: thoughts on expand_builtin_mathfn
- References: <20040721215546.GA25730@redhat.com>
Richard Henderson <rth@redhat.com> writes:
> So I notice that, for
>
> float f(float x) { return sqrtf(x); }
>
> we're generating
>
> t1 = __builtin_sqrtf(x); // optab thingy
> if (t1 == t1)
> t2 = t1;
> else
> t2 = sqrtf(x);
> return t2;
>
> This is a bit suboptimal, since we're stalled on the result
> of the sqrt instruction. A bit better would be
>
> if (x >= 0)
> t1 = __builtin_sqrtf(x);
> else
> t1 = sqrtf(x);
> return t1;
Yes; but you really want isgreaterequal(), though, not '>='.
> If the register allocator manages to put t1 in the return
> result register, then we don't need the result of the sqrt
> instruction until we get back to the caller. I.e. we get
> to excute the entire function epilogue in parallel with the
> computation.
>
> I don't know if its easy to characterize the errno characteristics
> of each of the math functions with a single test like this, but for
> some, like sqrt, it should be easy.
ln() should be similar, except '>' not '>='.