Re: [PATCH] Update sinhatanh test

2019-04-29 Thread Giuliano Augusto Faulin Belinassi
Hi. Ping :-) (I hope I am not bothering you with it) Giuliano. On Thu, Jan 10, 2019 at 6:51 PM Giuliano Belinassi wrote: > > Previously, the tests 'sinhatanh-2.c' and 'sinhatanh-3.c' did not count > the number of functions found in the tree-dump. This patch address this > issue. > > 2019-01-10 G

Re: [PATCH v4] Add sinh(atanh(x)) and cosh(atanh(x)) optimizations

2018-11-29 Thread Giuliano Augusto Faulin Belinassi
Hi, Please check line 4102 in match.pd. Notice that (if (flag_unsafe_math_optimizations) And my code is inside that if :-) Giuliano. On Thu, Nov 29, 2018 at 2:37 AM Jeff Law wrote: > > On 11/27/18 12:38 PM, Giuliano Augusto Faulin Belinassi wrote: > > Only do this optimizatio

[PATCH v4] Add sinh(atanh(x)) and cosh(atanh(x)) optimizations

2018-11-27 Thread Giuliano Augusto Faulin Belinassi
Only do this optimization if funsafe-math and -fno-math-errno are enabled, as pointed in the previous iteration. Also added one more test case to ensure that fno-math-errno is required for the optimization. Special thanks for Wilco Dijsktra for all his help :-) gcc/ChangeLog 2018-11-27 Giuliano

Re: [PATCH v3] Add sinh(atanh(x)) and cosh(atanh(x)) optimizations

2018-11-22 Thread Giuliano Augusto Faulin Belinassi
Hi, Sorry, but I am a little confused. On Wed, Nov 14, 2018 at 11:28 AM Wilco Dijkstra wrote: > > Hi, > > > > Indeed. After plotting the graph of both functions, it is very clear > > that this check isn't required. Sorry about that. > > It wouldn't be clear from the graph, you need to check that

Re: [PATCH v3] Add sinh(atanh(x)) and cosh(atanh(x)) optimizations

2018-11-14 Thread Giuliano Augusto Faulin Belinassi
On Wed, Nov 14, 2018 at 7:41 AM Richard Biener wrote: > > On Tue, Nov 13, 2018 at 10:25 PM Giuliano Augusto Faulin Belinassi > wrote: > > > > Only do the optimization if flag_signed_zeros && > > !flag_finite_math_only is set, as suggested in the previous itera

[PATCH v3] Add sinh(atanh(x)) and cosh(atanh(x)) optimizations

2018-11-13 Thread Giuliano Augusto Faulin Belinassi
Only do the optimization if flag_signed_zeros && !flag_finite_math_only is set, as suggested in the previous iteration. Before, the patch did the optimization even when -fno-signed-zeros and -ffinite-math-only was set. This could generate badly incorrect results for targets that do not support inf

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-11-09 Thread Giuliano Augusto Faulin Belinassi
Hi. Sorry for the late reply :P > But the max. error in sinh/cosh/atanh is less than 2 ULP, with some math > ibraries. It could be < 1 ULP, in theory, so sinh(atanh(x)) less than >2 ULP even. Sorry, but doesn't the user agree to sacrifice precision for performance when -ffast-math is enabled? >

[PATCHv2] Add sinh(atanh(x)) and cosh(atanh(x)) optimizations

2018-10-29 Thread Giuliano Augusto Faulin Belinassi
Improves the numerical precision, as suggested on the previous iteration. Before, the code used 1 - x*x, which can be problematic when x is near 1. Wilco Dijkstra suggested to replace it with 2*(1-fabs(x)) - (1-fabs(x))*(1-fabs(x)) when fabs(x) > 0.5 to greatly improve precision, however after som

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-10-20 Thread Giuliano Augusto Faulin Belinassi
So I did some further investigation comparing the ULP error. With the formula that Wilco Dijkstra provided, there are cases where the substitution is super precise. With floats: with input : = 9.9940395355224609375000e-01 sinh: before: = 2.896310058593750

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-10-19 Thread Giuliano Augusto Faulin Belinassi
; > 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)

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-10-19 Thread Giuliano Augusto Faulin Belinassi
Hello, > 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 availabl

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-10-17 Thread Giuliano Augusto Faulin Belinassi
ecise approximation). Well, I will try check that. But yes, with regard to compatibility this may be a problem. On Wed, Oct 17, 2018 at 6:42 PM Jeff Law wrote: > > On 10/17/18 3:25 PM, Giuliano Augusto Faulin Belinassi wrote: > >> Hmm, do we have problems as we get close to -1 or 1 where the

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-10-17 Thread Giuliano Augusto Faulin Belinassi
> Hmm, do we have problems as we get close to -1 or 1 where the outputs of > the two forms might diverge? Well, I did some minor testing with that with input x around nextafter(1, -1); There are a minor imprecision when comparing directly with sinh(atanh(x)) and cosh(atanh(x)). * On 32-bits floa

Re: [PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-16 Thread Giuliano Augusto Faulin Belinassi
re about that? Since the only point of this patch is to simplify these kind of expressions, and it is not being simplified at all in your arch as the asm dump suggests, then it seems safe to skip all sinatan-*.c tests. On Tue, Oct 16, 2018 at 1:25 PM Christophe Lyon wrote: > > On

Re: [PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-16 Thread Giuliano Augusto Faulin Belinassi
Hello, Christophe Could you please dump the assembly of cosatanf here? On Tue, Oct 16, 2018 at 12:23 PM Christophe Lyon wrote: > > On Tue, 16 Oct 2018 at 17:15, Giuliano Augusto Faulin Belinassi > wrote: > > > > Hello. Sorry for the late reply. > > > > &

Re: [PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-16 Thread Giuliano Augusto Faulin Belinassi
ne 58 to: int __attribute__ ((optimize("O0"))) in sinatan-1.c? On Fri, Oct 12, 2018 at 3:24 PM Christophe Lyon wrote: > > On Fri, 12 Oct 2018 at 20:01, Giuliano Augusto Faulin Belinassi > wrote: > > > > > fc is built with: > > >mov r0, #0 > &g

Re: [PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-12 Thread Giuliano Augusto Faulin Belinassi
ter option? On Fri, Oct 12, 2018 at 12:57 PM Jeff Law wrote: > > On 10/12/18 9:51 AM, Giuliano Augusto Faulin Belinassi wrote: > > Hello > > What is the output of these functions on such arch? Since the > > test didn't fail for the sinatan counterpart, an possible

Re: [PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-12 Thread Giuliano Augusto Faulin Belinassi
Hello What is the output of these functions on such arch? Since the test didn't fail for the sinatan counterpart, an possible explanation would be that the calculation of the sqrf, sqrt and sqrtl (lines 62-64) yielded a number that is far behind of what it should be. However, I am still not su

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-10-12 Thread Giuliano Augusto Faulin Belinassi
orted to try to keep compatibility, but I think this is safe :-). On Fri, Oct 12, 2018 at 1:09 AM Jeff Law wrote: > > On 8/7/18 2:00 PM, Giuliano Augusto Faulin Belinassi wrote: > > Related with bug 86829, but for hyperbolic trigonometric functions. > > This patch adds substitution rul

[PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

2018-10-09 Thread Giuliano Augusto Faulin Belinassi
Fixed all issues pointed in the previous iteration. There is now a significant change regarding how the sin(atan(x)) constant is calculated, as now it checks for which values such that computing 1 + x*x won't overflow. There are two reasons for this change: (1) Avoid an intermediate infinity value

Re: [PATCH] Optimize sin(atan(x)), take 2

2018-10-05 Thread Giuliano Augusto Faulin Belinassi
Thank you for the review. I will address all these issues :-). > Imagine a pause here while I lookup isolation of radicals It's been > a long time... OK. Sure. I see what you're doing here... Sorry, but I really did not understand your comment. Should I write a shorter comment for that f

Re: [PATCH] Optimize sin(atan(x)), take 2

2018-09-20 Thread Giuliano Augusto Faulin Belinassi
Pinging match.pd and real.c maintainers, as suggested in IRC. Sorry if it is inappropriate On Mon, Sep 17, 2018 at 9:46 AM Giuliano Augusto Faulin Belinassi wrote: > > Ping. > > On Mon, Sep 3, 2018 at 4:11 PM, Giuliano Augusto Faulin Belinassi > wrote: > > Fixed the

Re: [PATCH] Optimize sin(atan(x)), take 2

2018-09-17 Thread Giuliano Augusto Faulin Belinassi
Ping. On Mon, Sep 3, 2018 at 4:11 PM, Giuliano Augusto Faulin Belinassi wrote: > Fixed the issues pointed by the previous discussions. Closes PR86829. > > Adds substitution rules for sin(atan(x)) and cos(atan(x)), being > careful with overflow issues by constructing a assumed

[PATCH] Optimize sin(atan(x)), take 2

2018-09-03 Thread Giuliano Augusto Faulin Belinassi
Fixed the issues pointed by the previous discussions. Closes PR86829. Adds substitution rules for sin(atan(x)) and cos(atan(x)), being careful with overflow issues by constructing a assumed convergence constant (see comment in real.c). 2018-09-03 Giuliano Belinassi * match.pd: add simplifi

[PATCH] fix typo 'exapnded' to 'expanded'

2018-08-23 Thread Giuliano Augusto Faulin Belinassi
There was a small typo in the current version of trunk, more precisely in genmatch.c and exp_unst.ads. This patch fixes it. Changelog: 2018-08-23 Giuliano Belinassi * genmatch.c: Fix typo 'exapnded' to 'expanded'. * exp_unst.ads: Likewise. I don't think this requires a test case :P In

Re: patch to bug #86829

2018-08-23 Thread Giuliano Augusto Faulin Belinassi
2018 06:02 AM, Richard Biener wrote: >> On Tue, Aug 21, 2018 at 11:27 PM Jeff Law wrote: >>> >>> On 08/21/2018 02:08 PM, Giuliano Augusto Faulin Belinassi wrote: >>>>> Just as an example, compare the results for >>>>> x = 0x1.fp1023 >

Re: patch to bug #86829

2018-08-21 Thread Giuliano Augusto Faulin Belinassi
>> On Mon, Aug 20, 2018 at 9:40 PM Jeff Law wrote: >>> >>> On 08/04/2018 07:22 AM, Giuliano Augusto Faulin Belinassi wrote: >>>> Closes bug #86829 >>>> >>>> Description: Adds substitution rules for both sin(atan(x)) and >>>> c

Re: patch to bug #86829

2018-08-18 Thread Giuliano Augusto Faulin Belinassi
ping On Sat, Aug 4, 2018 at 10:22 AM, Giuliano Augusto Faulin Belinassi wrote: > Closes bug #86829 > > Description: Adds substitution rules for both sin(atan(x)) and > cos(atan(x)). These formulas are replaced by x / sqrt(x*x + 1) and 1 / > sqrt(x*x + 1) respectively, providing up

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-08-08 Thread Giuliano Augusto Faulin Belinassi
t; > paul > > >> On Aug 7, 2018, at 4:42 PM, Giuliano Augusto Faulin Belinassi >> wrote: >> >> That is a good question because I didn't know that such targets >> exists. Any suggestion? >> >> >> On Tue, Aug 7, 2018 at 5:29 PM,

Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-08-07 Thread Giuliano Augusto Faulin Belinassi
That is a good question because I didn't know that such targets exists. Any suggestion? On Tue, Aug 7, 2018 at 5:29 PM, Paul Koning wrote: > > >> On Aug 7, 2018, at 4:00 PM, Giuliano Augusto Faulin Belinassi >> wrote: >> >> Related with bug 86829, but for

[PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules

2018-08-07 Thread Giuliano Augusto Faulin Belinassi
Related with bug 86829, but for hyperbolic trigonometric functions. This patch adds substitution rules to both sinh(tanh(x)) -> x / sqrt(1 - x*x) and cosh(tanh(x)) -> 1 / sqrt(1 - x*x). Notice that the both formulas has division by 0, but it causes no harm because 1/(+0) -> +infinity, thus the math

patch to bug #86829

2018-08-04 Thread Giuliano Augusto Faulin Belinassi
Closes bug #86829 Description: Adds substitution rules for both sin(atan(x)) and cos(atan(x)). These formulas are replaced by x / sqrt(x*x + 1) and 1 / sqrt(x*x + 1) respectively, providing up to 10x speedup. This identity can be proved mathematically. Changelog: 2018-08-03 Giuliano Belinassi