This is the mail archive of the gcc@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: thoughts on expand_builtin_mathfn


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 '>='.


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