This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Giuliano Augusto Faulin Belinassi <giuliano dot belinassi at usp dot br>
- Cc: Wilco dot Dijkstra at arm dot com, GCC Patches <gcc-patches at gcc dot gnu dot org>, giuliano dot belinassi at gmail dot com, nd at arm dot com, Jeff Law <law at redhat dot com>
- Date: Fri, 19 Oct 2018 08:45:12 -0500
- Subject: Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules
- References: <DB5PR08MB103001D43201E2827778B49F83E30@DB5PR08MB1030.eurprd08.prod.outlook.com> <CAEFO=4CV1P23fmb_kAv8u=ubJ5PejVFC59gFGnbNm2TrO-P38Q@mail.gmail.com>
Hi all,
On Fri, Oct 19, 2018 at 09:21:07AM -0300, Giuliano Augusto Faulin Belinassi wrote:
> > Did you enable FMA? I'd expect 1 - x*x to be accurate with FMA, so the relative error
> > should be much better. If there is no FMA, 2*(1-fabs(x)) - (1-fabs(x))^2 should be
> > more accurate when abs(x)>0.5 and still much faster.
>
> No, but I will check how to enable it if FMA is available.
> I did a minor test with your formula and the precision improved a lot.
> Here is an example for floats
>
> with input : = 9.99999880790710449218750000000000000000000000000000e-01
> cosh: before: = 2.04800000000000000000000000000000000000000000000000e+03
> cosh: after : = 2.04800024414062500000000000000000000000000000000000e+03
> cosh: mpfr : = 2.04800006103515897848424084406334262726138617589463e+03
> error before: = 6.10351589784842408440633426272613861758946325324235e-05
> error after : = 1.83105466021515759155936657372738613824105367467577e-04
Maybe I am crazy, or the labels here are wrong, but that looks like the
error is three times as *big* after the patch. I.e. it worsened instead
of improving.
Segher