https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106902

--- Comment #7 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Lawrence, thank you for the nice work reducing the testcase. For RawTherapee
the recommended course of action would be to compile everything with
-ffp-contract=off, then manually reintroduce use of fma in
performance-sensitive places by testing the FP_FAST_FMA macro to know if
hardware fma is available. This way you'll know that all systems without fma
get the same results, and all systems with fma also get the same results (but
different from the former).

For example, my function 'f1' could be adapted like this:

void f1(void)
{
        double x1 = 0, x2 = 0, x3 = 0;

        for (int i = 0; i < 99; ) {
                double t;
#ifdef FP_FAST_FMA
                t = fma(x1, b1, fma(x2, b2, fma(x3, b3, B * one)));
#else
                t = B * one + x1 * b1 + x2 * b2 + x3 * b3;
#endif
                printf("%d %g\t%a\n", i++, t, t);

                x3 = x2, x2 = x1, x1 = t;
        }
}

Reply via email to