This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
thoughts on expand_builtin_mathfn
- From: Richard Henderson <rth at redhat dot com>
- To: Roger Sayle <roger at eyesopen dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 21 Jul 2004 14:55:46 -0700
- Subject: thoughts on expand_builtin_mathfn
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;
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.
r~