Tail calls and floating-point types (was Re: remove unneeded fold-converts)
Richard Henderson
rth@redhat.com
Thu Sep 9 19:46:00 GMT 2004
On Thu, Sep 09, 2004 at 04:34:21PM +0100, Richard Sandiford wrote:
> + /* Tail call optimizations would convert func() into the moral
> equivalent of:
> +
> + double acc = 0.0;
> + for (int i = 0; i < n; i++)
> + acc += d;
> + return acc;
> +
> + which mishandles the case where 'd' is -0. They also initialised 'acc'
> + to a zero int rather than a zero double. */
> +
> + double func (double d, int n)
> + {
> + if (n == 0)
> + return d;
> + else
> + return d + func (d, n - 1);
Whee. That's nifty.
Yeah, a check for HONOR_SIGNED_ZEROS would do the trick.
r~
More information about the Gcc-patches
mailing list