diff options
author | Rafael Tsuha <rafael.tsuha@usp.br> | 2019-10-04 18:34:29 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2019-10-04 12:34:29 -0600 |
commit | 2066f7951cc4f0b23ddff5abfd2ad2ea4ee90fff (patch) | |
tree | ab2ca5ec91831479d810d5601ff37fedbae4dc55 /gcc | |
parent | 69b35f396ceb22e2e04b4228a6811291621808c1 (diff) | |
download | gcc-2066f7951cc4f0b23ddff5abfd2ad2ea4ee90fff.zip gcc-2066f7951cc4f0b23ddff5abfd2ad2ea4ee90fff.tar.gz gcc-2066f7951cc4f0b23ddff5abfd2ad2ea4ee90fff.tar.bz2 |
match.pd (sinh (x) / cosh (x)): New simplification rule.
* match.pd (sinh (x) / cosh (x)): New simplification rule.
* gcc.dg/sinhovercosh-1.c: New test.
From-SVN: r276595
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/match.pd | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/sinhovercosh-1.c | 45 |
4 files changed, 58 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a013d86..6da73b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2019-10-04 Rafael Tsuha <rafael.tsuha@usp.br> + + * match.pd (sinh (x) / cosh (x)): New simplification rule. + 2019-10-04 Martin Jambor <mjambor@suse.cz> * tree-ssa-forwprop.c (simplify_builtin_call): Set gimple call diff --git a/gcc/match.pd b/gcc/match.pd index 23ce3768..9bd5f3e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4922,6 +4922,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (rdiv (SIN:s @0) (COS:s @0)) (TAN @0)) + /* Simplify sinh(x) / cosh(x) -> tanh(x). */ + (simplify + (rdiv (SINH:s @0) (COSH:s @0)) + (TANH @0)) + /* Simplify cos(x) / sin(x) -> 1 / tan(x). */ (simplify (rdiv (COS:s @0) (SIN:s @0)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 68ca51e..4248c81 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-10-04 Rafael Tsuha <rafael.tsuha@usp.br> + + * gcc.dg/sinhovercosh-1.c: New test. + 2019-10-04 Joseph Myers <joseph@codesourcery.com> * gcc.dg/c11-builtins-1.c, gcc.dg/c2x-builtins-1.c, diff --git a/gcc/testsuite/gcc.dg/sinhovercosh-1.c b/gcc/testsuite/gcc.dg/sinhovercosh-1.c new file mode 100644 index 0000000..7e51072 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sinhovercosh-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ + +extern float sinhf (float); +extern float coshf (float); +extern float tanhf (float); +extern float sqrtf (float); +extern double sinh (double); +extern double cosh (double); +extern double sqrt (double); +extern double tanh (double); +extern long double sinhl (long double); +extern long double coshl (long double); +extern long double tanhl (long double); +extern long double sqrtl (long double); + +double __attribute__ ((noinline)) +sinhovercosh_ (double x) +{ + return sinh (x) / cosh (x); +} + +float __attribute__ ((noinline)) +sinhfovercoshf_(float x) +{ + return sinhf (x) / coshf (x); +} + +long double __attribute__ ((noinline)) +sinhlovercoshl_ (long double x) +{ + return sinhl (x) / coshl (x); +} + +/* There must be no calls to sinh, cosh, or atanh */ +/* {dg-final { scan-tree-dump-not "sinh " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "cosh " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "sinfh " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "cosfh " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "sinlh " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "coslh " "optimized" } } */ +/* {dg-final { scan-tree-dump-times "tanh " "1" "optimized" }} */ +/* {dg-final { scan-tree-dump-times "tanhl " "1" "optimized" }} */ +/* {dg-final { scan-tree-dump-times "tanhf " "1" "optimized" }} */ + |