This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Constant fold sqrt at compile time
- From: Roger Sayle <roger at eyesopen dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 2 Nov 2002 22:15:01 -0700 (MST)
- Subject: Re: [PATCH] Constant fold sqrt at compile time
Richard Henderson wrote:
> > My proposal is more efficient but requires the function:
> >
> > void real_inc_ulps(REAL_VALUE_TYPE *r, enum machine_mode mode)
> >
> > which will increment the value "r" by one ulps.
>
> Well, really I'd rather the sqrt function be implemented with
> the internal routines, which I think makes it a bit cleaner,
> and makes this function trivial. It's add_significand with one
> of the significands with bit 1 set.
One of the advantages of using a "real_inc_ulps" is that it can be
implemented much more efficiently than using add_significands. The
average carry chain for increment is about one bit (half of all
increments have no carry at all), so the probability of requiring
more than a single integer addition are exceedingly low. A
real_inc_ulps routine could also handle the increment exponent on
mantissa overflow cases efficiently and transparently.
Hence even with sqrt implemented using internal routines, it would
still make sense to split out the "inc_ulps" functionality into its
own subroutine. Clearly, this inc_ulps would need to use internal
routines, but real_sqrt would retain the choice of being internal or
external, if real_inc_ulps became a public interface.
Roger
--