User account creation filtered due to spam.

Bug 33197 - Fortran 2008: math functions
Summary: Fortran 2008: math functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 36096 36158
Blocks: 39627
  Show dependency treegraph
 
Reported: 2007-08-26 18:24 UTC by Tobias Burnus
Modified: 2010-08-27 19:20 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-27 18:37:40


Attachments
Patch for some of these points (5.66 KB, patch)
2008-02-17 16:01 UTC, Francois-Xavier Coudert
Details | Diff
Complex (A)TAN(H), (A)COSH, (A)SINH, without no-C99 fallback & w/o tests (2.10 KB, patch)
2009-02-17 20:58 UTC, Tobias Burnus
Details | Diff
Test implementation in C for complex arc{tan,sin,cos}{,h} (3.59 KB, text/plain)
2009-07-10 15:45 UTC, Tobias Burnus
Details
Draft patch for NORM2 -- and draft run-time test, early PARITY patch (15.16 KB, patch)
2010-08-22 19:32 UTC, Tobias Burnus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-08-26 18:24:59 UTC
Split of from PR32980 (collected by FX and me)

Fortran 2008 status: http://www.nag.co.uk/sc22wg5/ ; time table:
   First working draft available                     2007-12
   WG5 review of working draft                       2008-02
   WG5 approval of draft CD                          2008-04
   First CD submitted for registration and approval  2008-05
   First CD ballot initiated                         2008-05
   First CD ballot comments available                2008-10
   WG5 ballot resolution meeting                     2008-11
   WG5 review meeting                                2009-05
   Final CD submitted for approval                   2009-07
(The question is when we should start supporting Fortran 2008 (-std=f2008) / Fortran 2008 features (as -std=gnu).)

Currently proposed additional intrinsic procedures:

- ACOSH, ASINH, ATANH, ERF, ERF_C, GAMMA: Exist in gfortran (STD_GNU)
- BESSEL_J0, _J1, _JN, _Y0, _Y1, _YN: Exist as BESJ0 etc.
- log_gamma: Exists as lgamma
- Not in gfortran: ERFC_SCALED (Exponentially scaled ERFC), HYPOT (= sqrt(x**2+y**2)), NORM2  (L_2 norm).

(For erfc_scaled: Needs a library function; see e.g. http://www.netlib.org/specfun/erf)

- "The intrinsic function ATAN is extended so that ATAN (Y, X) is ATAN2 (Y,X)."
- -stf=f2008 needs to be supported
- File extensions .f08
- Fortran 2008 allows "CONTAINS" with no procedures following in PROGRAM and MODULE. (Change STD_GNU to STD_F2008.)
Comment 1 Francois-Xavier Coudert 2008-02-17 16:01:11 UTC
Created attachment 15177 [details]
Patch for some of these points

This patch adds all new intrinsics listed in the report except NORM2, and the modification to ATAN that adds a second, optional argument. It adds support for -std=2008 and empty CONTAINS. It includes a library support function for ERFC_SCALED, which is a C translation of the Netlib routine.
Comment 2 Tobias Burnus 2008-02-17 18:51:33 UTC
+#define GFC_STD_F2008	(1<<7)	/* New in F2008.  */
 #define GFC_STD_LEGACY	(1<<6)	/* Backward compatibility.  */
 #define GFC_STD_GNU	(1<<5)	/* GNU Fortran extension.  */
 #define GFC_STD_F2003	(1<<4)	/* New in F2003.  */

I fear this will break some std tests. You should better use:

 #define GFC_STD_LEGACY	(1<<7)	/* Backward compatibility.  */
 #define GFC_STD_GNU	(1<<6)	/* GNU Fortran extension.  */
 #define GFC_STD_F2008	(1<<5)	/* New in F2008.  */
 #define GFC_STD_F2003	(1<<4)	/* New in F2003.  */

which is also more readable - especially when we will have F2013 etc.

decl.c also contains two STD_F2008: "Fortran 2008 draft allows BIND(C) for internal procedures.".

Additionally, one needs to update *texi for the new -std=f2008 option.

Also the .F08/.f08 should be supported, cf.
http://gcc.gnu.org/ml/fortran/2007-01/msg00410.html
and note that also the CPP section has to updated.
Comment 3 Francois-Xavier Coudert 2008-02-17 18:56:52 UTC
(In reply to comment #2)
> I fear this will break some std tests. You should better use:
> 
>  #define GFC_STD_LEGACY (1<<7)  /* Backward compatibility.  */
>  #define GFC_STD_GNU    (1<<6)  /* GNU Fortran extension.  */
>  #define GFC_STD_F2008  (1<<5)  /* New in F2008.  */
>  #define GFC_STD_F2003  (1<<4)  /* New in F2003.  */

It shouldn't break any tests if they're well written, so it gives us an opportunity to check that :)
Also, and more importantly, what you suggest means breaking the ABI, because this information is passed to libgfortran.
Comment 4 Tobias Burnus 2008-02-17 19:08:31 UTC
Of cause, also the added/modified intrinsics mandate a *texi update.
BTW: Thanks for the patch.

(In reply to comment #3)
> It shouldn't break any tests if they're well written, so it gives us an
> opportunity to check that :) Also, and more importantly, what you suggest 
> means breaking the ABI, because this information is passed to libgfortran.

Forgot that :-/  Actually, I think the tests are better written than I remembered - at least I could not find "std < GFC_..." only
"gfc_option.allow_std & GFC_STD_*".
Comment 5 Tobias Burnus 2008-02-19 16:14:29 UTC
New version of the Fortran 2008 draft (candiate draft, before was working draft):
ftp://ftp.nag.co.uk/sc22wg5/N1701-N1750/N1718.pdf
http://www.nag.co.uk/sc22wg5/
Thus things should be settled enough for this patch.
Comment 6 Francois-Xavier Coudert 2008-02-27 21:02:33 UTC
Two more remarks on that: ASINH, ACOSH and ATANH need to accept COMPLEX arguments. Some other functions also should be extended that way (ASIN, ACOS... and probably many more).

Also, one very annoying feature: BESSEL_JN and BESSEL_YN have two forms, with 2 or 3 arguments. What's more, these two forms have very different properties (the first one is elemental, the second one is transformational), and I don't know how to implement that in the current handling of intrinsics!
Comment 7 Francois-Xavier Coudert 2008-02-28 17:57:15 UTC
One more remark: checking of intrinsics and compliance to the -std option specified is lacking, and this is a generic issue of gfortran. Maybe there's a PR open about it?
Comment 8 Francois-Xavier Coudert 2008-03-03 23:46:57 UTC
Subject: Bug 33197

Author: fxcoudert
Date: Mon Mar  3 23:46:20 2008
New Revision: 132846

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132846
Log:
	PR fortran/33197

gcc/fortran/
	* intrinsic.c (add_functions): Modify intrinsics ACOSH, ASINH,
	ATANH, ERF, ERFC and GAMMA. Add intrinsics BESSEL_{J,Y}{0,1,N},
	ERFC_SCALED, LOG_GAMMA and HYPOT.
	* intrinsic.h (gfc_check_hypot, gfc_simplify_hypot,
	gfc_resolve_hypot): New prototypes.
	* mathbuiltins.def: Add HYPOT builtin. Make complex versions of
	ACOSH, ASINH and ATANH available.
	* gfortran.h (GFC_ISYM_ERFC_SCALED, GFC_ISYM_HYPOT): New values.
	* lang.opt: Add -std=f2008 option.
	* libgfortran.h: Define GFC_STD_F2008.
	* lang-specs.h: Add .f08 and .F08 file suffixes.
	* iresolve.c (gfc_resolve_hypot): New function.
	* parse.c (parse_contained): Allow empty CONTAINS for Fortran 2008.
	* check.c (gfc_check_hypot): New function.
	* trans-intrinsic.c (gfc_intrinsic_map): Define ERFC_SCALE builtin.
	* options.c (set_default_std_flags): Allow Fortran 2008 by default.
	(form_from_filename): Add .f08 suffix.
	(gfc_handle_option): Handle -std=f2008 option.
	* simplify.c (gfc_simplify_hypot): New function.
	* gfortran.texi: Document Fortran 2008 status and file extensions.
	* intrinsic.texi: Document new BESSEL_{J,Y}{0,1,N} intrinsics,
	as well as HYPOT and ERFC_SCALED. Update documentation of ERF,
	ERFC, GAMMA, LGAMMA, ASINH, ACOSH and ATANH.
	* invoke.texi: Document the new -std=f2008 option.

libgomp/
	* testsuite/libgomp.fortran/fortran.exp: Add .f08 and
	.F08 file suffixes.

gcc/testsuite/
	* gfortran.dg/gomp/gomp.exp: Add .f08 and .F08 file suffixes.
	* gfortran.dg/dg.exp: Likewise.
	* gfortran.dg/vect/vect.exp: Likewise.
	* gfortran.fortran-torture/execute/execute.exp: Likewise.
	* gfortran.fortran-torture/compile/compile.exp: Likewise.
	* gfortran.dg/gamma_1.f90: Also check log_gamma.
	* gfortran.dg/invalid_contains_1.f90: Remove warning about
	empty CONTAINS.
	* gfortran.dg/gamma_2.f90: Add a few error messages.
	* gfortran.dg/invalid_contains_2.f90: Remove warning about
	empty CONTAINS.
	* gfortran.dg/gamma_3.f90: Adjust error message.
	* gfortran.dg/gamma_4.f90: Test for log_gamma instead of lgamma.
	* gfortran.dg/bind_c_usage_9.f03: Adjust error messages.
	* gfortran.dg/bessel_1.f90: New test.
	* gfortran.dg/recursive_check_3.f90: Remove warnings.
	* gfortran.dg/besxy.f90: Also check for new F2008 intrinsics.
	* gfortran.dg/derived_function_interface_1.f90: Remove warning.
	* gfortran.dg/contains_empty_1.f03: New test.
	* gfortran.dg/erfc_scaled_1.f90: New test.
	* gfortran.dg/hypot_1.f90: New test.
	* gfortran.dg/contains_empty_2.f03: New test.

libgfortran/
	* intrinsics/erfc_scaled_inc.c: New file.
	* intrinsics/erfc_scaled.c: New file.
	* gfortran.map (GFORTRAN_1.0): Add _gfortran_erfc_scaled_r*.
	* Makefile.am: Add intrinsics/erfc_scaled.c.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

Added:
    trunk/gcc/testsuite/gfortran.dg/bessel_1.f90
    trunk/gcc/testsuite/gfortran.dg/contains_empty_1.f03
    trunk/gcc/testsuite/gfortran.dg/contains_empty_2.f03
    trunk/gcc/testsuite/gfortran.dg/erfc_scaled_1.f90
    trunk/gcc/testsuite/gfortran.dg/hypot_1.f90
    trunk/libgfortran/intrinsics/erfc_scaled.c
    trunk/libgfortran/intrinsics/erfc_scaled_inc.c
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/gfortran.texi
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/invoke.texi
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/lang-specs.h
    trunk/gcc/fortran/lang.opt
    trunk/gcc/fortran/libgfortran.h
    trunk/gcc/fortran/mathbuiltins.def
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/besxy.f90
    trunk/gcc/testsuite/gfortran.dg/bind_c_usage_9.f03
    trunk/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90
    trunk/gcc/testsuite/gfortran.dg/dg.exp
    trunk/gcc/testsuite/gfortran.dg/gamma_1.f90
    trunk/gcc/testsuite/gfortran.dg/gamma_2.f90
    trunk/gcc/testsuite/gfortran.dg/gamma_3.f90
    trunk/gcc/testsuite/gfortran.dg/gamma_4.f90
    trunk/gcc/testsuite/gfortran.dg/gomp/gomp.exp
    trunk/gcc/testsuite/gfortran.dg/invalid_contains_1.f90
    trunk/gcc/testsuite/gfortran.dg/invalid_contains_2.f90
    trunk/gcc/testsuite/gfortran.dg/recursive_check_3.f90
    trunk/gcc/testsuite/gfortran.dg/vect/vect.exp
    trunk/gcc/testsuite/gfortran.fortran-torture/compile/compile.exp
    trunk/gcc/testsuite/gfortran.fortran-torture/execute/execute.exp
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in
    trunk/libgfortran/config.h.in
    trunk/libgfortran/configure
    trunk/libgfortran/gfortran.map
    trunk/libgomp/ChangeLog
    trunk/libgomp/testsuite/libgomp.fortran/fortran.exp

Comment 9 Francois-Xavier Coudert 2008-03-03 23:51:28 UTC
Tobias noted the following also need updating:

3999:      /* Fortran 2008 draft allows BIND(C) for internal procedures.  */
4000-      if (gfc_current_state () == COMP_CONTAINS
4001-     && sym->ns->proc_name->attr.flavor != FL_MODULE
4002-     && gfc_notify_std (GFC_STD_GNU, "Extension: BIND(C) attribute at %L "
4003-                        "may not be specified for an internal procedure",
--
4733:      /* The following is allowed in the Fortran 2008 draft.  */
4734-      if (gfc_current_state () == COMP_CONTAINS
4735-     && sym->ns->proc_name->attr.flavor != FL_MODULE
4736-     && gfc_notify_std (GFC_STD_GNU, "Extension: BIND(C) attribute at "
4737-                        "%L may not be specified for an internal procedure",

ERF and ERFC should be simplified, it's easy since MPFR has these functions.

And, quoting my comment #6:
"Two more remarks on that: ASINH, ACOSH and ATANH need to accept COMPLEX
arguments. Some other functions also should be extended that way (ASIN, ACOS...
and probably many more).

Also, one very annoying feature: BESSEL_JN and BESSEL_YN have two forms, with 2
or 3 arguments. What's more, these two forms have very different properties
(the first one is elemental, the second one is transformational), and I don't
know how to implement that in the current handling of intrinsics!"
Comment 10 Francois-Xavier Coudert 2008-03-04 14:21:37 UTC
A bit of experimentation reveals that we can use the asymptotic expression at http://en.wikipedia.org/wiki/Error_function#Asymptotic_expansion for arguments larger than 7, and it does converge with less than 100 terms (for x86 long double, arg = 7.0 requires 30 terms, arg = 8.0 requires 22, arg = 10.0 requires 16 and arg = 18.0 requires 10 terms; allow a bit more for ppc long doubles). So, I rank this as costly but doable, and we frankly don't care too much about the cost at the moment (people relying on heavy simplification of ERFC_SCALED intrinsic, well... I don't see that coming too soon). For smaller arguments, using mpfr_erfc and mpfr_exp should be fine. Does that sound like a plan?
Comment 11 Francois-Xavier Coudert 2008-03-04 14:26:02 UTC
On ppc longdouble, convergence requires argument >= 8.6 and, again, less than 100 terms. Why does convergence radius depend on the format of the floating-point type, I wonder... For the record, here's the small C program I use for testing:

#include <math.h>
#include <float.h>
#include <stdio.h>

#define PI 3.1415926535897932384626433832795029L

extern long double asympt (long double);

long double asympt (long double x)
{
  long double res, f, y, z;
  int n;

  y = 1 / (2 * x * x);
  z = 1;
  res = 1;
  f = 1;
  for (n = 1; n < 100; n++)
  {
    f *= 2 * n - 1;
    z *= y;
    res += (n % 2 ? -1 : 1) * f * z;
    if (f*z <= DBL_MIN)
      break;
    if (f*z <= (nextafterl (res, __builtin_infl()) - res))
      break;
  }
  if (n >= 100)
  {
    printf ("@@@@ failed\n");
    return -1;
  }

  printf ("#### %d %Lg\n", n, f*z);
  return res / (x * sqrtl (PI));
}

int main(void)
{
  int i;

  for (i = 20; i < 10000; i++)
    printf ("%Lg %Lg\n", i * 0.1L, asympt(i * 0.1L));
  return 0;
}
Comment 12 Francois-Xavier Coudert 2008-03-06 12:41:30 UTC
Subject: Bug 33197

Author: fxcoudert
Date: Thu Mar  6 12:40:28 2008
New Revision: 132970

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132970
Log:
	PR fortran/33197
	* intrinsic.c (add_functions): Add simplification routines for
	ERF, DERF, ERFC and DERFC.
	* decl.c (gfc_match_suffix, gfc_match_subroutine): Change GNU
	extensions into Fortran 2008 features.
	* intrinsic.h (gfc_simplify_erf, gfc_simplify_erfc): New
	prototypes.
	* simplify.c (gfc_simplify_erf, gfc_simplify_erfc): New functions.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/simplify.c

Comment 13 Francois-Xavier Coudert 2008-03-06 12:45:54 UTC
Remaining tasks in this PR: taking care of math functions that now accept complex args (in particular, A{SIN,COS,TAN}{,H}), taking care of the two arguments form of ATAN, and deal with the 3 args form of BESSEL_JN and BESSEL_YN.
Comment 14 Tobias Burnus 2008-03-06 13:10:18 UTC
> Remaining tasks in this PR: [...]
I think also missing are:
- Compile-time evaluation of erfc_scaled
- Implementation of NORM2
Comment 15 Francois-Xavier Coudert 2008-03-06 13:15:54 UTC
(In reply to comment #14)
> I think also missing are:
> - Compile-time evaluation of erfc_scaled

Right. A though one.

> - Implementation of NORM2

There are quite a few other new F2008 intrinsics, including other transformational intrinsics, so I think it's better to focus this PR on math intrinsics.
Comment 16 Tobias Burnus 2008-03-06 13:50:06 UTC
(In reply to comment #15)
> > - Implementation of NORM2
> There are quite a few other new F2008 intrinsics, including other
> transformational intrinsics, so I think it's better to focus this PR on math
> intrinsics.

I would regard the L2 norm as mathematical (http://mathworld.wolfram.com/L2-Norm.html)
y = NORM2(x) is for rank one arrays simply:

y = 0
do i=lbound(x,dim=1),ubound(x,dim=1)
   y = y + x(i)**2
enddo
y = sqrt(y).

For a rank-one, size-two array it is the same as hypot(x(1),x(2)). Actually, using hypot is an optimization one should do for size-2 arrays.
Comment 17 Francois-Xavier Coudert 2008-03-11 16:53:29 UTC
Adding a note: fallback formulas for systems that lack C99 complex functions can be found in Cephes (http://www.netlib.org/cephes/)
Comment 18 Tobias Burnus 2009-02-17 20:58:58 UTC
Created attachment 17315 [details]
Complex (A)TAN(H), (A)COSH, (A)SINH, without no-C99 fallback & w/o tests

"Implementation" of the run-time version of (A)TAN(H), (A)COSH, (A)SINH with complex arguments. Missing: (a) Fall back if libm does not have those C99 functions; (b) test cases; (c) compile-time evaluations -- this should use the MPC library as soon as the middle end has support for it.

TODO (carried on from above):
- TAN(X,Y)  (= TAN2(X,Y))
- BESSEL_JN and BESSEL_YN: Transitional form is missing
- ERFC_SCALED: compile-time version
- NORM2
Comment 19 Francois-Xavier Coudert 2009-05-02 13:46:51 UTC
Patch submitted for review for the ERFC_SCALED compile-time version here: http://gcc.gnu.org/ml/fortran/2009-05/msg00012.html
Comment 20 Francois-Xavier Coudert 2009-05-16 17:33:35 UTC
Subject: Bug 33197

Author: fxcoudert
Date: Sat May 16 17:33:23 2009
New Revision: 147621

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147621
Log:
	PR fortran/33197

	* intrinsic.c (add_functions): Use ERFC_SCALED simplification.
	* intrinsic.h (gfc_simplify_erfc_scaled): New prototype.
	* simplify.c (fullprec_erfc_scaled, asympt_erfc_scaled,
	gfc_simplify_erfc_scaled): New functions.

	* gfortran.dg/erf_2.F90: New test.
	* gfortran.dg/erfc_scaled_2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/erf_2.F90
    trunk/gcc/testsuite/gfortran.dg/erfc_scaled_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 21 Francois-Xavier Coudert 2009-05-16 18:09:58 UTC
ERFC_SCALED compile-time simplification was committed.

TODO (carried on from above):
- TAN(X,Y)  (= TAN2(X,Y))
- BESSEL_JN and BESSEL_YN: Transitional form is missing
- NORM2
- Finish complex (A)TAN(H), (A)COSH, (A)SINH, from comment #18
Comment 22 Tobias Burnus 2009-07-10 11:46:34 UTC
For z a complex number: Patch for tan(z), sinh(z), cosh(z), tanh(z) - see at
http://gcc.gnu.org/ml/fortran/2009-07/msg00071.html

Remark: atan(z), asin(z) and acos(z) are also missing besides a{sin,cos,tan}h.

Additionally, I think the description for ATAN2 in the gfortran manual is wrong:
  "ATAN2(Y, X) computes the arctangent of the complex number X + i Y"
while the standard has:
  "The result has a value equal ... to the principal value of the argument of the complex number (X, Y), expressed in radians."
That is: atan2(y, x) = Pr arg(x+iy) = Arg(x+iy) =/= ATAN(X+i Y).

 * * *

Fallback implementations via complex logarithm: I have no idea about NaN, Inf etc. nor about the precision (I do not know how precise the fall back needs to be), but Abramowitz & Stegun has the following:

a{tan,sin,cos}: http://www.iopb.res.in/~somen/abramowitz_and_stegun/page_80.htm and http://en.wikipedia.org/wiki/Arctangent#Logarithmic_forms

a{sin,tan,cos}h: http://www.iopb.res.in/~somen/abramowitz_and_stegun/page_87.htm  However, the equations might need to be slightly for complex arguments as written at http://en.wikipedia.org/wiki/Inverse_hyperbolic_function#Logarithmic_representation
Comment 23 Tobias Burnus 2009-07-10 15:45:00 UTC
Created attachment 18173 [details]
Test implementation in C for complex arc{tan,sin,cos}{,h}

> Fallback implementations via complex logarithm

Attached is an implementation of the complex arc{tan,sin,cos}{,h} using complex log and complex sqrt; plus test cases comparing to libc version; plus result on my system with Mathematica comparison).

The test show that the result is good unless either value is Inf. In that case, NaN is returned instead of the proper result. The GLIBC also has problems, often it returns "(something,Inf)" instead of "(0, Inf)".

The question is whether this is good enough for whether one needs a special case for +/-Inf at the real/imaginary part. (Note: I only looked at (0,Inf), (Inf,0), (Inf,Inf) and not at (Inf,finite) etc.)

FX: If you are interested in creating a fall-back version for libgfortran ...
Comment 24 Tobias Burnus 2009-07-10 16:17:39 UTC
Regarding expressions with Inf with x being finite according to Mathematica 7:
ArcSin (+/-Inf,x) = (0, -/+Inf)
ArcSin (x,+/-Inf) = (0, +/-Inf)
ArcCos (+/-Inf,x) = (0, +/-Inf)
ArcCos (x,+/-Inf) = (0, -/+Inf)
ArcTan (+/-Inf,x) = (+/-Pi/2, 0)
ArcTan (x,+/-Inf) = (+/-Pi/2, 0)
ArcSinh (+/-Inf,x) = (+/-Inf,0)
ArcSinh (x,+/-Inf) = (+/-Inf,0)
ArcSinh (Inf,+/-Inf)  = (Inf,0)
ArcSinh (-Inf,+/-Inf) = (-Inf,0)
ArcCosh (+/-Inf,x) = (Inf,0)
ArcCosh (x,+/-Inf) = (Inf,0)
ArcTanh (+/-Inf,x) = (0,-/+Pi/2)
ArcTanh (x,+/-Inf) = (0,-/+Pi/2)

(For ArcSin, ArcCos, ArcTan, ArcCosh and ArcTanh an expression was returned for (Inf,Inf).)
Comment 25 Tobias Burnus 2009-07-11 00:03:26 UTC
Subject: Bug 33197

Author: burnus
Date: Sat Jul 11 00:03:07 2009
New Revision: 149503

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149503
Log:
2009-07-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * check.c (gfc_check_fn_rc2008): New function.
        * intrinsic.h (gfc_check_fn_rc2008): New prototype.
        * intrinsic.c (add_functions): Add complex tan, cosh, sinh,
        and tanh.

2009-07-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * gfortran.dg/complex_intrinsic_3.f90: New test.
        * gfortran.dg/complex_intrinsic_4.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/complex_intrinsic_3.f90
    trunk/gcc/testsuite/gfortran.dg/complex_intrinsic_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/testsuite/ChangeLog

Comment 26 Tobias Burnus 2009-07-14 07:43:45 UTC
Patch: http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00739.html
- MPC compile-time evaluation of complex tan and sinh/cosh/tanh
- Run-time complex a(sin,cos,tan)(h) with C99 fallback (for finite values only)

TODO:
- Check-in the patch above
- Support infinite arguments in the fallback?
- TAN(X,Y)  (= TAN2(X,Y)) - and fix wrong TAN2 description in the docs
- BESSEL_JN and BESSEL_YN: Transitional form is missing
- NORM2
Comment 27 kargl 2009-07-15 02:36:49 UTC
(In reply to comment #26)
> Patch: http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00739.html
> - MPC compile-time evaluation of complex tan and sinh/cosh/tanh
> - Run-time complex a(sin,cos,tan)(h) with C99 fallback (for finite values only)
> 
> TODO:
> - Check-in the patch above

If no one else gets to a review by the weekend, I try to get one 
done.  In a quick scan of the patch, I note that the mpfr versions
of the simplifications weren't in the patch. I'll do those later.

Comment 28 Tobias Burnus 2009-07-15 06:08:19 UTC
> In a quick scan of the patch, I note that the mpfr versions
> of the simplifications weren't in the patch.

MPFR or MPC? The MPFR version should be there since years; the MPC version of tan/sinh/cosh/tanh should be there (FX patch which is part of this patch) and the MPC version of a{sin,cos,tan}{,h} does not exist, yet:
http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/TODO?root=mpc&view=markup

Comment 29 Tobias Burnus 2009-07-25 19:39:20 UTC
Subject: Bug 33197

Author: burnus
Date: Sat Jul 25 19:39:07 2009
New Revision: 150087

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150087
Log:
2009-07-25  Tobias Burnus  <burnus@net-b.de>
            Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        PR fortran/33197
        * intrinsic.c (add_functions): Support complex arguments for
        acos,acosh,asin,asinh,atan,atanh.
        * invoke.texi (ACOS,ACOSH,ASIN,ASINH,ATAN,ATANH): Support
        complex arguments.
        * simplify.c (gfc_simplify_acos,gfc_simplify_acosh,
        gfc_simplify_asin,gfc_simplify_asinh,gfc_simplify_atan,
        gfc_simplify_atanh,gfc_simplify_atan,gfc_simplify_asinh,
        gfc_simplify_acosh,gfc_simplify_atanh): Support
        complex arguments.

2009-07-25  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * intrinsics/c99_functions.c (cacosf,cacos,cacosl,casinf,
        casin,casind,catanf,catan,catanl,cacoshf,cacosh,cacoshl,
        casinhf,casinh,casinhf,catanhf,catanh,catanhl): New functions.
        * c99_protos.h: Add prototypes for those.

2009-07-25  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * gfortran.dg/complex_intrinsic_5.f90: New test.
        * gfortran.dg/complex_intrinsic_7.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/complex_intrinsic_5.f90
    trunk/gcc/testsuite/gfortran.dg/complex_intrinsic_6.f90
    trunk/gcc/testsuite/gfortran.dg/complex_intrinsic_7.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/c99_protos.h
    trunk/libgfortran/intrinsics/c99_functions.c

Comment 30 Tobias Burnus 2009-07-25 19:44:54 UTC
(Patch was approved by Steve on IRC.)

TODO (carried on):
- Support inverse functions as initialization expressions, when MPC is ready
- TAN(X,Y)  (= TAN2(X,Y)) - and fix wrong TAN2 description in intrinsic.texi
- BESSEL_JN and BESSEL_YN: Transitional form is missing
- NORM2 is missing
Comment 31 Tobias Burnus 2009-07-26 17:26:15 UTC
Subject: Bug 33197

Author: burnus
Date: Sun Jul 26 17:25:56 2009
New Revision: 150100

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150100
Log:
2009-07-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * intrinsic.c (make_generic): Remove assert as "atan" can be
        both ISYM_ATAN and ISYM_ATAN2.
        (add_functions): Add two-argument variant of ATAN.
        * intrinsic.h (gfc_check_atan_2): Add check for it.
        * intrinsic.texi (ATAN2): Correct and enhance description.
        (ATAN): Describe two-argument variant of ATAN.

2009-07-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * gfortran.dg/atan2_1.f90: New test
        * gfortran.dg/atan2_2.f90: New test


Added:
    trunk/gcc/testsuite/gfortran.dg/atan2_1.f90
    trunk/gcc/testsuite/gfortran.dg/atan2_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/testsuite/ChangeLog

Comment 32 Kaveh Ghazi 2009-10-02 03:52:18 UTC
Subject: Bug 33197

Author: ghazi
Date: Fri Oct  2 03:52:05 2009
New Revision: 152394

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152394
Log:
	PR fortran/33197
	* gfortran.h (HAVE_mpc_arc): Define.
	* simplify.c (gfc_simplify_acos): Handle complex acos.
	(gfc_simplify_acosh): Likewise for acosh.
	(gfc_simplify_asin): Likewise for asin.
	(gfc_simplify_asinh): Likewise for asinh.
	(gfc_simplify_atan): Likewise for atan.
	(gfc_simplify_atanh): Likewise for atanh.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/simplify.c

Comment 33 Daniel Franke 2010-05-02 08:47:46 UTC
TODO (carried on):
 - BESSEL_JN and BESSEL_YN: Transitional form is missing (c.f. PR36096, PR36158)
 - NORM2 is missing
Comment 34 Tobias Burnus 2010-08-19 07:28:41 UTC
Subject: Bug 33197

Author: burnus
Date: Thu Aug 19 07:28:17 2010
New Revision: 163364

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163364
Log:
2010-08-19  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36158
        PR fortran/33197
        * check.c (gfc_check_bessel_n2): New function.
        * gfortran.h (gfc_isym_id): Add GFC_ISYM_JN2 and GFC_ISYM_YN2.
        * intrinsic.c (add_functions): Add transformational version
        of the Bessel_jn/yn intrinsics.
        * intrinsic.h (gfc_check_bessel_n2,gfc_simplify_bessel_jn2,
        gfc_simplify_bessel_yn2): New prototypes.
        * intrinsic.texi (Bessel_jn, Bessel_yn): Document
        transformational variant.
        * simplify.c (gfc_simplify_bessel_jn, gfc_simplify_bessel_yn):
        Check for negative order.
        (gfc_simplify_bessel_n2,gfc_simplify_bessel_jn2,
        gfc_simplify_bessel_yn2): New functions.

2010-08-19  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36158
        PR fortran/33197
        * gfortran.dg/bessel_3.f90: New.
        * gfortran.dg/bessel_4.f90: New.
        * gfortran.dg/bessel_5.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/bessel_3.f90
    trunk/gcc/testsuite/gfortran.dg/bessel_4.f90
    trunk/gcc/testsuite/gfortran.dg/bessel_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 35 Tobias Burnus 2010-08-21 10:13:09 UTC
Subject: Bug 33197

Author: burnus
Date: Sat Aug 21 10:12:53 2010
New Revision: 163440

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163440
Log:
2010-08-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36158
        PR fortran/33197
        * intrinsic.c (add_sym): Init value attribute.
        (set_attr_value): New function.
        (add_functions) Use it and add JN/YN resolvers.
        * symbol.c (gfc_copy_formal_args_intr): Copy value attr.
        * intrinsic.h (gfc_resolve_bessel_n2): New prototype.
        * gfortran.h (gfc_intrinsic_arg): Add value attribute.
        * iresolve.c (gfc_resolve_bessel_n2): New function.
        * trans-intrinsic.c (gfc_get_symbol_for_expr): Create
        formal arg list.
        (gfc_conv_intrinsic_function,gfc_is_intrinsic_libcall):
        Add GFC_ISYM_JN2/GFC_ISYM_YN2 as case value.
        * simplify.c (): For YN set to -INF if previous values
        was -INF.
        * trans-expr.c (gfc_conv_procedure_call): Don't crash
        if sym->as is NULL.
        * iresolve.c (gfc_resolve_extends_type_of): Set the
        type of the dummy argument to the one of the actual.

2010-08-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36158
        PR fortran/33197
        * m4/bessel.m4: Implement bessel_jn and bessel_yn.
        * gfortran.map: Add the generated bessel_jn_r{4,8,10,16}
        and bessel_yn_r{4,8,10,16}.
        * Makefile.am: Add bessel.m4.
        * Makefile.in: Regenerated.
        * generated/bessel_r4.c: Generated.
        * generated/bessel_r16.c: Generated.
        * generated/bessel_r8.c: Generated.
        * generated/bessel_r10.c: Generated.

2010-08-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36158
        PR fortran/33197
        * gfortran.dg/bessel_6.f90: New.
        * gfortran.dg/bessel_7.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/bessel_6.f90
    trunk/gcc/testsuite/gfortran.dg/bessel_7.f90
    trunk/libgfortran/generated/bessel_r10.c
    trunk/libgfortran/generated/bessel_r16.c
    trunk/libgfortran/generated/bessel_r4.c
    trunk/libgfortran/generated/bessel_r8.c
    trunk/libgfortran/m4/bessel.m4
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in
    trunk/libgfortran/gfortran.map

Comment 36 Tobias Burnus 2010-08-21 10:35:33 UTC
TODO (carried on):

- NORM2 (L2 norm).

For size-2, one should simply call HYPOT.
Comment 37 Tobias Burnus 2010-08-22 19:32:07 UTC
Created attachment 21545 [details]
Draft patch for NORM2 -- and draft run-time test, early PARITY patch

Draft patch for NORM2; as PARITY is essentially the same -- thus, an untested PARITY implementation is included as well.

TODO
- There is some bug in converting the call for NORM2 - probably in trans-intrinsic.c; result: a segfault for the run-time version at compile time
- Inline run-time version missing, cf. ISYM_SUM - possibly use lib version with -Os?
- Test cases

- PARITY: What about logical kinds 1 and 2? Or how to handle this better? -- and the same issues as for NORM2.
Note, a simple conversion only works for scalars not for arrays - which require would require a temporary. I could image that INTEGER(1) is often used due to its smaller storage size.

PS: NORM2 is described as "careful calculation of Euclidean norm" in the BCS slides and in the what's new in F2008 article. Currently, I use the trivial brute-force method. Maybe something more careful should be done?
Comment 38 Tobias Burnus 2010-08-22 19:34:33 UTC
(In reply to comment #37)
> - PARITY: ... and the same issues as for NORM2.
And PARITY documentation is missing.

Reminder: For NORM2's inline version, think also about hypot.
Comment 39 Tobias Burnus 2010-08-22 21:02:45 UTC
(In reply to comment #37)
> PS: NORM2 is described as "careful calculation of Euclidean norm" in the BCS
> slides and in the what's new in F2008 article. Currently, I use the trivial
> brute-force method. Maybe something more careful should be done?

As Dominique points out - the algorithm can be made more robust by doing the calculation as
  tmp = max(abs(a))
  NORM2(a) := tmp*sqrt(dot_product(a/tmp,a/tmp))
That helps a lot for "a" finite with (a^2 > huge(a)) [overflow] ;-)

However, there is a method which only requires a single pass, cf. p. 38/39 in 
http://cpc.cs.qub.ac.uk/MRSN/higham.pdf. The algorithm by Sven Hammarling is also used in BLAS, cf. http://www.netlib.org/blas/snrm2.f
Comment 40 Tobias Burnus 2010-08-27 19:18:08 UTC
Subject: Bug 33197

Author: burnus
Date: Fri Aug 27 19:17:45 2010
New Revision: 163595

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163595
Log:
gcc/fortran/
2010-08-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * gcc/fortran/intrinsic.c (add_functions): Add norm2 and parity.
        * gcc/fortran/intrinsic.h (gfc_check_norm2, gfc_check_parity):
        gfc_simplify_norm2, gfc_simplify_parity, gfc_resolve_norm2,
        gfc_resolve_parity): New prototypes.
        * gcc/fortran/gfortran.h (gfc_isym_id): New enum items
        GFC_ISYM_NORM2 and GFC_ISYM_PARITY.
        * gcc/fortran/iresolve.c (gfc_resolve_norm2,
        gfc_resolve_parity): New functions.
        * gcc/fortran/check.c (gfc_check_norm2, gfc_check_parity):
        New functions.
        * gcc/fortran/trans-intrinsic.c (gfc_conv_intrinsic_arith,
        gfc_conv_intrinsic_function): Handle NORM2 and PARITY.
        * gcc/fortran/intrinsic.texi (NORM2, PARITY): Add.
        * gcc/fortran/simplify.c (simplify_transformation_to_array):
        Add post-processing opterator.
        (gfc_simplify_all, gfc_simplify_any, gfc_simplify_count,
        gfc_simplify_product, gfc_simplify_sum): Update call.
        (add_squared, do_sqrt, gfc_simplify_norm2, do_xor,
        gfc_simplify_parity): New functions.

gcc/testsuite/
2010-08-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * gcc/testsuite/gfortran.dg/norm2_1.f90: New.
        * gcc/testsuite/gfortran.dg/norm2_2.f90: New.
        * gcc/testsuite/gfortran.dg/norm2_3.f90: New.
        * gcc/testsuite/gfortran.dg/norm2_4.f90: New.
        * gcc/testsuite/gfortran.dg/parity_1.f90: New.
        * gcc/testsuite/gfortran.dg/parity_2.f90: New.
        * gcc/testsuite/gfortran.dg/parity_3.f90: New.

libgfortran/
2010-08-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33197
        * libgfortran/m4/ifunction.m4 (FINISH_ARRAY_FUNCTION,
        ARRAY_FUNCTION): Allow expression after loop.
        * libgfortran/m4/norm2.m4: New for _gfortran_norm2_r{4,8,10,16}.
        * libgfortran/m4/parity.m4: New for
        * _gfortran_parity_l{1,2,4,8,16}.
        * libgfortran/gfortran.map: Add new functions.
        * libgfortran/Makefile.am: Ditto.
        * libgfortran/m4/minloc1.m4: Add empty argument for
        * ARRAY_FUNCTION.
        * libgfortran/m4/maxloc1.m4: Ditto.
        * libgfortran/m4/all.m4: Ditto.
        * libgfortran/m4/minval.m4: Ditto.
        * libgfortran/m4/maxval.m4: Ditto.
        * libgfortran/m4/count.m4: Ditto.
        * libgfortran/m4/product.m4: Ditto.
        * libgfortran/m4/any.m4: Ditto.
        * Makefile.in: Regenerated.
        * generated/minval_r8.c: Regenerated.
        * generated/maxloc1_4_r8.c: Regenerated.
        * generated/minloc1_16_r16.c: Regenerated.
        * generated/norm2_r4.c: Regenerated.
        * generated/sum_i8.c: Regenerated.
        * generated/parity_l2.c: Regenerated.
        * generated/any_l16.c: Regenerated.
        * generated/maxval_i2.c: Regenerated.
        * generated/any_l2.c: Regenerated.
        * generated/product_r4.c: Regenerated.
        * generated/maxloc1_8_i4.c: Regenerated.
        * generated/parity_l16.c: Regenerated.
        * generated/all_l1.c: Regenerated.
        * generated/product_i2.c: Regenerated.
        * generated/minloc1_8_r16.c: Regenerated.
        * generated/maxloc1_8_r16.c: Regenerated.
        * generated/sum_r16.c: Regenerated.
        * generated/sum_i1.c: Regenerated.
        * generated/minloc1_4_r8.c: Regenerated.
        * generated/maxloc1_16_r16.c: Regenerated.
        * generated/minloc1_16_i4.c: Regenerated.
        * generated/maxloc1_16_i4.c: Regenerated.
        * generated/maxval_r16.c: Regenerated.
        * generated/product_c10.c: Regenerated.
        * generated/minloc1_8_i4.c: Regenerated.
        * generated/all_l2.c: Regenerated.
        * generated/product_c4.c: Regenerated.
        * generated/sum_r4.c: Regenerated.
        * generated/all_l16.c: Regenerated.
        * generated/minloc1_16_r10.c: Regenerated.
        * generated/sum_i2.c: Regenerated.
        * generated/maxloc1_8_r8.c: Regenerated.
        * generated/minval_i16.c: Regenerated.
        * generated/parity_l4.c: Regenerated.
        * generated/maxval_i4.c: Regenerated.
        * generated/any_l4.c: Regenerated.
        * generated/minval_i8.c: Regenerated.
        * generated/maxloc1_4_i8.c: Regenerated.
        * generated/minloc1_4_i16.c: Regenerated.
        * generated/maxloc1_4_i16.c: Regenerated.
        * generated/minloc1_8_r10.c: Regenerated.
        * generated/product_i4.c: Regenerated.
        * generated/maxloc1_8_r10.c: Regenerated.
        * generated/sum_c16.c: Regenerated.
        * generated/minloc1_16_r8.c: Regenerated.
        * generated/maxloc1_16_r8.c: Regenerated.
        * generated/count_4_l.c: Regenerated.
        * generated/sum_r10.c: Regenerated.
        * generated/count_8_l.c: Regenerated.
        * generated/sum_c4.c: Regenerated.
        * generated/maxloc1_16_r10.c: Regenerated.
        * generated/minloc1_8_r8.c: Regenerated.
        * generated/maxval_r10.c: Regenerated.
        * generated/minval_i1.c: Regenerated.
        * generated/maxloc1_4_i1.c: Regenerated.
        * generated/minloc1_4_i8.c: Regenerated.
        * generated/product_i16.c: Regenerated.
        * generated/all_l4.c: Regenerated.
        * generated/norm2_r16.c: Regenerated.
        * generated/minval_r4.c: Regenerated.
        * generated/maxloc1_4_r4.c: Regenerated.
        * generated/sum_i4.c: Regenerated.
        * generated/maxval_r8.c: Regenerated.
        * generated/norm2_r8.c: Regenerated.
        * generated/minloc1_4_i1.c: Regenerated.
        * generated/minval_r16.c: Regenerated.
        * generated/minval_i2.c: Regenerated.
        * generated/maxloc1_4_i2.c: Regenerated.
        * generated/product_r8.c: Regenerated.
        * generated/maxloc1_8_i8.c: Regenerated.
        * generated/sum_c10.c: Regenerated.
        * generated/minloc1_4_r16.c: Regenerated.
        * generated/maxloc1_4_r16.c: Regenerated.
        * generated/count_1_l.c: Regenerated.
        * generated/minloc1_4_r4.c: Regenerated.
        * generated/minloc1_16_i8.c: Regenerated.
        * generated/maxloc1_16_i8.c: Regenerated.
        * generated/minloc1_4_i2.c: Regenerated.
        * generated/maxloc1_8_i1.c: Regenerated.
        * generated/minloc1_8_i8.c: Regenerated.
        * generated/product_r16.c: Regenerated.
        * generated/product_c8.c: Regenerated.
        * generated/sum_r8.c: Regenerated.
        * generated/norm2_r10.c: Regenerated.
        * generated/minloc1_16_i16.c: Regenerated.
        * generated/maxloc1_8_r4.c: Regenerated.
        * generated/minloc1_16_i1.c: Regenerated.
        * generated/maxloc1_16_i1.c: Regenerated.
        * generated/minval_r10.c: Regenerated.
        * generated/count_16_l.c: Regenerated.
        * generated/parity_l8.c: Regenerated.
        * generated/minloc1_8_i1.c: Regenerated.
        * generated/minval_i4.c: Regenerated.
        * generated/maxloc1_4_i4.c: Regenerated.
        * generated/maxloc1_8_i2.c: Regenerated.
        * generated/maxval_i8.c: Regenerated.
        * generated/any_l8.c: Regenerated.
        * generated/minloc1_4_r10.c: Regenerated.
        * generated/minloc1_8_i16.c: Regenerated.
        * generated/maxloc1_4_r10.c: Regenerated.
        * generated/maxloc1_8_i16.c: Regenerated.
        * generated/minloc1_16_r4.c: Regenerated.
        * generated/maxloc1_16_r4.c: Regenerated.
        * generated/product_i8.c: Regenerated.
        * generated/sum_i16.c: Regenerated.
        * generated/count_2_l.c: Regenerated.
        * generated/maxloc1_16_i16.c: Regenerated.
        * generated/minloc1_8_r4.c: Regenerated.
        * generated/sum_c8.c: Regenerated.
        * generated/minloc1_16_i2.c: Regenerated.
        * generated/maxloc1_16_i2.c: Regenerated.
        * generated/parity_l1.c: Regenerated.
        * generated/maxval_i16.c: Regenerated.
        * generated/maxval_i1.c: Regenerated.
        * generated/minloc1_4_i4.c: Regenerated.
        * generated/any_l1.c: Regenerated.
        * generated/minloc1_8_i2.c: Regenerated.
        * generated/product_c16.c: Regenerated.
        * generated/product_r10.c: Regenerated.
        * generated/product_i1.c: Regenerated.
        * generated/all_l8.c: Regenerated.
        * generated/maxval_r4.c: Regenerated.


Added:
    trunk/gcc/testsuite/gfortran.dg/norm2_1.f90
    trunk/gcc/testsuite/gfortran.dg/norm2_2.f90
    trunk/gcc/testsuite/gfortran.dg/norm2_3.f90
    trunk/gcc/testsuite/gfortran.dg/norm_4.f90
    trunk/gcc/testsuite/gfortran.dg/parity_1.f90
    trunk/gcc/testsuite/gfortran.dg/parity_2.f90
    trunk/gcc/testsuite/gfortran.dg/parity_3.f90
    trunk/libgfortran/generated/norm2_r10.c
    trunk/libgfortran/generated/norm2_r16.c
    trunk/libgfortran/generated/norm2_r4.c
    trunk/libgfortran/generated/norm2_r8.c
    trunk/libgfortran/generated/parity_l1.c
    trunk/libgfortran/generated/parity_l16.c
    trunk/libgfortran/generated/parity_l2.c
    trunk/libgfortran/generated/parity_l4.c
    trunk/libgfortran/generated/parity_l8.c
    trunk/libgfortran/m4/norm2.m4
    trunk/libgfortran/m4/parity.m4
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in
    trunk/libgfortran/generated/all_l1.c
    trunk/libgfortran/generated/all_l16.c
    trunk/libgfortran/generated/all_l2.c
    trunk/libgfortran/generated/all_l4.c
    trunk/libgfortran/generated/all_l8.c
    trunk/libgfortran/generated/any_l1.c
    trunk/libgfortran/generated/any_l16.c
    trunk/libgfortran/generated/any_l2.c
    trunk/libgfortran/generated/any_l4.c
    trunk/libgfortran/generated/any_l8.c
    trunk/libgfortran/generated/count_16_l.c
    trunk/libgfortran/generated/count_1_l.c
    trunk/libgfortran/generated/count_2_l.c
    trunk/libgfortran/generated/count_4_l.c
    trunk/libgfortran/generated/count_8_l.c
    trunk/libgfortran/generated/maxloc1_16_i1.c
    trunk/libgfortran/generated/maxloc1_16_i16.c
    trunk/libgfortran/generated/maxloc1_16_i2.c
    trunk/libgfortran/generated/maxloc1_16_i4.c
    trunk/libgfortran/generated/maxloc1_16_i8.c
    trunk/libgfortran/generated/maxloc1_16_r10.c
    trunk/libgfortran/generated/maxloc1_16_r16.c
    trunk/libgfortran/generated/maxloc1_16_r4.c
    trunk/libgfortran/generated/maxloc1_16_r8.c
    trunk/libgfortran/generated/maxloc1_4_i1.c
    trunk/libgfortran/generated/maxloc1_4_i16.c
    trunk/libgfortran/generated/maxloc1_4_i2.c
    trunk/libgfortran/generated/maxloc1_4_i4.c
    trunk/libgfortran/generated/maxloc1_4_i8.c
    trunk/libgfortran/generated/maxloc1_4_r10.c
    trunk/libgfortran/generated/maxloc1_4_r16.c
    trunk/libgfortran/generated/maxloc1_4_r4.c
    trunk/libgfortran/generated/maxloc1_4_r8.c
    trunk/libgfortran/generated/maxloc1_8_i1.c
    trunk/libgfortran/generated/maxloc1_8_i16.c
    trunk/libgfortran/generated/maxloc1_8_i2.c
    trunk/libgfortran/generated/maxloc1_8_i4.c
    trunk/libgfortran/generated/maxloc1_8_i8.c
    trunk/libgfortran/generated/maxloc1_8_r10.c
    trunk/libgfortran/generated/maxloc1_8_r16.c
    trunk/libgfortran/generated/maxloc1_8_r4.c
    trunk/libgfortran/generated/maxloc1_8_r8.c
    trunk/libgfortran/generated/maxval_i1.c
    trunk/libgfortran/generated/maxval_i16.c
    trunk/libgfortran/generated/maxval_i2.c
    trunk/libgfortran/generated/maxval_i4.c
    trunk/libgfortran/generated/maxval_i8.c
    trunk/libgfortran/generated/maxval_r10.c
    trunk/libgfortran/generated/maxval_r16.c
    trunk/libgfortran/generated/maxval_r4.c
    trunk/libgfortran/generated/maxval_r8.c
    trunk/libgfortran/generated/minloc1_16_i1.c
    trunk/libgfortran/generated/minloc1_16_i16.c
    trunk/libgfortran/generated/minloc1_16_i2.c
    trunk/libgfortran/generated/minloc1_16_i4.c
    trunk/libgfortran/generated/minloc1_16_i8.c
    trunk/libgfortran/generated/minloc1_16_r10.c
    trunk/libgfortran/generated/minloc1_16_r16.c
    trunk/libgfortran/generated/minloc1_16_r4.c
    trunk/libgfortran/generated/minloc1_16_r8.c
    trunk/libgfortran/generated/minloc1_4_i1.c
    trunk/libgfortran/generated/minloc1_4_i16.c
    trunk/libgfortran/generated/minloc1_4_i2.c
    trunk/libgfortran/generated/minloc1_4_i4.c
    trunk/libgfortran/generated/minloc1_4_i8.c
    trunk/libgfortran/generated/minloc1_4_r10.c
    trunk/libgfortran/generated/minloc1_4_r16.c
    trunk/libgfortran/generated/minloc1_4_r4.c
    trunk/libgfortran/generated/minloc1_4_r8.c
    trunk/libgfortran/generated/minloc1_8_i1.c
    trunk/libgfortran/generated/minloc1_8_i16.c
    trunk/libgfortran/generated/minloc1_8_i2.c
    trunk/libgfortran/generated/minloc1_8_i4.c
    trunk/libgfortran/generated/minloc1_8_i8.c
    trunk/libgfortran/generated/minloc1_8_r10.c
    trunk/libgfortran/generated/minloc1_8_r16.c
    trunk/libgfortran/generated/minloc1_8_r4.c
    trunk/libgfortran/generated/minloc1_8_r8.c
    trunk/libgfortran/generated/minval_i1.c
    trunk/libgfortran/generated/minval_i16.c
    trunk/libgfortran/generated/minval_i2.c
    trunk/libgfortran/generated/minval_i4.c
    trunk/libgfortran/generated/minval_i8.c
    trunk/libgfortran/generated/minval_r10.c
    trunk/libgfortran/generated/minval_r16.c
    trunk/libgfortran/generated/minval_r4.c
    trunk/libgfortran/generated/minval_r8.c
    trunk/libgfortran/generated/product_c10.c
    trunk/libgfortran/generated/product_c16.c
    trunk/libgfortran/generated/product_c4.c
    trunk/libgfortran/generated/product_c8.c
    trunk/libgfortran/generated/product_i1.c
    trunk/libgfortran/generated/product_i16.c
    trunk/libgfortran/generated/product_i2.c
    trunk/libgfortran/generated/product_i4.c
    trunk/libgfortran/generated/product_i8.c
    trunk/libgfortran/generated/product_r10.c
    trunk/libgfortran/generated/product_r16.c
    trunk/libgfortran/generated/product_r4.c
    trunk/libgfortran/generated/product_r8.c
    trunk/libgfortran/generated/sum_c10.c
    trunk/libgfortran/generated/sum_c16.c
    trunk/libgfortran/generated/sum_c4.c
    trunk/libgfortran/generated/sum_c8.c
    trunk/libgfortran/generated/sum_i1.c
    trunk/libgfortran/generated/sum_i16.c
    trunk/libgfortran/generated/sum_i2.c
    trunk/libgfortran/generated/sum_i4.c
    trunk/libgfortran/generated/sum_i8.c
    trunk/libgfortran/generated/sum_r10.c
    trunk/libgfortran/generated/sum_r16.c
    trunk/libgfortran/generated/sum_r4.c
    trunk/libgfortran/generated/sum_r8.c
    trunk/libgfortran/gfortran.map
    trunk/libgfortran/m4/all.m4
    trunk/libgfortran/m4/any.m4
    trunk/libgfortran/m4/count.m4
    trunk/libgfortran/m4/ifunction.m4
    trunk/libgfortran/m4/maxloc1.m4
    trunk/libgfortran/m4/maxval.m4
    trunk/libgfortran/m4/minloc1.m4
    trunk/libgfortran/m4/minval.m4
    trunk/libgfortran/m4/product.m4

Comment 41 Tobias Burnus 2010-08-27 19:20:57 UTC
FIXED on the 4.6 trunk.

Thanks to all involved in implementing the math intrinsics.