Re: [patch,committed] Move gfortran.dg/dec_math_5.f90 to ./ieee/ (was: Re: PATCH -- Fix degree trignometric functions)

2020-04-08 Thread Fritz Reese via Gcc-patches
Andreas, thank you for the report.

Tobias, thank you for the fix.

---
Fritz Reese

On Wed, Apr 8, 2020 at 12:02 PM Tobias Burnus  wrote:
>
> Hi Andreas,
>
> thanks for the report. In principle, it would be helpful to know on
> which target you are running the test case.
>
> However, I assume that either of the following went wrong:
> * Target does not support IEEE
> * It supports it, but gfortran's intrinsic search path does
>not point to directory in which the ieee modules are
>
> That's solved by moving the test case to the ieee/ subdirectory
> which has a check whether IEEE works and also sets the intrinsic
> module include path (-fintrinsic-modules-path $specpath/libgfortran/).
>
> I have now committed it as obvious – but I would be good when you
> can confirm that it works (PASS if it should support IEEE or, if not,
> UNSUPPORTED).
>
> See r10-7631-gfaa0817311f43e0d4d223d53c816b0c74ec35c4e
> or attachment.
>
> Cheers,
>
> Tobias
>
> On 4/8/20 5:04 PM, Andreas Schwab wrote:
>
> > FAIL: gfortran.dg/dec_math_5.f90   -O0  (test for excess errors)
> > Excess errors:
> > /opt/gcc/gcc-20200408/gcc/testsuite/gfortran.dg/dec_math_5.f90:132:9: Fatal 
> > Error: Cannot open module file 'ieee_arithmetic.mod' for reading at (1): No 
> > such file or directory
> > compilation terminated.
> >
> > Andreas.
> >
> -
> Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
> Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, 
> Alexander Walter


[patch,committed] Move gfortran.dg/dec_math_5.f90 to ./ieee/ (was: Re: PATCH -- Fix degree trignometric functions)

2020-04-08 Thread Tobias Burnus

Hi Andreas,

thanks for the report. In principle, it would be helpful to know on
which target you are running the test case.

However, I assume that either of the following went wrong:
* Target does not support IEEE
* It supports it, but gfortran's intrinsic search path does
  not point to directory in which the ieee modules are

That's solved by moving the test case to the ieee/ subdirectory
which has a check whether IEEE works and also sets the intrinsic
module include path (-fintrinsic-modules-path $specpath/libgfortran/).

I have now committed it as obvious – but I would be good when you
can confirm that it works (PASS if it should support IEEE or, if not,
UNSUPPORTED).

See r10-7631-gfaa0817311f43e0d4d223d53c816b0c74ec35c4e
or attachment.

Cheers,

Tobias

On 4/8/20 5:04 PM, Andreas Schwab wrote:


FAIL: gfortran.dg/dec_math_5.f90   -O0  (test for excess errors)
Excess errors:
/opt/gcc/gcc-20200408/gcc/testsuite/gfortran.dg/dec_math_5.f90:132:9: Fatal 
Error: Cannot open module file 'ieee_arithmetic.mod' for reading at (1): No 
such file or directory
compilation terminated.

Andreas.


-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
commit faa0817311f43e0d4d223d53c816b0c74ec35c4e
Author: Tobias Burnus 
Date:   Wed Apr 8 17:54:04 2020 +0200

Move gfortran.dg/dec_math_5.f90 to ./ieee/

PR fortran/93871
* gfortran.dg/dec_math_5.f90: Move to ...
* gfortran.dg/ieee/dec_math_1.f90: ... here; change
dg-options to dg-additional-options.
---
 gcc/testsuite/ChangeLog   | 7 +++
 gcc/testsuite/gfortran.dg/{dec_math_5.f90 => ieee/dec_math_1.f90} | 5 -
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 557c81544e4..347181619a5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2020-04-08  Tobias Burnus  
+
+	PR fortran/93871
+	* gfortran.dg/dec_math_5.f90: Move to ...
+	* gfortran.dg/ieee/dec_math_1.f90: ... here; change
+	dg-options to dg-additional-options.
+
 2020-04-08  Alexandre Oliva 
 
 	* gcc.dg/tls/pr78796.c: Require tls_runtime.
diff --git a/gcc/testsuite/gfortran.dg/dec_math_5.f90 b/gcc/testsuite/gfortran.dg/ieee/dec_math_1.f90
similarity index 97%
rename from gcc/testsuite/gfortran.dg/dec_math_5.f90
rename to gcc/testsuite/gfortran.dg/ieee/dec_math_1.f90
index d761e039cc8..8587fd66eb1 100644
--- a/gcc/testsuite/gfortran.dg/dec_math_5.f90
+++ b/gcc/testsuite/gfortran.dg/ieee/dec_math_1.f90
@@ -1,8 +1,11 @@
-! { dg-options "-cpp -std=gnu" }
 ! { dg-do run }
+! { dg-additional-options "-cpp -std=gnu" }
 !
 ! Test values for degree-valued trigonometric intrinsics.
 !
+! Run under ieee/ as
+!   use ieee_arithmetic
+! (used for result checking) is not available on all platforms)
 
 module dec_math_5
 


Re: PATCH -- Fix degree trignometric functions

2020-04-08 Thread Andreas Schwab
FAIL: gfortran.dg/dec_math_5.f90   -O0  (test for excess errors)
Excess errors:
/opt/gcc/gcc-20200408/gcc/testsuite/gfortran.dg/dec_math_5.f90:132:9: Fatal 
Error: Cannot open module file 'ieee_arithmetic.mod' for reading at (1): No 
such file or directory
compilation terminated.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: PATCH -- Fix degree trignometric functions

2020-03-31 Thread Fritz Reese via Gcc-patches
On Fri, Mar 27, 2020 at 7:36 PM Fritz Reese  wrote:
>
> On Fri, Mar 6, 2020 at 6:18 PM Steve Kargl
>  wrote:
> [...]
> > TL;DR version.
> >
> >   Fix the simplification and handling of the degree trigonometric functions.
> >   This includes fixing a number of ICEs.  See PR 93871.
>
> An updated version of the patch is attached. Regression tests (and new
> test cases) are pending.
>

Patch with regression tests attached, and rebased onto master
(013fca64fc...). The new and updated tests cover several issues
discovered and discussed in PR 93871 at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93871 . I am
bootstrapping and testing now. If everything passes, does this look OK
to commit?

gcc/fortran/ChangeLog:

PR fortran/93871
* gfortran.h (GFC_ISYM_ACOSD, GFC_ISYM_ASIND, GFC_ISYM_ATAN2D,
GFC_ISYM_ATAND, GFC_ISYM_COSD, GFC_ISYM_COTAND, GFC_ISYM_SIND,
GFC_ISYM_TAND): New.
* intrinsic.c (add_functions): Remove check for flag_dec_math.
Give degree trig functions simplification and name resolution
functions (e.g, gfc_simplify_atrigd () and gfc_resolve_atrigd ()).
(do_simplify): Remove special casing of degree trig functions.
* intrinsic.h (gfc_simplify_acosd, gfc_simplify_asind,
gfc_simplify_atand, gfc_simplify_cosd, gfc_simplify_cotand,
gfc_simplify_sind, gfc_simplify_tand, gfc_resolve_trigd2): Add new
prototypes.
(gfc_simplify_atrigd, gfc_simplify_trigd, gfc_resolve_cotan,
resolve_atrigd): Remove prototypes of deleted functions.
* iresolve.c (is_trig_resolved, copy_replace_function_shallow,
gfc_resolve_cotan, get_radians, get_degrees, resolve_trig_call,
gfc_resolve_atrigd, gfc_resolve_atan2d): Delete functions.
(gfc_resolve_trigd, gfc_resolve_trigd2): Resolve to library functions.
* simplify.c (rad2deg, deg2rad, gfc_simplify_acosd, gfc_simplify_asind,
gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd,
gfc_simplify_sind, gfc_simplify_tand, gfc_simplify_cotand): New
functions.
(gfc_simplify_atan2): Fix error message.
(simplify_trig_call, gfc_simplify_trigd, gfc_simplify_atrigd,
radians_f): Delete functions.
* trans-intrinsic.c: Add LIB_FUNCTION decls for sind, cosd, tand.
(rad2deg, gfc_conv_intrinsic_atrigd, gfc_conv_intrinsic_cotan,
gfc_conv_intrinsic_cotand, gfc_conv_intrinsic_atan2d): New functions.
(gfc_conv_intrinsic_function): Handle ACOSD, ASIND, ATAND, COTAN,
COTAND, ATAN2D.
* trigd_fe.inc: New file. Included by simplify.c to implement
simplify_sind, simplify_cosd, simplify_tand with code common to the
libgfortran implementation.

libgfortran/ChangeLog:

PR fortran/93871
* Makefile.am, Makefile.in: New make rule for intrinsics/trigd.c.
* gfortran.map: New routines for {sind, cosd, tand}X{r4, r8, r10, r16}.
* intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc:
New files. Defines native degree-valued trig functions.

gcc/testsuite/ChangeLog:

PR fortran/93871
* gfortran.dg/dec_math.f90: Extend coverage to real(10) and real(16).
* gfortran.dg/dec_math_2.f90: New test.
* gfortran.dg/dec_math_3.f90: Likewise.
* gfortran.dg/dec_math_4.f90: Likewise.
* gfortran.dg/dec_math_5.f90: Likewise.
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 96037629f5f..371f77be64d 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -357,6 +357,7 @@ enum gfc_isym_id
   GFC_ISYM_ACCESS,
   GFC_ISYM_ACHAR,
   GFC_ISYM_ACOS,
+  GFC_ISYM_ACOSD,
   GFC_ISYM_ACOSH,
   GFC_ISYM_ADJUSTL,
   GFC_ISYM_ADJUSTR,
@@ -369,10 +370,13 @@ enum gfc_isym_id
   GFC_ISYM_ANINT,
   GFC_ISYM_ANY,
   GFC_ISYM_ASIN,
+  GFC_ISYM_ASIND,
   GFC_ISYM_ASINH,
   GFC_ISYM_ASSOCIATED,
   GFC_ISYM_ATAN,
   GFC_ISYM_ATAN2,
+  GFC_ISYM_ATAN2D,
+  GFC_ISYM_ATAND,
   GFC_ISYM_ATANH,
   GFC_ISYM_ATOMIC_ADD,
   GFC_ISYM_ATOMIC_AND,
@@ -410,8 +414,10 @@ enum gfc_isym_id
   GFC_ISYM_CONJG,
   GFC_ISYM_CONVERSION,
   GFC_ISYM_COS,
+  GFC_ISYM_COSD,
   GFC_ISYM_COSH,
   GFC_ISYM_COTAN,
+  GFC_ISYM_COTAND,
   GFC_ISYM_COUNT,
   GFC_ISYM_CPU_TIME,
   GFC_ISYM_CSHIFT,
@@ -598,6 +604,7 @@ enum gfc_isym_id
   GFC_ISYM_SIGNAL,
   GFC_ISYM_SI_KIND,
   GFC_ISYM_SIN,
+  GFC_ISYM_SIND,
   GFC_ISYM_SINH,
   GFC_ISYM_SIZE,
   GFC_ISYM_SLEEP,
@@ -618,6 +625,7 @@ enum gfc_isym_id
   GFC_ISYM_SYSTEM,
   GFC_ISYM_SYSTEM_CLOCK,
   GFC_ISYM_TAN,
+  GFC_ISYM_TAND,
   GFC_ISYM_TANH,
   GFC_ISYM_TEAM_NUMBER,
   GFC_ISYM_THIS_IMAGE,
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 3012187ddae..17f5efc6566 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -3281,116 +3281,130 @@ add_functions (void)
 
   make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU);
 
-  if (flag_dec_math)
-{
-  add_sym_1 ("acosd", GFC_ISYM_ACOS, CLASS_ELEMENTAL, ACTUAL_YES, 

Re: PATCH -- Fix degree trignometric functions

2020-03-30 Thread Fritz Reese via Gcc-patches
On Mon, Mar 30, 2020 at 4:53 PM Tobias Burnus  wrote:
>
> Hi Fritz,
>
> On 3/30/20 10:20 PM, Fritz Reese via Fortran wrote:
>
> >>> * All included files need dependency; I do not quickly
> >>>see whether that' the case.
>
> If one looks at the build, the dependency is automatically
> obtained and tracked in …/.deps/*.Po in the build directory.
> Hence, no action needed.
>
> Cheers,
>
> Tobias

Awesome, thanks!


Fritz


Re: PATCH -- Fix degree trignometric functions

2020-03-30 Thread Tobias Burnus

Hi Fritz,

On 3/30/20 10:20 PM, Fritz Reese via Fortran wrote:


* All included files need dependency; I do not quickly
   see whether that' the case.


If one looks at the build, the dependency is automatically
obtained and tracked in …/.deps/*.Po in the build directory.
Hence, no action needed.

Cheers,

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter


Re: PATCH -- Fix degree trignometric functions

2020-03-30 Thread Fritz Reese via Gcc-patches
On Sat, Mar 28, 2020 at 12:37 PM Steve Kargl
 wrote:
>
> On Sat, Mar 28, 2020 at 08:10:38AM +0100, Tobias Burnus wrote:
> > Two remarks:
> >
> > * As the file trigd_lib.inc is shared between libgfortran
> >   and gcc/fortran, I wonder whether it should be placed
> >   under include/ (under the GCC toplevel directroy)
>
> The original name and location were chosen to match
> intrinsics/erfc_scaled_inc.c, which is included in
> intrinsics/erfc_scaled.c.  I think Fritz's re-use
> in simplification makes since given the ugly nested
> if-elseif-else constructs in the file.  As this is
> Fortran specific, I do not believe it should be moved
> up to a toplevel diretory.

I'm ambivalent about the location, though it is Fortran-specific.

> > * All included files need dependency; I do not quickly
> >   see whether that' the case.

Yes, I'd like to add a dependency for them as rebuilding after a
change is a pain. I've not yet decoded the Make-fu involved, but I
will be sure to add them for the final patch.

Thanks for the feedback, Tobias.

---
Fritz


Re: PATCH -- Fix degree trignometric functions

2020-03-28 Thread Steve Kargl via Gcc-patches
On Sat, Mar 28, 2020 at 08:10:38AM +0100, Tobias Burnus wrote:
> Two remarks:
> 
> * As the file trigd_lib.inc is shared between libgfortran
>   and gcc/fortran, I wonder whether it should be placed
>   under include/ (under the GCC toplevel directroy)

The original name and location were chosen to match
intrinsics/erfc_scaled_inc.c, which is included in
intrinsics/erfc_scaled.c.  I think Fritz's re-use
in simplification makes since given the ugly nested
if-elseif-else constructs in the file.  As this is
Fortran specific, I do not believe it should be moved
up to a toplevel diretory.

> 
> * All included files need dependency; I do not quickly
>   see whether that' the case.


They do?  See intrinsics/erfc_scaled*.c.

% grep erfc_ Makefile.am
intrinsics/erfc_scaled.c \

-- 
steve


Re: PATCH -- Fix degree trignometric functions

2020-03-28 Thread Tobias Burnus

Two remarks:

* As the file trigd_lib.inc is shared between libgfortran
  and gcc/fortran, I wonder whether it should be placed
  under include/ (under the GCC toplevel directroy)

* All included files need dependency; I do not quickly
  see whether that' the case.

Cheers,

Tobias

On 3/28/20 12:36 AM, Fritz Reese via Fortran wrote:


On Fri, Mar 6, 2020 at 6:18 PM Steve Kargl
 wrote:
[...]

TL;DR version.

   Fix the simplification and handling of the degree trigonometric functions.
   This includes fixing a number of ICEs.  See PR 93871.

An updated version of the patch is attached. Regression tests (and new
test cases) are pending.

Changes since Steve's patch of note:

* libgfortran/intrinsics/trigd.c now indirectly includes trigd.inc
(formerly trigd_inc.c) through trigd_lib.inc. trigd.inc is now written
using GMP/MPFR functions, so that the same file can be included from
the front-end for simplification. The GMP/MPFR functions are
pre-processed into native code by trigd_lib.inc. This ensures that
both the FE and the library are using the same code for resolving
these functions, preventing future maintenance woes.

* TAND(90, 270) returns +Infinity and -Infinity, instead of NaN. This
is compatible with behavior of (at least some) DEC compilers.

* COTAN[D] are implemented as -TAN[D](x + 90 degrees) rather than 1 /
COTAN[D] for speed and to avoid singularities (though the new
implementation of TAND allows 1 / TAND to return zero when TAND
returns infinity).

* SMALL thresholds and signs of some specific values are corrected.
For REAL(10) and REAL(16), the SMALL threshold for SIND(x) = D2R(x) is
eliminated, since there would be loss of precision. The other
thresholds achieve COSD(x) = 1 and SIND(x) = D2R(x) without loss of
precision.

ChangeLogs are below. I will post an update soon after I perform
regression tests, which include some new tests which I will add.

gcc/fortran/ChangeLog:

 PR fortran/93871

 * gfortran.h (GFC_ISYM_ACOSD, GFC_ISYM_ASIND, GFC_ISYM_ATAN2D,
 GFC_ISYM_ATAND, GFC_ISYM_COSD, GFC_ISYM_COTAND, GFC_ISYM_SIND,
 GFC_ISYM_TAND): New.
 * intrinsic.c (add_functions): Remove check for flag_dec_math.
 Give degree trig functions simplification and name resolution
 functions (e.g, gfc_simplify_atrigd () and gfc_resolve_atrigd ()).
 (do_simplify): Remove special casing of degree trig functions.
 * intrinsic.h (gfc_simplify_acosd, gfc_simplify_asind,
 gfc_simplify_atand, gfc_simplify_cosd, gfc_simplify_cotand,
 gfc_simplify_sind, gfc_simplify_tand, gfc_resolve_trigd2): Add new
 prototypes.
 (gfc_simplify_atrigd, gfc_simplify_trigd, gfc_resolve_cotan,
 resolve_atrigd): Remove prototypes of deleted functions.
 * iresolve.c (is_trig_resolved, copy_replace_function_shallow,
 gfc_resolve_cotan, get_radians, get_degrees, resolve_trig_call,
 gfc_resolve_atrigd, gfc_resolve_atan2d): Delete functions.
 (gfc_resolve_trigd, gfc_resolve_trigd2): Resolve to library functions.
 * simplify.c (rad2deg, deg2rad, gfc_simplify_acosd, gfc_simplify_asind,
 gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd,
 gfc_simplify_sind, gfc_simplify_tand, gfc_simplify_cotand): New
 functions.
 (gfc_simplify_atan2): Fix error message.
 (simplify_trig_call, gfc_simplify_trigd, gfc_simplify_atrigd,
 radians_f): Delete functions.
 * trans-intrinsic.c: Add LIB_FUNCTION decls for sind, cosd, tand.
 (rad2deg, gfc_conv_intrinsic_atrigd, gfc_conv_intrinsic_cotan,
 gfc_conv_intrinsic_cotand, gfc_conv_intrinsic_atan2d): New functions.
 (gfc_conv_intrinsic_function): Handle ACOSD, ASIND, ATAND, COTAN,
 COTAND, ATAN2D.
 * trigd_fe.inc: New file. Included by simplify.c to implement
 simplify_sind, simplify_cosd, simplify_tand with code common to the
 libgfortran implementation.

libgfortran/ChangeLog:

 PR fortran/93871
 * Makefile.am, Makefile.in: New make rule for intrinsics/trigd.c.
 * gfortran.map: New routines for {sind, cosd, tand}X{r4, r8, r10, r16}.
 * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc:
 New files. Defines native degree-valued trig functions.


Re: PATCH -- Fix degree trignometric functions

2020-03-27 Thread Fritz Reese via Gcc-patches
On Fri, Mar 6, 2020 at 6:18 PM Steve Kargl
 wrote:
[...]
> TL;DR version.
>
>   Fix the simplification and handling of the degree trigonometric functions.
>   This includes fixing a number of ICEs.  See PR 93871.

An updated version of the patch is attached. Regression tests (and new
test cases) are pending.

Changes since Steve's patch of note:

* libgfortran/intrinsics/trigd.c now indirectly includes trigd.inc
(formerly trigd_inc.c) through trigd_lib.inc. trigd.inc is now written
using GMP/MPFR functions, so that the same file can be included from
the front-end for simplification. The GMP/MPFR functions are
pre-processed into native code by trigd_lib.inc. This ensures that
both the FE and the library are using the same code for resolving
these functions, preventing future maintenance woes.

* TAND(90, 270) returns +Infinity and -Infinity, instead of NaN. This
is compatible with behavior of (at least some) DEC compilers.

* COTAN[D] are implemented as -TAN[D](x + 90 degrees) rather than 1 /
COTAN[D] for speed and to avoid singularities (though the new
implementation of TAND allows 1 / TAND to return zero when TAND
returns infinity).

* SMALL thresholds and signs of some specific values are corrected.
For REAL(10) and REAL(16), the SMALL threshold for SIND(x) = D2R(x) is
eliminated, since there would be loss of precision. The other
thresholds achieve COSD(x) = 1 and SIND(x) = D2R(x) without loss of
precision.

ChangeLogs are below. I will post an update soon after I perform
regression tests, which include some new tests which I will add.

gcc/fortran/ChangeLog:

PR fortran/93871

* gfortran.h (GFC_ISYM_ACOSD, GFC_ISYM_ASIND, GFC_ISYM_ATAN2D,
GFC_ISYM_ATAND, GFC_ISYM_COSD, GFC_ISYM_COTAND, GFC_ISYM_SIND,
GFC_ISYM_TAND): New.
* intrinsic.c (add_functions): Remove check for flag_dec_math.
Give degree trig functions simplification and name resolution
functions (e.g, gfc_simplify_atrigd () and gfc_resolve_atrigd ()).
(do_simplify): Remove special casing of degree trig functions.
* intrinsic.h (gfc_simplify_acosd, gfc_simplify_asind,
gfc_simplify_atand, gfc_simplify_cosd, gfc_simplify_cotand,
gfc_simplify_sind, gfc_simplify_tand, gfc_resolve_trigd2): Add new
prototypes.
(gfc_simplify_atrigd, gfc_simplify_trigd, gfc_resolve_cotan,
resolve_atrigd): Remove prototypes of deleted functions.
* iresolve.c (is_trig_resolved, copy_replace_function_shallow,
gfc_resolve_cotan, get_radians, get_degrees, resolve_trig_call,
gfc_resolve_atrigd, gfc_resolve_atan2d): Delete functions.
(gfc_resolve_trigd, gfc_resolve_trigd2): Resolve to library functions.
* simplify.c (rad2deg, deg2rad, gfc_simplify_acosd, gfc_simplify_asind,
gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd,
gfc_simplify_sind, gfc_simplify_tand, gfc_simplify_cotand): New
functions.
(gfc_simplify_atan2): Fix error message.
(simplify_trig_call, gfc_simplify_trigd, gfc_simplify_atrigd,
radians_f): Delete functions.
* trans-intrinsic.c: Add LIB_FUNCTION decls for sind, cosd, tand.
(rad2deg, gfc_conv_intrinsic_atrigd, gfc_conv_intrinsic_cotan,
gfc_conv_intrinsic_cotand, gfc_conv_intrinsic_atan2d): New functions.
(gfc_conv_intrinsic_function): Handle ACOSD, ASIND, ATAND, COTAN,
COTAND, ATAN2D.
* trigd_fe.inc: New file. Included by simplify.c to implement
simplify_sind, simplify_cosd, simplify_tand with code common to the
libgfortran implementation.

libgfortran/ChangeLog:

PR fortran/93871
* Makefile.am, Makefile.in: New make rule for intrinsics/trigd.c.
* gfortran.map: New routines for {sind, cosd, tand}X{r4, r8, r10, r16}.
* intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc:
New files. Defines native degree-valued trig functions.
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 96037629f5f..371f77be64d 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -357,6 +357,7 @@ enum gfc_isym_id
   GFC_ISYM_ACCESS,
   GFC_ISYM_ACHAR,
   GFC_ISYM_ACOS,
+  GFC_ISYM_ACOSD,
   GFC_ISYM_ACOSH,
   GFC_ISYM_ADJUSTL,
   GFC_ISYM_ADJUSTR,
@@ -369,10 +370,13 @@ enum gfc_isym_id
   GFC_ISYM_ANINT,
   GFC_ISYM_ANY,
   GFC_ISYM_ASIN,
+  GFC_ISYM_ASIND,
   GFC_ISYM_ASINH,
   GFC_ISYM_ASSOCIATED,
   GFC_ISYM_ATAN,
   GFC_ISYM_ATAN2,
+  GFC_ISYM_ATAN2D,
+  GFC_ISYM_ATAND,
   GFC_ISYM_ATANH,
   GFC_ISYM_ATOMIC_ADD,
   GFC_ISYM_ATOMIC_AND,
@@ -410,8 +414,10 @@ enum gfc_isym_id
   GFC_ISYM_CONJG,
   GFC_ISYM_CONVERSION,
   GFC_ISYM_COS,
+  GFC_ISYM_COSD,
   GFC_ISYM_COSH,
   GFC_ISYM_COTAN,
+  GFC_ISYM_COTAND,
   GFC_ISYM_COUNT,
   GFC_ISYM_CPU_TIME,
   GFC_ISYM_CSHIFT,
@@ -598,6 +604,7 @@ enum gfc_isym_id
   GFC_ISYM_SIGNAL,
   GFC_ISYM_SI_KIND,
   GFC_ISYM_SIN,
+  GFC_ISYM_SIND,
   GFC_ISYM_SINH,
   GFC_ISYM_SIZE,
   GFC_ISYM_SLEEP,

Re: PATCH -- Fix degree trignometric functions

2020-03-09 Thread Fritz Reese
On Sat, Mar 7, 2020 at 1:32 PM Steve Kargl
 wrote:
>
> Fix the simplification and handling of the degree trigonometric functions.
>  This includes fixing a number of ICEs.  See PR 93871.
>
>  ChangeLog and patch attached.

As the author of the original degree-trig functions I intend to review
this patch soon, and...

> On Fri, Mar 06, 2020 at 03:18:19PM -0800, Steve Kargl wrote:
> >
> >   3. Simplification routines do the following mappings:
> >  sind(x) = sin((pi/180) * x) asind(x) = (180/pi) * asin(x)
> >  cosd(x) = cos((pi/180) * x) acosd(x) = (180/pi) * acos(x)
> >  tand(x) = tan((pi/180) * x) atand(x) = (180/pi) * atan(x)
> >  atan2d(y,x) = (180/pi) * atan2(y,x)
> >  cotand(x) = cotan((pi/180) * x)
> >  All computations are carried out by MPFR or MPC.
>
> In looking at some basic tests, the above simplification will
> need to be modified to do what ...
>
>
> >   5. New functions have been added to libgfortran to handle sind, cosd,
> >  and tand.
>
> ... these functions do.  Otherwise, things like cos(real(60+123*360))
> give wrong values.  Modifications are so easy even a lurker can do
> them.

... extend the patch to include these changes (unless someone
enthusiastic gets around to these mods before I do).

I should be able to start on this next week (around 16 March).

---
Fritz Reese


Re: PATCH -- Fix degree trignometric functions

2020-03-07 Thread Steve Kargl
On Fri, Mar 06, 2020 at 03:18:19PM -0800, Steve Kargl wrote:
> 
>   3. Simplification routines do the following mappings:
>  sind(x) = sin((pi/180) * x) asind(x) = (180/pi) * asin(x)
>  cosd(x) = cos((pi/180) * x) acosd(x) = (180/pi) * acos(x)
>  tand(x) = tan((pi/180) * x) atand(x) = (180/pi) * atan(x)
>  atan2d(y,x) = (180/pi) * atan2(y,x)
>  cotand(x) = cotan((pi/180) * x)
>  All computations are carried out by MPFR or MPC.

In looking at some basic tests, the above simplification will
need to be modified to do what ...


>   5. New functions have been added to libgfortran to handle sind, cosd,
>  and tand.

... these functions do.  Otherwise, things like cos(real(60+123*360))
give wrong values.  Modifications are so easy even a lurker can do
them.

-- 
steve