This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH, RFC] fma vs gcc 4.9
- From: Richard Henderson <rth at twiddle dot net>
- To: libc-alpha <libc-alpha at sourceware dot org>
- Date: Thu, 10 Jul 2014 09:14:49 -0700
- Subject: Re: [PATCH, RFC] fma vs gcc 4.9
- Authentication-results: sourceware.org; auth=none
- References: <53B59CDF dot 1010604 at twiddle dot net>
Ping?
On 07/03/2014 11:11 AM, Richard Henderson wrote:
> GCC 4.9 optimizes
>
> double a1 = z + m1;
> double t1 = a1 - z;
> double t2 = a1 - t1;
> t1 = m1 - t1;
> t2 = z - t2;
> double a2 = t1 + t2;
> feclearexcept (FE_INEXACT);
>
> if (a1 == 0 && m2 == 0)
> ... return ...
>
> into
>
> double a1 = z + m1;
> feclearexcept (FE_INEXACT);
>
> if (a1 == 0 && m2 == 0)
> ... return ...
>
> double t1 = a1 - z;
> double t2 = a1 - t1;
> t1 = m1 - t1;
> t2 = z - t2;
> double a2 = t1 + t2;
>
> because the later computation is partially redundant for the path leading to
> the return. I noticed this because, of course, the moved computation raises
> INEXACT, leading to incorrect results.
>
> At first I was simply going to add a math_force_eval to make sure everything is
> complete before the feclearexcept, but on further reflection it seemed odd that
> most of the computation is in fact redundant.
>
> It seems to me that there's a typo on that exact zero test: a2 should be used,
> not m2. Correct, or have I mis-read the code?
>
>
> r~
>