Bug 54613

Summary: [F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=
Product: gcc Reporter: Tobias Burnus <burnus>
Component: fortranAssignee: Thomas Koenig <tkoenig>
Status: RESOLVED FIXED    
Severity: normal CC: janus, juergen.reuter, tkoenig, uberprugelknabe, weeks, zbeekman
Priority: P3 Keywords: rejects-valid
Version: 4.8.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2012-09-18 00:00:00
Bug Depends on: 54633    
Bug Blocks: 39627    
Attachments: Very preliminary patch for MAXLOC/MINLOC
Draft patch for BACK, slows down some cases
Patch which should not slow down things....
First piece of the work...
Patch with a first version of a library function
Patch for findloc library version without dim
Patch for the library version, minus quite a few bugs

Description Tobias Burnus 2012-09-18 07:40:45 UTC
Fortran 2003 (cf. PR 29600) added KIND= to MINLOC/MAXLOC, Fortran 2008 added BACK=. Additionally, Fortran 2008 added FINDLOC with a similar syntax.

See also James' post in "binary data" https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/GpaACNKn0Ds

"As can be seen from the commented out code, gfortran does not yet
 implement the BACK= argument for the MAXLOC and MINLOC intrinsics,
 doesn't yet implement MAXLOC, MAXVAL, MINLOC, MINVAL for constant
 expressions and doesn't implement FINDLOC at all."

See also his comments in https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/5eAz5ns6AG0



The first step is to implement the run-time version, i.e. extending MINLOC/MAXLOC and adding FINDLOC.

(trans-intrinsic.c version, frontend-optimization.c and the library version, possibly such that one doesn't cause an explosion of the intrinsics, e.g. only returning default + index-type? If so, one needs to have a RANGE_REF copy for the array results - and for the MASK argument.)


As a next step, one has to think of the compile-time simplification of {MIN,MAX}{VAL,LOC},FINDLOC.
Comment 1 Tobias Burnus 2012-09-18 09:17:25 UTC
Created attachment 28211 [details]
Very preliminary patch for MAXLOC/MINLOC

Very preliminary patch for the MAXLOC/MINLOC support; i.e. documentation and resolving plus identifying the spot (and needed changes) for trans-intrinsic.c. Implementing the latter and in particular the library support are still lacking. (As is FINDLOC.)
Comment 2 Dominique d'Humieres 2012-09-18 09:25:36 UTC
This PR seems related to pr25104 and pr45689.
Comment 3 Dominique d'Humieres 2016-11-18 17:59:47 UTC
At https://gcc.gnu.org/ml/fortran/2016-11/msg00179.html I wrote 

pr54613, sixth and eighth tests,

Actually the tests were extracted from https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/5eAz5ns6AG0, i.e.,

module m2procs 
   implicit none 
   contains 
      recursive function fun(depth) result(r) 
         integer r 
         integer depth 
         integer x(minval([1],mask=[.TRUE.])) 
         integer y 
         save 

         x = 0 
         if(depth > 0) y = fun(depth-1) 
         x = x+1 
         r = x(1) 
      end function fun 
end module m2procs 

program minval2 
   use m2procs 
   implicit none 

   write(*,*) fun(1) 
end program minval2 

and

[Book15] f90/bug% diff -up pr54613_5.f90 pr54613_7.f90
--- pr54613_5.f90	2012-09-18 10:43:48.000000000 +0200
+++ pr54613_7.f90	2012-09-18 10:44:56.000000000 +0200
@@ -4,7 +4,7 @@ module m2procs 
       recursive function fun(depth) result(r) 
          integer r 
          integer depth 
-         integer x(minval([1],mask=[.TRUE.])) 
+         integer x(sum(minloc([1]))) 
          integer y 
          save 
 
@@ -15,9 +15,9 @@ module m2procs 
       end function fun 
 end module m2procs 
 
-program minval2 
+program minloc2 
    use m2procs 
    implicit none 
 
    write(*,*) fun(1) 
-end program minval2 
+end program minloc2
Comment 4 Thomas Koenig 2017-11-28 18:58:02 UTC
KIND is done (PR 29600).

Still to do: FINDLOC and BACK.
Comment 5 Thomas Koenig 2018-01-07 12:33:50 UTC
I'll take a shot, but this will take a while.
If anybody else wants to chime in, feel free :-)
Comment 6 Thomas Koenig 2018-01-15 18:35:45 UTC
Author: tkoenig
Date: Mon Jan 15 18:35:13 2018
New Revision: 256705

URL: https://gcc.gnu.org/viewcvs?rev=256705&root=gcc&view=rev
Log:
2018-01-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.h (gfc_check_f): Rename f4ml to f5ml.
	(gfc_logical_4_kind): New macro
	* intrinsic.h (gfc_simplify_minloc): Add a gfc_expr *argument.
	(gfc_simplify_maxloc): Likewise.
	(gfc_resolve_maxloc): Likewise.
	(gfc_resolve_minloc): Likewise.
	* check.c (gfc_check_minloc_maxloc): Add checking for "back"
	argument; also raise error if it is used (for now). Add it
	if it isn't present.
	* intrinsic.c (add_sym_4ml): Rename to
	(add_sym_5ml), adjust for extra argument.
	(add_functions): Add "back" constant. Adjust maxloc and minloc
	for back argument.
	* iresolve.c (gfc_resolve_maxloc): Add back argument. If back is
	not of gfc_logical_4_kind, convert.
	(gfc_resolve_minloc): Likewise.
	* simplify.c (gfc_simplify_minloc): Add back argument.
	(gfc_simplify_maxloc): Likewise.
	* trans-intinsic.c (gfc_conv_intrinsic_minmaxloc): Rename last
	argument to %VAL to ensure passing by value.
	(gfc_conv_intrinsic_function): Call gfc_conv_intrinsic_minmaxloc
	also for library calls.

2018-01-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* m4/iparm.m4: Add back_arg macro if in minloc or maxloc.
	* m4/iforeach-s.m4: Add optional argument back with back_arg
	macro. Improve m4 quoting. If HAVE_BACK_ARG is defined, assert
	that back is non-true.
	* m4/iforeach.m4: Likewise.
	* m4/ifunction-s.m4: Likewise.
	* m4/ifunction.m4: Likewise.
	* m4/maxloc0.m4: Include assert.h
	* m4/minloc0.m4: Likewise.
	* m4/maxloc0s.m4: #define HAVE_BACK_ARG.
	* m4/minloc0s.m4: Likewise.
	* m4/maxloc1s.m4: Likewise.
	* m4/minloc1s.m4: Likewise.
	* m4/maxloc1.m4: Include assert.h, #define HAVE_BACK_ARG.
	* m4/minloc1.m4: Likewise.
	* m4/maxloc2s.m4: Add assert.h, add back_arg, assert that
	back is non-true.
	* m4/minloc2s.m4: Likewise.
	* generated/iall_i1.c: Regenerated.
	* generated/iall_i16.c: Regenerated.
	* generated/iall_i2.c: Regenerated.
	* generated/iall_i4.c: Regenerated.
	* generated/iall_i8.c: Regenerated.
	* generated/iany_i1.c: Regenerated.
	* generated/iany_i16.c: Regenerated.
	* generated/iany_i2.c: Regenerated.
	* generated/iany_i4.c: Regenerated.
	* generated/iany_i8.c: Regenerated.
	* generated/iparity_i1.c: Regenerated.
	* generated/iparity_i16.c: Regenerated.
	* generated/iparity_i2.c: Regenerated.
	* generated/iparity_i4.c: Regenerated.
	* generated/iparity_i8.c: Regenerated.
	* generated/maxloc0_16_i1.c: Regenerated.
	* generated/maxloc0_16_i16.c: Regenerated.
	* generated/maxloc0_16_i2.c: Regenerated.
	* generated/maxloc0_16_i4.c: Regenerated.
	* generated/maxloc0_16_i8.c: Regenerated.
	* generated/maxloc0_16_r10.c: Regenerated.
	* generated/maxloc0_16_r16.c: Regenerated.
	* generated/maxloc0_16_r4.c: Regenerated.
	* generated/maxloc0_16_r8.c: Regenerated.
	* generated/maxloc0_16_s1.c: Regenerated.
	* generated/maxloc0_16_s4.c: Regenerated.
	* generated/maxloc0_4_i1.c: Regenerated.
	* generated/maxloc0_4_i16.c: Regenerated.
	* generated/maxloc0_4_i2.c: Regenerated.
	* generated/maxloc0_4_i4.c: Regenerated.
	* generated/maxloc0_4_i8.c: Regenerated.
	* generated/maxloc0_4_r10.c: Regenerated.
	* generated/maxloc0_4_r16.c: Regenerated.
	* generated/maxloc0_4_r4.c: Regenerated.
	* generated/maxloc0_4_r8.c: Regenerated.
	* generated/maxloc0_4_s1.c: Regenerated.
	* generated/maxloc0_4_s4.c: Regenerated.
	* generated/maxloc0_8_i1.c: Regenerated.
	* generated/maxloc0_8_i16.c: Regenerated.
	* generated/maxloc0_8_i2.c: Regenerated.
	* generated/maxloc0_8_i4.c: Regenerated.
	* generated/maxloc0_8_i8.c: Regenerated.
	* generated/maxloc0_8_r10.c: Regenerated.
	* generated/maxloc0_8_r16.c: Regenerated.
	* generated/maxloc0_8_r4.c: Regenerated.
	* generated/maxloc0_8_r8.c: Regenerated.
	* generated/maxloc0_8_s1.c: Regenerated.
	* generated/maxloc0_8_s4.c: Regenerated.
	* generated/maxloc1_16_i1.c: Regenerated.
	* generated/maxloc1_16_i16.c: Regenerated.
	* generated/maxloc1_16_i2.c: Regenerated.
	* generated/maxloc1_16_i4.c: Regenerated.
	* generated/maxloc1_16_i8.c: Regenerated.
	* generated/maxloc1_16_r10.c: Regenerated.
	* generated/maxloc1_16_r16.c: Regenerated.
	* generated/maxloc1_16_r4.c: Regenerated.
	* generated/maxloc1_16_r8.c: Regenerated.
	* generated/maxloc1_16_s1.c: Regenerated.
	* generated/maxloc1_16_s4.c: Regenerated.
	* generated/maxloc1_4_i1.c: Regenerated.
	* generated/maxloc1_4_i16.c: Regenerated.
	* generated/maxloc1_4_i2.c: Regenerated.
	* generated/maxloc1_4_i4.c: Regenerated.
	* generated/maxloc1_4_i8.c: Regenerated.
	* generated/maxloc1_4_r10.c: Regenerated.
	* generated/maxloc1_4_r16.c: Regenerated.
	* generated/maxloc1_4_r4.c: Regenerated.
	* generated/maxloc1_4_r8.c: Regenerated.
	* generated/maxloc1_4_s1.c: Regenerated.
	* generated/maxloc1_4_s4.c: Regenerated.
	* generated/maxloc1_8_i1.c: Regenerated.
	* generated/maxloc1_8_i16.c: Regenerated.
	* generated/maxloc1_8_i2.c: Regenerated.
	* generated/maxloc1_8_i4.c: Regenerated.
	* generated/maxloc1_8_i8.c: Regenerated.
	* generated/maxloc1_8_r10.c: Regenerated.
	* generated/maxloc1_8_r16.c: Regenerated.
	* generated/maxloc1_8_r4.c: Regenerated.
	* generated/maxloc1_8_r8.c: Regenerated.
	* generated/maxloc1_8_s1.c: Regenerated.
	* generated/maxloc1_8_s4.c: Regenerated.
	* generated/maxval_i1.c: Regenerated.
	* generated/maxval_i16.c: Regenerated.
	* generated/maxval_i2.c: Regenerated.
	* generated/maxval_i4.c: Regenerated.
	* generated/maxval_i8.c: Regenerated.
	* generated/maxval_r10.c: Regenerated.
	* generated/maxval_r16.c: Regenerated.
	* generated/maxval_r4.c: Regenerated.
	* generated/maxval_r8.c: Regenerated.
	* generated/minloc0_16_i1.c: Regenerated.
	* generated/minloc0_16_i16.c: Regenerated.
	* generated/minloc0_16_i2.c: Regenerated.
	* generated/minloc0_16_i4.c: Regenerated.
	* generated/minloc0_16_i8.c: Regenerated.
	* generated/minloc0_16_r10.c: Regenerated.
	* generated/minloc0_16_r16.c: Regenerated.
	* generated/minloc0_16_r4.c: Regenerated.
	* generated/minloc0_16_r8.c: Regenerated.
	* generated/minloc0_16_s1.c: Regenerated.
	* generated/minloc0_16_s4.c: Regenerated.
	* generated/minloc0_4_i1.c: Regenerated.
	* generated/minloc0_4_i16.c: Regenerated.
	* generated/minloc0_4_i2.c: Regenerated.
	* generated/minloc0_4_i4.c: Regenerated.
	* generated/minloc0_4_i8.c: Regenerated.
	* generated/minloc0_4_r10.c: Regenerated.
	* generated/minloc0_4_r16.c: Regenerated.
	* generated/minloc0_4_r4.c: Regenerated.
	* generated/minloc0_4_r8.c: Regenerated.
	* generated/minloc0_4_s1.c: Regenerated.
	* generated/minloc0_4_s4.c: Regenerated.
	* generated/minloc0_8_i1.c: Regenerated.
	* generated/minloc0_8_i16.c: Regenerated.
	* generated/minloc0_8_i2.c: Regenerated.
	* generated/minloc0_8_i4.c: Regenerated.
	* generated/minloc0_8_i8.c: Regenerated.
	* generated/minloc0_8_r10.c: Regenerated.
	* generated/minloc0_8_r16.c: Regenerated.
	* generated/minloc0_8_r4.c: Regenerated.
	* generated/minloc0_8_r8.c: Regenerated.
	* generated/minloc0_8_s1.c: Regenerated.
	* generated/minloc0_8_s4.c: Regenerated.
	* generated/minloc1_16_i1.c: Regenerated.
	* generated/minloc1_16_i16.c: Regenerated.
	* generated/minloc1_16_i2.c: Regenerated.
	* generated/minloc1_16_i4.c: Regenerated.
	* generated/minloc1_16_i8.c: Regenerated.
	* generated/minloc1_16_r10.c: Regenerated.
	* generated/minloc1_16_r16.c: Regenerated.
	* generated/minloc1_16_r4.c: Regenerated.
	* generated/minloc1_16_r8.c: Regenerated.
	* generated/minloc1_16_s1.c: Regenerated.
	* generated/minloc1_16_s4.c: Regenerated.
	* generated/minloc1_4_i1.c: Regenerated.
	* generated/minloc1_4_i16.c: Regenerated.
	* generated/minloc1_4_i2.c: Regenerated.
	* generated/minloc1_4_i4.c: Regenerated.
	* generated/minloc1_4_i8.c: Regenerated.
	* generated/minloc1_4_r10.c: Regenerated.
	* generated/minloc1_4_r16.c: Regenerated.
	* generated/minloc1_4_r4.c: Regenerated.
	* generated/minloc1_4_r8.c: Regenerated.
	* generated/minloc1_4_s1.c: Regenerated.
	* generated/minloc1_4_s4.c: Regenerated.
	* generated/minloc1_8_i1.c: Regenerated.
	* generated/minloc1_8_i16.c: Regenerated.
	* generated/minloc1_8_i2.c: Regenerated.
	* generated/minloc1_8_i4.c: Regenerated.
	* generated/minloc1_8_i8.c: Regenerated.
	* generated/minloc1_8_r10.c: Regenerated.
	* generated/minloc1_8_r16.c: Regenerated.
	* generated/minloc1_8_r4.c: Regenerated.
	* generated/minloc1_8_r8.c: Regenerated.
	* generated/minloc1_8_s1.c: Regenerated.
	* generated/minloc1_8_s4.c: Regenerated.
	* generated/minval_i1.c: Regenerated.
	* generated/minval_i16.c: Regenerated.
	* generated/minval_i2.c: Regenerated.
	* generated/minval_i4.c: Regenerated.
	* generated/minval_i8.c: Regenerated.
	* generated/minval_r10.c: Regenerated.
	* generated/minval_r16.c: Regenerated.
	* generated/minval_r4.c: Regenerated.
	* generated/minval_r8.c: Regenerated.
	* generated/norm2_r10.c: Regenerated.
	* generated/norm2_r16.c: Regenerated.
	* generated/norm2_r4.c: Regenerated.
	* generated/norm2_r8.c: Regenerated.
	* generated/parity_l1.c: Regenerated.
	* generated/parity_l16.c: Regenerated.
	* generated/parity_l2.c: Regenerated.
	* generated/parity_l4.c: Regenerated.
	* generated/parity_l8.c: Regenerated.
	* generated/product_c10.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/product_i8.c: Regenerated.
	* generated/product_r10.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/product_r8.c: Regenerated.
	* generated/sum_c10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/sum_r8.c: Regenerated.

2018-01-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.dg/minmaxloc_9.f90: New test.
	* gfortran.dg/minmaxloc_10.f90: New test.
	* gfortran.dg/minmaxloc_11.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/minmaxloc_10.f90
    trunk/gcc/testsuite/gfortran.dg/minmaxloc_11.f90
    trunk/gcc/testsuite/gfortran.dg/minmaxloc_9.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/iresolve.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/generated/iall_i1.c
    trunk/libgfortran/generated/iall_i16.c
    trunk/libgfortran/generated/iall_i2.c
    trunk/libgfortran/generated/iall_i4.c
    trunk/libgfortran/generated/iall_i8.c
    trunk/libgfortran/generated/iany_i1.c
    trunk/libgfortran/generated/iany_i16.c
    trunk/libgfortran/generated/iany_i2.c
    trunk/libgfortran/generated/iany_i4.c
    trunk/libgfortran/generated/iany_i8.c
    trunk/libgfortran/generated/iparity_i1.c
    trunk/libgfortran/generated/iparity_i16.c
    trunk/libgfortran/generated/iparity_i2.c
    trunk/libgfortran/generated/iparity_i4.c
    trunk/libgfortran/generated/iparity_i8.c
    trunk/libgfortran/generated/maxloc0_16_i1.c
    trunk/libgfortran/generated/maxloc0_16_i16.c
    trunk/libgfortran/generated/maxloc0_16_i2.c
    trunk/libgfortran/generated/maxloc0_16_i4.c
    trunk/libgfortran/generated/maxloc0_16_i8.c
    trunk/libgfortran/generated/maxloc0_16_r10.c
    trunk/libgfortran/generated/maxloc0_16_r16.c
    trunk/libgfortran/generated/maxloc0_16_r4.c
    trunk/libgfortran/generated/maxloc0_16_r8.c
    trunk/libgfortran/generated/maxloc0_16_s1.c
    trunk/libgfortran/generated/maxloc0_16_s4.c
    trunk/libgfortran/generated/maxloc0_4_i1.c
    trunk/libgfortran/generated/maxloc0_4_i16.c
    trunk/libgfortran/generated/maxloc0_4_i2.c
    trunk/libgfortran/generated/maxloc0_4_i4.c
    trunk/libgfortran/generated/maxloc0_4_i8.c
    trunk/libgfortran/generated/maxloc0_4_r10.c
    trunk/libgfortran/generated/maxloc0_4_r16.c
    trunk/libgfortran/generated/maxloc0_4_r4.c
    trunk/libgfortran/generated/maxloc0_4_r8.c
    trunk/libgfortran/generated/maxloc0_4_s1.c
    trunk/libgfortran/generated/maxloc0_4_s4.c
    trunk/libgfortran/generated/maxloc0_8_i1.c
    trunk/libgfortran/generated/maxloc0_8_i16.c
    trunk/libgfortran/generated/maxloc0_8_i2.c
    trunk/libgfortran/generated/maxloc0_8_i4.c
    trunk/libgfortran/generated/maxloc0_8_i8.c
    trunk/libgfortran/generated/maxloc0_8_r10.c
    trunk/libgfortran/generated/maxloc0_8_r16.c
    trunk/libgfortran/generated/maxloc0_8_r4.c
    trunk/libgfortran/generated/maxloc0_8_r8.c
    trunk/libgfortran/generated/maxloc0_8_s1.c
    trunk/libgfortran/generated/maxloc0_8_s4.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_16_s1.c
    trunk/libgfortran/generated/maxloc1_16_s4.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_4_s1.c
    trunk/libgfortran/generated/maxloc1_4_s4.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/maxloc1_8_s1.c
    trunk/libgfortran/generated/maxloc1_8_s4.c
    trunk/libgfortran/generated/maxloc2_16_s1.c
    trunk/libgfortran/generated/maxloc2_16_s4.c
    trunk/libgfortran/generated/maxloc2_4_s1.c
    trunk/libgfortran/generated/maxloc2_4_s4.c
    trunk/libgfortran/generated/maxloc2_8_s1.c
    trunk/libgfortran/generated/maxloc2_8_s4.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/minloc0_16_i1.c
    trunk/libgfortran/generated/minloc0_16_i16.c
    trunk/libgfortran/generated/minloc0_16_i2.c
    trunk/libgfortran/generated/minloc0_16_i4.c
    trunk/libgfortran/generated/minloc0_16_i8.c
    trunk/libgfortran/generated/minloc0_16_r10.c
    trunk/libgfortran/generated/minloc0_16_r16.c
    trunk/libgfortran/generated/minloc0_16_r4.c
    trunk/libgfortran/generated/minloc0_16_r8.c
    trunk/libgfortran/generated/minloc0_16_s1.c
    trunk/libgfortran/generated/minloc0_16_s4.c
    trunk/libgfortran/generated/minloc0_4_i1.c
    trunk/libgfortran/generated/minloc0_4_i16.c
    trunk/libgfortran/generated/minloc0_4_i2.c
    trunk/libgfortran/generated/minloc0_4_i4.c
    trunk/libgfortran/generated/minloc0_4_i8.c
    trunk/libgfortran/generated/minloc0_4_r10.c
    trunk/libgfortran/generated/minloc0_4_r16.c
    trunk/libgfortran/generated/minloc0_4_r4.c
    trunk/libgfortran/generated/minloc0_4_r8.c
    trunk/libgfortran/generated/minloc0_4_s1.c
    trunk/libgfortran/generated/minloc0_4_s4.c
    trunk/libgfortran/generated/minloc0_8_i1.c
    trunk/libgfortran/generated/minloc0_8_i16.c
    trunk/libgfortran/generated/minloc0_8_i2.c
    trunk/libgfortran/generated/minloc0_8_i4.c
    trunk/libgfortran/generated/minloc0_8_i8.c
    trunk/libgfortran/generated/minloc0_8_r10.c
    trunk/libgfortran/generated/minloc0_8_r16.c
    trunk/libgfortran/generated/minloc0_8_r4.c
    trunk/libgfortran/generated/minloc0_8_r8.c
    trunk/libgfortran/generated/minloc0_8_s1.c
    trunk/libgfortran/generated/minloc0_8_s4.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_16_s1.c
    trunk/libgfortran/generated/minloc1_16_s4.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_4_s1.c
    trunk/libgfortran/generated/minloc1_4_s4.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/minloc1_8_s1.c
    trunk/libgfortran/generated/minloc1_8_s4.c
    trunk/libgfortran/generated/minloc2_16_s1.c
    trunk/libgfortran/generated/minloc2_16_s4.c
    trunk/libgfortran/generated/minloc2_4_s1.c
    trunk/libgfortran/generated/minloc2_4_s4.c
    trunk/libgfortran/generated/minloc2_8_s1.c
    trunk/libgfortran/generated/minloc2_8_s4.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/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/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/m4/iforeach-s.m4
    trunk/libgfortran/m4/iforeach.m4
    trunk/libgfortran/m4/ifunction-s.m4
    trunk/libgfortran/m4/ifunction.m4
    trunk/libgfortran/m4/iparm.m4
    trunk/libgfortran/m4/maxloc0.m4
    trunk/libgfortran/m4/maxloc0s.m4
    trunk/libgfortran/m4/maxloc1.m4
    trunk/libgfortran/m4/maxloc1s.m4
    trunk/libgfortran/m4/maxloc2s.m4
    trunk/libgfortran/m4/minloc0.m4
    trunk/libgfortran/m4/minloc0s.m4
    trunk/libgfortran/m4/minloc1.m4
    trunk/libgfortran/m4/minloc1s.m4
    trunk/libgfortran/m4/minloc2s.m4
Comment 7 Thomas Koenig 2018-01-21 10:37:21 UTC
Created attachment 43200 [details]
Draft patch for BACK, slows down some cases

This patch implements the functionality, but there are still
issues with speed. Putting in the condition for back inside
a hot loop slows down things too much..
Here are some numbers:

program main
  real, dimension(1000,1000) :: a
  real, dimension(1000*1000) :: b
  call random_number(a)
  call cpu_time (t1)
  print *,minloc(a)
  call cpu_time (t2)
  print *,t2-t1
  call random_number(b)
  call cpu_time (t1)
  print *,minloc(b,dim=1)
  call cpu_time (t2)
  print *,t2-t1
end program main

"gfortran" is gcc-8 with the patch, "/usr/bin/gfortran" is gcc-7.

$ gfortran -O3 bench.f90 && ./a.out
   4.58569974E-02
   7.76470006E-02
$ gfortran -Ofast bench.f90 && ./a.out
   4.58849967E-02
   4.99750078E-02
$ /usr/bin/gfortran -O3 bench.f90 && ./a.out
   3.56819928E-02
   7.77039826E-02
$ /usr/bin/gfortran -Ofast bench.f90 && ./a.out
   4.05109972E-02
   4.98609543E-02

So, the inline version appears to be OK, the library version is slower.
Comment 8 Thomas Koenig 2018-01-23 23:27:58 UTC
Created attachment 43226 [details]
Patch which should not slow down things....

This seems to be better from the timing perspective for
the library versions.
Comment 9 Thomas Koenig 2018-05-08 07:47:51 UTC
Author: tkoenig
Date: Tue May  8 07:47:19 2018
New Revision: 260023

URL: https://gcc.gnu.org/viewcvs?rev=260023&root=gcc&view=rev
Log:
2018-05-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* check.c (gfc_check_minmaxloc): Remove error for BACK not being
	implemented.  Use gfc_logical_4_kind for BACK.
	* simplify.c (min_max_choose): Add optional argument back_val.
	Handle it.
	(simplify_minmaxloc_to_scalar): Add argument back_val. Pass
	back_val to min_max_choose.
	(simplify_minmaxloc_to_nodim): Likewise.
	(simplify_minmaxloc_to_array): Likewise.
	(gfc_simplify_minmaxloc): Add argument back, handle it.
	Pass back_val to specific simplification functions.
	(gfc_simplify_minloc): Remove ATTRIBUTE_UNUSED from argument back,
	pass it on to gfc_simplify_minmaxloc.
	(gfc_simplify_maxloc): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Adjust
	comment. If BACK is true, use greater or equal (or lesser or
	equal) insteal of greater (or lesser). Mark the condition of
	having found a value which exceeds the limit as unlikely.

2018-05-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* m4/iforeach-s.m4: Remove assertion that back is zero.
	* m4/iforeach.m4: Likewise.  Remove leading 'do'
	before implementation start.
	* m4/ifunction-s.m4: Remove assertion that back is zero.
	* m4/ifunction.m4: Likewise.  Remove for loop if HAVE_BACK_ARG
	is defined.
	* m4/maxloc0.m4: Reorganize loops. Split loops between >= and =,
	depending if back is true.  Mark the condition of having
	found a value which exceeds the limit as unlikely.
	* m4/minloc0.m4: Likewise.
	* m4/maxloc1.m4: Likewise.
	* m4/minloc1.m4: Likewise.
	* m4/maxloc1s.m4: Handle back argument.
	* m4/minloc1s.m4: Likewise.
	* m4/maxloc2s.m4: Remove assertion that back is zero.
	Remove special handling of loop start. Handle back argument.
	* m4/minloc2s.m4: Likewise.
	* generated/iall_i1.c: Regenerated.
	* generated/iall_i16.c: Regenerated.
	* generated/iall_i2.c: Regenerated.
	* generated/iall_i4.c: Regenerated.
	* generated/iall_i8.c: Regenerated.
	* generated/iany_i1.c: Regenerated.
	* generated/iany_i16.c: Regenerated.
	* generated/iany_i2.c: Regenerated.
	* generated/iany_i4.c: Regenerated.
	* generated/iany_i8.c: Regenerated.
	* generated/iparity_i1.c: Regenerated.
	* generated/iparity_i16.c: Regenerated.
	* generated/iparity_i2.c: Regenerated.
	* generated/iparity_i4.c: Regenerated.
	* generated/iparity_i8.c: Regenerated.
	* generated/maxloc0_16_i1.c: Regenerated.
	* generated/maxloc0_16_i16.c: Regenerated.
	* generated/maxloc0_16_i2.c: Regenerated.
	* generated/maxloc0_16_i4.c: Regenerated.
	* generated/maxloc0_16_i8.c: Regenerated.
	* generated/maxloc0_16_r10.c: Regenerated.
	* generated/maxloc0_16_r16.c: Regenerated.
	* generated/maxloc0_16_r4.c: Regenerated.
	* generated/maxloc0_16_r8.c: Regenerated.
	* generated/maxloc0_16_s1.c: Regenerated.
	* generated/maxloc0_16_s4.c: Regenerated.
	* generated/maxloc0_4_i1.c: Regenerated.
	* generated/maxloc0_4_i16.c: Regenerated.
	* generated/maxloc0_4_i2.c: Regenerated.
	* generated/maxloc0_4_i4.c: Regenerated.
	* generated/maxloc0_4_i8.c: Regenerated.
	* generated/maxloc0_4_r10.c: Regenerated.
	* generated/maxloc0_4_r16.c: Regenerated.
	* generated/maxloc0_4_r4.c: Regenerated.
	* generated/maxloc0_4_r8.c: Regenerated.
	* generated/maxloc0_4_s1.c: Regenerated.
	* generated/maxloc0_4_s4.c: Regenerated.
	* generated/maxloc0_8_i1.c: Regenerated.
	* generated/maxloc0_8_i16.c: Regenerated.
	* generated/maxloc0_8_i2.c: Regenerated.
	* generated/maxloc0_8_i4.c: Regenerated.
	* generated/maxloc0_8_i8.c: Regenerated.
	* generated/maxloc0_8_r10.c: Regenerated.
	* generated/maxloc0_8_r16.c: Regenerated.
	* generated/maxloc0_8_r4.c: Regenerated.
	* generated/maxloc0_8_r8.c: Regenerated.
	* generated/maxloc0_8_s1.c: Regenerated.
	* generated/maxloc0_8_s4.c: Regenerated.
	* generated/maxloc1_16_i1.c: Regenerated.
	* generated/maxloc1_16_i16.c: Regenerated.
	* generated/maxloc1_16_i2.c: Regenerated.
	* generated/maxloc1_16_i4.c: Regenerated.
	* generated/maxloc1_16_i8.c: Regenerated.
	* generated/maxloc1_16_r10.c: Regenerated.
	* generated/maxloc1_16_r16.c: Regenerated.
	* generated/maxloc1_16_r4.c: Regenerated.
	* generated/maxloc1_16_r8.c: Regenerated.
	* generated/maxloc1_16_s1.c: Regenerated.
	* generated/maxloc1_16_s4.c: Regenerated.
	* generated/maxloc1_4_i1.c: Regenerated.
	* generated/maxloc1_4_i16.c: Regenerated.
	* generated/maxloc1_4_i2.c: Regenerated.
	* generated/maxloc1_4_i4.c: Regenerated.
	* generated/maxloc1_4_i8.c: Regenerated.
	* generated/maxloc1_4_r10.c: Regenerated.
	* generated/maxloc1_4_r16.c: Regenerated.
	* generated/maxloc1_4_r4.c: Regenerated.
	* generated/maxloc1_4_r8.c: Regenerated.
	* generated/maxloc1_4_s1.c: Regenerated.
	* generated/maxloc1_4_s4.c: Regenerated.
	* generated/maxloc1_8_i1.c: Regenerated.
	* generated/maxloc1_8_i16.c: Regenerated.
	* generated/maxloc1_8_i2.c: Regenerated.
	* generated/maxloc1_8_i4.c: Regenerated.
	* generated/maxloc1_8_i8.c: Regenerated.
	* generated/maxloc1_8_r10.c: Regenerated.
	* generated/maxloc1_8_r16.c: Regenerated.
	* generated/maxloc1_8_r4.c: Regenerated.
	* generated/maxloc1_8_r8.c: Regenerated.
	* generated/maxloc1_8_s1.c: Regenerated.
	* generated/maxloc1_8_s4.c: Regenerated.
	* generated/maxloc2_16_s1.c: Regenerated.
	* generated/maxloc2_16_s4.c: Regenerated.
	* generated/maxloc2_4_s1.c: Regenerated.
	* generated/maxloc2_4_s4.c: Regenerated.
	* generated/maxloc2_8_s1.c: Regenerated.
	* generated/maxloc2_8_s4.c: Regenerated.
	* generated/maxval_i1.c: Regenerated.
	* generated/maxval_i16.c: Regenerated.
	* generated/maxval_i2.c: Regenerated.
	* generated/maxval_i4.c: Regenerated.
	* generated/maxval_i8.c: Regenerated.
	* generated/maxval_r10.c: Regenerated.
	* generated/maxval_r16.c: Regenerated.
	* generated/maxval_r4.c: Regenerated.
	* generated/maxval_r8.c: Regenerated.
	* generated/minloc0_16_i1.c: Regenerated.
	* generated/minloc0_16_i16.c: Regenerated.
	* generated/minloc0_16_i2.c: Regenerated.
	* generated/minloc0_16_i4.c: Regenerated.
	* generated/minloc0_16_i8.c: Regenerated.
	* generated/minloc0_16_r10.c: Regenerated.
	* generated/minloc0_16_r16.c: Regenerated.
	* generated/minloc0_16_r4.c: Regenerated.
	* generated/minloc0_16_r8.c: Regenerated.
	* generated/minloc0_16_s1.c: Regenerated.
	* generated/minloc0_16_s4.c: Regenerated.
	* generated/minloc0_4_i1.c: Regenerated.
	* generated/minloc0_4_i16.c: Regenerated.
	* generated/minloc0_4_i2.c: Regenerated.
	* generated/minloc0_4_i4.c: Regenerated.
	* generated/minloc0_4_i8.c: Regenerated.
	* generated/minloc0_4_r10.c: Regenerated.
	* generated/minloc0_4_r16.c: Regenerated.
	* generated/minloc0_4_r4.c: Regenerated.
	* generated/minloc0_4_r8.c: Regenerated.
	* generated/minloc0_4_s1.c: Regenerated.
	* generated/minloc0_4_s4.c: Regenerated.
	* generated/minloc0_8_i1.c: Regenerated.
	* generated/minloc0_8_i16.c: Regenerated.
	* generated/minloc0_8_i2.c: Regenerated.
	* generated/minloc0_8_i4.c: Regenerated.
	* generated/minloc0_8_i8.c: Regenerated.
	* generated/minloc0_8_r10.c: Regenerated.
	* generated/minloc0_8_r16.c: Regenerated.
	* generated/minloc0_8_r4.c: Regenerated.
	* generated/minloc0_8_r8.c: Regenerated.
	* generated/minloc0_8_s1.c: Regenerated.
	* generated/minloc0_8_s4.c: Regenerated.
	* generated/minloc1_16_i1.c: Regenerated.
	* generated/minloc1_16_i16.c: Regenerated.
	* generated/minloc1_16_i2.c: Regenerated.
	* generated/minloc1_16_i4.c: Regenerated.
	* generated/minloc1_16_i8.c: Regenerated.
	* generated/minloc1_16_r10.c: Regenerated.
	* generated/minloc1_16_r16.c: Regenerated.
	* generated/minloc1_16_r4.c: Regenerated.
	* generated/minloc1_16_r8.c: Regenerated.
	* generated/minloc1_16_s1.c: Regenerated.
	* generated/minloc1_16_s4.c: Regenerated.
	* generated/minloc1_4_i1.c: Regenerated.
	* generated/minloc1_4_i16.c: Regenerated.
	* generated/minloc1_4_i2.c: Regenerated.
	* generated/minloc1_4_i4.c: Regenerated.
	* generated/minloc1_4_i8.c: Regenerated.
	* generated/minloc1_4_r10.c: Regenerated.
	* generated/minloc1_4_r16.c: Regenerated.
	* generated/minloc1_4_r4.c: Regenerated.
	* generated/minloc1_4_r8.c: Regenerated.
	* generated/minloc1_4_s1.c: Regenerated.
	* generated/minloc1_4_s4.c: Regenerated.
	* generated/minloc1_8_i1.c: Regenerated.
	* generated/minloc1_8_i16.c: Regenerated.
	* generated/minloc1_8_i2.c: Regenerated.
	* generated/minloc1_8_i4.c: Regenerated.
	* generated/minloc1_8_i8.c: Regenerated.
	* generated/minloc1_8_r10.c: Regenerated.
	* generated/minloc1_8_r16.c: Regenerated.
	* generated/minloc1_8_r4.c: Regenerated.
	* generated/minloc1_8_r8.c: Regenerated.
	* generated/minloc1_8_s1.c: Regenerated.
	* generated/minloc1_8_s4.c: Regenerated.
	* generated/minloc2_16_s1.c: Regenerated.
	* generated/minloc2_16_s4.c: Regenerated.
	* generated/minloc2_4_s1.c: Regenerated.
	* generated/minloc2_4_s4.c: Regenerated.
	* generated/minloc2_8_s1.c: Regenerated.
	* generated/minloc2_8_s4.c: Regenerated.
	* generated/minval_i1.c: Regenerated.
	* generated/minval_i16.c: Regenerated.
	* generated/minval_i2.c: Regenerated.
	* generated/minval_i4.c: Regenerated.
	* generated/minval_i8.c: Regenerated.
	* generated/minval_r10.c: Regenerated.
	* generated/minval_r16.c: Regenerated.
	* generated/minval_r4.c: Regenerated.
	* generated/minval_r8.c: Regenerated.
	* generated/norm2_r10.c: Regenerated.
	* generated/norm2_r16.c: Regenerated.
	* generated/norm2_r4.c: Regenerated.
	* generated/norm2_r8.c: Regenerated.
	* generated/parity_l1.c: Regenerated.
	* generated/parity_l16.c: Regenerated.
	* generated/parity_l2.c: Regenerated.
	* generated/parity_l4.c: Regenerated.
	* generated/parity_l8.c: Regenerated.
	* generated/product_c10.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/product_i8.c: Regenerated.
	* generated/product_r10.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/product_r8.c: Regenerated.
	* generated/sum_c10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/sum_r8.c: Regenerated.

2018-05-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.dg/minmaxloc_12.f90: New test case.
	* gfortran.dg/minmaxloc_13.f90: New test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/minmaxloc_12.f90
    trunk/gcc/testsuite/gfortran.dg/minmaxloc_13.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/generated/iall_i1.c
    trunk/libgfortran/generated/iall_i16.c
    trunk/libgfortran/generated/iall_i2.c
    trunk/libgfortran/generated/iall_i4.c
    trunk/libgfortran/generated/iall_i8.c
    trunk/libgfortran/generated/iany_i1.c
    trunk/libgfortran/generated/iany_i16.c
    trunk/libgfortran/generated/iany_i2.c
    trunk/libgfortran/generated/iany_i4.c
    trunk/libgfortran/generated/iany_i8.c
    trunk/libgfortran/generated/iparity_i1.c
    trunk/libgfortran/generated/iparity_i16.c
    trunk/libgfortran/generated/iparity_i2.c
    trunk/libgfortran/generated/iparity_i4.c
    trunk/libgfortran/generated/iparity_i8.c
    trunk/libgfortran/generated/maxloc0_16_i1.c
    trunk/libgfortran/generated/maxloc0_16_i16.c
    trunk/libgfortran/generated/maxloc0_16_i2.c
    trunk/libgfortran/generated/maxloc0_16_i4.c
    trunk/libgfortran/generated/maxloc0_16_i8.c
    trunk/libgfortran/generated/maxloc0_16_r10.c
    trunk/libgfortran/generated/maxloc0_16_r16.c
    trunk/libgfortran/generated/maxloc0_16_r4.c
    trunk/libgfortran/generated/maxloc0_16_r8.c
    trunk/libgfortran/generated/maxloc0_16_s1.c
    trunk/libgfortran/generated/maxloc0_16_s4.c
    trunk/libgfortran/generated/maxloc0_4_i1.c
    trunk/libgfortran/generated/maxloc0_4_i16.c
    trunk/libgfortran/generated/maxloc0_4_i2.c
    trunk/libgfortran/generated/maxloc0_4_i4.c
    trunk/libgfortran/generated/maxloc0_4_i8.c
    trunk/libgfortran/generated/maxloc0_4_r10.c
    trunk/libgfortran/generated/maxloc0_4_r16.c
    trunk/libgfortran/generated/maxloc0_4_r4.c
    trunk/libgfortran/generated/maxloc0_4_r8.c
    trunk/libgfortran/generated/maxloc0_4_s1.c
    trunk/libgfortran/generated/maxloc0_4_s4.c
    trunk/libgfortran/generated/maxloc0_8_i1.c
    trunk/libgfortran/generated/maxloc0_8_i16.c
    trunk/libgfortran/generated/maxloc0_8_i2.c
    trunk/libgfortran/generated/maxloc0_8_i4.c
    trunk/libgfortran/generated/maxloc0_8_i8.c
    trunk/libgfortran/generated/maxloc0_8_r10.c
    trunk/libgfortran/generated/maxloc0_8_r16.c
    trunk/libgfortran/generated/maxloc0_8_r4.c
    trunk/libgfortran/generated/maxloc0_8_r8.c
    trunk/libgfortran/generated/maxloc0_8_s1.c
    trunk/libgfortran/generated/maxloc0_8_s4.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_16_s1.c
    trunk/libgfortran/generated/maxloc1_16_s4.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_4_s1.c
    trunk/libgfortran/generated/maxloc1_4_s4.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/maxloc1_8_s1.c
    trunk/libgfortran/generated/maxloc1_8_s4.c
    trunk/libgfortran/generated/maxloc2_16_s1.c
    trunk/libgfortran/generated/maxloc2_16_s4.c
    trunk/libgfortran/generated/maxloc2_4_s1.c
    trunk/libgfortran/generated/maxloc2_4_s4.c
    trunk/libgfortran/generated/maxloc2_8_s1.c
    trunk/libgfortran/generated/maxloc2_8_s4.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/minloc0_16_i1.c
    trunk/libgfortran/generated/minloc0_16_i16.c
    trunk/libgfortran/generated/minloc0_16_i2.c
    trunk/libgfortran/generated/minloc0_16_i4.c
    trunk/libgfortran/generated/minloc0_16_i8.c
    trunk/libgfortran/generated/minloc0_16_r10.c
    trunk/libgfortran/generated/minloc0_16_r16.c
    trunk/libgfortran/generated/minloc0_16_r4.c
    trunk/libgfortran/generated/minloc0_16_r8.c
    trunk/libgfortran/generated/minloc0_16_s1.c
    trunk/libgfortran/generated/minloc0_16_s4.c
    trunk/libgfortran/generated/minloc0_4_i1.c
    trunk/libgfortran/generated/minloc0_4_i16.c
    trunk/libgfortran/generated/minloc0_4_i2.c
    trunk/libgfortran/generated/minloc0_4_i4.c
    trunk/libgfortran/generated/minloc0_4_i8.c
    trunk/libgfortran/generated/minloc0_4_r10.c
    trunk/libgfortran/generated/minloc0_4_r16.c
    trunk/libgfortran/generated/minloc0_4_r4.c
    trunk/libgfortran/generated/minloc0_4_r8.c
    trunk/libgfortran/generated/minloc0_4_s1.c
    trunk/libgfortran/generated/minloc0_4_s4.c
    trunk/libgfortran/generated/minloc0_8_i1.c
    trunk/libgfortran/generated/minloc0_8_i16.c
    trunk/libgfortran/generated/minloc0_8_i2.c
    trunk/libgfortran/generated/minloc0_8_i4.c
    trunk/libgfortran/generated/minloc0_8_i8.c
    trunk/libgfortran/generated/minloc0_8_r10.c
    trunk/libgfortran/generated/minloc0_8_r16.c
    trunk/libgfortran/generated/minloc0_8_r4.c
    trunk/libgfortran/generated/minloc0_8_r8.c
    trunk/libgfortran/generated/minloc0_8_s1.c
    trunk/libgfortran/generated/minloc0_8_s4.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_16_s1.c
    trunk/libgfortran/generated/minloc1_16_s4.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_4_s1.c
    trunk/libgfortran/generated/minloc1_4_s4.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/minloc1_8_s1.c
    trunk/libgfortran/generated/minloc1_8_s4.c
    trunk/libgfortran/generated/minloc2_16_s1.c
    trunk/libgfortran/generated/minloc2_16_s4.c
    trunk/libgfortran/generated/minloc2_4_s1.c
    trunk/libgfortran/generated/minloc2_4_s4.c
    trunk/libgfortran/generated/minloc2_8_s1.c
    trunk/libgfortran/generated/minloc2_8_s4.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/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/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/m4/iforeach-s.m4
    trunk/libgfortran/m4/iforeach.m4
    trunk/libgfortran/m4/ifunction-s.m4
    trunk/libgfortran/m4/ifunction.m4
    trunk/libgfortran/m4/maxloc0.m4
    trunk/libgfortran/m4/maxloc0s.m4
    trunk/libgfortran/m4/maxloc1.m4
    trunk/libgfortran/m4/maxloc1s.m4
    trunk/libgfortran/m4/maxloc2s.m4
    trunk/libgfortran/m4/minloc0.m4
    trunk/libgfortran/m4/minloc0s.m4
    trunk/libgfortran/m4/minloc1.m4
    trunk/libgfortran/m4/minloc1s.m4
    trunk/libgfortran/m4/minloc2s.m4
Comment 10 Thomas Koenig 2018-05-10 14:32:26 UTC
Author: tkoenig
Date: Thu May 10 14:31:54 2018
New Revision: 260116

URL: https://gcc.gnu.org/viewcvs?rev=260116&root=gcc&view=rev
Log:
2018-05-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* intrinsic.texi: Document BACK for MINLOC and MAXLOC.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.texi
Comment 11 janus 2018-07-03 06:54:15 UTC
(In reply to Thomas Koenig from comment #4)
> Still to do: FINDLOC and BACK.

It seems that BACK is done by now, while FINDLOC is still to do.
Comment 12 Thomas Koenig 2018-10-07 17:17:41 UTC
Created attachment 44803 [details]
First piece of the work...

This adds the parsing, checking, resolution and calling of the library routines
(if any).

Still a very large piece of work to be done...
Comment 13 Thomas Koenig 2018-10-08 22:17:58 UTC
Created attachment 44813 [details]
Patch with a first version of a library function

At least BACK appears to work already.
Comment 14 Thomas Koenig 2018-10-13 11:57:26 UTC
Created attachment 44834 [details]
Patch for findloc library version without dim

Here's a version which adds findloc support without dim,
both for character and non-character data.
Comment 15 Thomas Koenig 2018-10-15 09:04:35 UTC
Created attachment 44840 [details]
Patch for the library version, minus quite a few bugs

OK, so here is something that people can actually test.

It currently has no support for simplification and no
support for findloc(rank_one_array,value,dim=1), but otherwise
it looks quite good.

If you apply this, the libgfortran/generated/findloc* files will be
added; if you apply it for a second time, everything will be added
twice in the files, which will lead to many confusing error messages :-)

Currently, you have to add -static-libgfortran to the command line
for this to work, because I didn't add the symbols to gfortran.map
yet (but this should be straightforward).

Design decision: To avoid combinatorial explosion, the library
files use index_type only.  For other integer kinds, the
results are converted on return.
Comment 16 Thomas Koenig 2018-10-15 09:06:40 UTC
Here are test cases. I tried to walk through most of the
code paths.

! { dg-do run }
! Various tests with findloc.
program main
  implicit none
  real, dimension(2,2) :: a, b
  integer, dimension(2,3) :: c
  logical, dimension(2,2) :: lo
  integer, dimension(:), allocatable :: e
  a = reshape([1.,2.,3.,4.], shape(a))
  b = reshape([1.,2.,1.,2.], shape(b))

  lo = .true.

  if (any(findloc(a, 5.) /= [0,0])) stop 1
  if (any(findloc(a, 5., back=.true.) /= [0,0])) stop 2
  if (any(findloc(a, 2.) /= [2,1])) stop 2
  if (any(findloc(a, 2. ,back=.true.) /= [2,1])) stop 3

  if (any(findloc(a,3.,mask=lo) /= [1,2])) stop 4
  if (any(findloc(a,3,mask=.true.) /= [1,2])) stop 5
  lo(1,2) = .false.
  if (any(findloc(a,3.,mask=lo) /= [0,0])) stop 6
  if (any(findloc(b,2.) /= [2,1])) stop 7
  if (any(findloc(b,2.,back=.true.) /= [2,2])) stop 8
  if (any(findloc(b,1.,mask=lo,back=.true.) /= [1,1])) stop 9
  if (any(findloc(b,1.,mask=.false.) /= [0,0])) stop 10

  c = reshape([1,2,2,2,-9,6], shape(c))
  if (any(findloc(c,value=2,dim=1) /= [2,1,0])) stop 11
  if (any(findloc(c,value=2,dim=2) /= [2,1])) stop 12
end program main

! { dg-do run }
! Various tests with findloc with character variables.
program main
  character(len=2) :: a(3,3), c(3,3), d(3,4)
  character(len=3) :: b(3,3)
  integer :: ret(2)                                                                                                                  
  integer :: i,j                                                                                                                     
  character(len=3) :: s                                                                                                              
  logical :: lo                                                                                                                      
  logical, dimension(3,4) :: msk                                                                                                     
  data a /"11", "21", "31", "12", "22", "32", "13", "23", "33" /                                                                     
  data b /"11 ", "21 ", "31 ", "12 ", "22 ", "32 ", "13 ", "23 ", "33 " /                                                            
  if (any(findloc(a,"11 ") /= [1,1])) stop 1                                                                                         
  ret = findloc(b,"31")                                                                                                              
  do j=1,3                                                                                                                           
     do i=1,3                                                                                                                        
        write(unit=s,fmt='(2I1," ")') i,j                                                                                            
        ret = findloc(b,s)                                                                                                           
        if (b(ret(1),ret(2)) /= s) stop 2                                                                                            
     end do                                                                                                                          
  end do                                                                                                                             
                                                                                                                                     
  if (any(findloc(b(::2,::2),"13") /= [1,2])) stop 3                                                                                 
                                                                                                                                     
  do j=1,3                                                                                                                           
    do i=1,3                                                                                                                         
      write(unit=c(i,j),fmt='(I2)') 2+i-j                                                                                            
    end do
  end do

  if (any(findloc(c," 1") /= [1,2])) stop 4
  if (any(findloc(c," 1", back=.true.) /= [2,3])) stop 5
  if (any(findloc(c," 1", back=.true., mask=.false.) /= [0,0])) stop 6

  lo = .true.
  if (any(findloc(c," 2", dim=1) /= [1,2,3])) stop 7
  if (any(findloc(c," 2",dim=1,mask=lo) /= [1,2,3])) stop 8

  if (any(findloc(c," 2", dim=1,back=.true.) /= [1,2,3])) stop 9
  if (any(findloc(c," 2",dim=1,mask=lo,back=.true.) /= [1,2,3])) stop 10
  do j=1,4
     do i=1,3
        if (j<= i) then
           d(i,j) = "AA"
        else
           d(i,j) = "BB"
        end if
     end do
  end do
  print '(4A3)', transpose(d)
  if (any(findloc(d,"AA") /= [1,1])) stop 11
  if (any(findloc(d,"BB") /= [1,2])) stop 12
  msk = .true.
  if (any(findloc(d,"AA", mask=msk) /= [1,1])) stop 11
  if (any(findloc(d,"BB", mask=msk) /= [1,2])) stop 12
  if (any(findloc(d,"AA", dim=1) /= [1,2,3,0])) stop 13
  if (any(findloc(d,"BB", dim=1) /= [0,1,1,1])) stop 14
  if (any(findloc(d,"AA", dim=2) /= [1,1,1])) stop 15
  if (any(findloc(d,"BB", dim=2) /= [2,3,4])) stop 16
  if (any(findloc(d,"AA", dim=1,mask=msk) /= [1,2,3,0])) stop 17
  if (any(findloc(d,"BB", dim=1,mask=msk) /= [0,1,1,1])) stop 18
  if (any(findloc(d,"AA", dim=2,mask=msk) /= [1,1,1])) stop 19
  if (any(findloc(d,"BB", dim=2,mask=msk) /= [2,3,4])) stop 20

  if (any(findloc(d,"AA", dim=1, back=.true.) /= [3,3,3,0])) stop 21
  if (any(findloc(d,"AA", dim=1, back=.true., mask=msk) /= [3,3,3,0])) stop 22
  if (any(findloc(d,"BB", dim=2, back=.true.) /= [4,4,4])) stop 23
  if (any(findloc(d,"BB", dim=2, back=.true.,mask=msk) /= [4,4,4])) stop 24

  msk(1,:) = .false.
  print '(4L3)', transpose(msk)
  if (any(findloc(d,"AA", dim=1,mask=msk) /= [2,2,3,0])) stop 21
  if (any(findloc(d,"BB", dim=2,mask=msk) /= [0,3,4])) stop 22
  if (any(findloc(d,"AA", dim=2, mask=msk, back=.true.) /= [0,2,3])) stop 23
  if (any(findloc(d,"AA", dim=1, mask=msk, back=.true.) /= [3,3,3,0])) stop 24

end program main
Comment 17 Thomas Koenig 2018-10-28 11:05:36 UTC
Author: tkoenig
Date: Sun Oct 28 11:05:05 2018
New Revision: 265570

URL: https://gcc.gnu.org/viewcvs?rev=265570&root=gcc&view=rev
Log:
2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.h (gfc_isym_id): Add GFC_ISYM_FINDLOC.
	(gfc_check_f): Add f6fl field.
	(gfc_simplify_f): Add f6 field.
	(gfc_resolve_f): Likewise.
	(gfc_type_letter): Add optional logical_equas_int flag.
	* check.c (intrinsic_type_check): New function.
	(gfc_check_findloc): New function.
	* intrinsics.c (gfc_type_letter): If logical_equals_int is
	set, act accordingly.
	(add_sym_5ml):  Reformat comment.
	(add_sym_6fl): New function.
	(add_functions): Add findloc.
	(check_arglist): Add sixth argument, handle it.
	(resolve_intrinsic): Likewise.
	(check_specific): Handle findloc.
	* intrinsic.h (gfc_check_findloc): Add prototype.
	(gfc_simplify_findloc): Likewise.
	(gfc_resolve_findloc): Likewise.
	(MAX_INTRINSIC_ARGS): Adjust.
	* iresolve.c (gfc_resolve_findloc): New function.
	* simplify.c (gfc_simplify_minmaxloc): Make static.
	(simplify_findloc_to_scalar): New function.
	(simplify_findloc_nodim): New function.
	(simplify_findloc_to_array): New function.
	(gfc_simplify_findloc): New function.
	(gfc_conv_intrinsic_findloc): New function.
	(gfc_conv_intrinsic_function): Handle GFC_ISYM_FINDLOC.
	(gfc_is_intrinsic_libcall): Likewise.

2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* Makefile.am: Add files for findloc.
	* Makefile.in: Regenerated.
	* libgfortran.h (gfc_array_index_type): Add.
	(gfc_array_s1): Add using GFC_UINTEGER_1.
	(gfc_array_s4): Likewise.
	Replace unnecessary comment.
	(HAVE_GFC_UINTEGER_1): Define.
	(HAVE_GFC_UINTEGER_4): Define.
	* m4/findloc0.m4: New file.
	* m4/findloc0s.m4: New file.
	* m4/findloc1.m4: New file.
	* m4/findloc1s.m4: New file.
	* m4/findloc2s.m4: New file.
	* m4/ifindloc0.m4: New file.
	* m4/ifindloc1.m4: New file.
	* m4/ifindloc2.m4: New file.
	* m4/iparm.m4: Use unsigned integer for characters.
        * generated/findloc0_c16.c: New file.
        * generated/findloc0_c4.c: New file.
        * generated/findloc0_c8.c: New file.
        * generated/findloc0_i1.c: New file.
        * generated/findloc0_i16.c: New file.
        * generated/findloc0_i2.c: New file.
        * generated/findloc0_i4.c: New file.
        * generated/findloc0_i8.c: New file.
        * generated/findloc0_r16.c: New file.
        * generated/findloc0_r4.c: New file.
        * generated/findloc0_r8.c: New file.
        * generated/findloc0_s1.c: New file.
        * generated/findloc0_s4.c: New file.
        * generated/findloc1_c16.c: New file.
        * generated/findloc1_c4.c: New file.
        * generated/findloc1_c8.c: New file.
        * generated/findloc1_i1.c: New file.
        * generated/findloc1_i16.c: New file.
        * generated/findloc1_i2.c: New file.
        * generated/findloc1_i4.c: New file.
        * generated/findloc1_i8.c: New file.
        * generated/findloc1_r16.c: New file.
        * generated/findloc1_r4.c: New file.
        * generated/findloc1_r8.c: New file.
        * generated/findloc1_s1.c: New file.
        * generated/findloc1_s4.c: New file.
        * generated/findloc2_s1.c: New file.
        * generated/findloc2_s4.c: New file.
        * generated/maxloc0_16_s1.c: Regenerated.
        * generated/maxloc0_16_s4.c: Regenerated.
        * generated/maxloc0_4_s1.c: Regenerated.
        * generated/maxloc0_4_s4.c: Regenerated.
        * generated/maxloc0_8_s1.c: Regenerated.
        * generated/maxloc0_8_s4.c: Regenerated.
        * generated/maxloc1_16_s1.c: Regenerated.
        * generated/maxloc1_16_s4.c: Regenerated.
        * generated/maxloc1_4_s1.c: Regenerated.
        * generated/maxloc1_4_s4.c: Regenerated.
        * generated/maxloc1_8_s1.c: Regenerated.
        * generated/maxloc1_8_s4.c: Regenerated.
        * generated/maxloc2_16_s1.c: Regenerated.
        * generated/maxloc2_16_s4.c: Regenerated.
        * generated/maxloc2_4_s1.c: Regenerated.
        * generated/maxloc2_4_s4.c: Regenerated.
        * generated/maxloc2_8_s1.c: Regenerated.
        * generated/maxloc2_8_s4.c: Regenerated.
        * generated/maxval0_s1.c: Regenerated.
        * generated/maxval0_s4.c: Regenerated.
        * generated/maxval1_s1.c: Regenerated.
        * generated/maxval1_s4.c: Regenerated.
        * generated/minloc0_16_s1.c: Regenerated.
        * generated/minloc0_16_s4.c: Regenerated.
        * generated/minloc0_4_s1.c: Regenerated.
        * generated/minloc0_4_s4.c: Regenerated.
        * generated/minloc0_8_s1.c: Regenerated.
        * generated/minloc0_8_s4.c: Regenerated.
        * generated/minloc1_16_s1.c: Regenerated.
        * generated/minloc1_16_s4.c: Regenerated.
        * generated/minloc1_4_s1.c: Regenerated.
        * generated/minloc1_4_s4.c: Regenerated.
        * generated/minloc1_8_s1.c: Regenerated.
        * generated/minloc1_8_s4.c: Regenerated.
        * generated/minloc2_16_s1.c: Regenerated.
        * generated/minloc2_16_s4.c: Regenerated.
        * generated/minloc2_4_s1.c: Regenerated.
        * generated/minloc2_4_s4.c: Regenerated.
        * generated/minloc2_8_s1.c: Regenerated.
        * generated/minloc2_8_s4.c: Regenerated.
        * generated/minval0_s1.c: Regenerated.
        * generated/minval0_s4.c: Regenerated.
        * generated/minval1_s1.c: Regenerated.
        * generated/minval1_s4.c: Regenerated.

2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.dg/findloc_1.f90: New test.
	* gfortran.dg/findloc_2.f90: New test.
	* gfortran.dg/findloc_3.f90: New test.
	* gfortran.dg/findloc_4.f90: New test.
	* gfortran.dg/findloc_5.f90: New test.
	* gfortran.dg/findloc_6.f90: New test.

Added:
    trunk/libgfortran/generated/findloc0_c16.c
    trunk/libgfortran/generated/findloc0_c4.c
    trunk/libgfortran/generated/findloc0_c8.c
    trunk/libgfortran/generated/findloc0_i1.c
    trunk/libgfortran/generated/findloc0_i16.c
    trunk/libgfortran/generated/findloc0_i2.c
    trunk/libgfortran/generated/findloc0_i4.c
    trunk/libgfortran/generated/findloc0_i8.c
    trunk/libgfortran/generated/findloc0_r16.c
    trunk/libgfortran/generated/findloc0_r4.c
    trunk/libgfortran/generated/findloc0_r8.c
    trunk/libgfortran/generated/findloc0_s1.c
    trunk/libgfortran/generated/findloc0_s4.c
    trunk/libgfortran/generated/findloc1_c16.c
    trunk/libgfortran/generated/findloc1_c4.c
    trunk/libgfortran/generated/findloc1_c8.c
    trunk/libgfortran/generated/findloc1_i1.c
    trunk/libgfortran/generated/findloc1_i16.c
    trunk/libgfortran/generated/findloc1_i2.c
    trunk/libgfortran/generated/findloc1_i4.c
    trunk/libgfortran/generated/findloc1_i8.c
    trunk/libgfortran/generated/findloc1_r16.c
    trunk/libgfortran/generated/findloc1_r4.c
    trunk/libgfortran/generated/findloc1_r8.c
    trunk/libgfortran/generated/findloc1_s1.c
    trunk/libgfortran/generated/findloc1_s4.c
    trunk/libgfortran/generated/findloc2_s1.c
    trunk/libgfortran/generated/findloc2_s4.c
    trunk/libgfortran/m4/findloc0.m4
    trunk/libgfortran/m4/findloc0s.m4
    trunk/libgfortran/m4/findloc1.m4
    trunk/libgfortran/m4/findloc1s.m4
    trunk/libgfortran/m4/findloc2s.m4
    trunk/libgfortran/m4/ifindloc0.m4
    trunk/libgfortran/m4/ifindloc1.m4
    trunk/libgfortran/m4/ifindloc2.m4
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/expr.c
    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/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in
    trunk/libgfortran/generated/maxloc0_16_s1.c
    trunk/libgfortran/generated/maxloc0_16_s4.c
    trunk/libgfortran/generated/maxloc0_4_s1.c
    trunk/libgfortran/generated/maxloc0_4_s4.c
    trunk/libgfortran/generated/maxloc0_8_s1.c
    trunk/libgfortran/generated/maxloc0_8_s4.c
    trunk/libgfortran/generated/maxloc1_16_s1.c
    trunk/libgfortran/generated/maxloc1_16_s4.c
    trunk/libgfortran/generated/maxloc1_4_s1.c
    trunk/libgfortran/generated/maxloc1_4_s4.c
    trunk/libgfortran/generated/maxloc1_8_s1.c
    trunk/libgfortran/generated/maxloc1_8_s4.c
    trunk/libgfortran/generated/maxloc2_16_s1.c
    trunk/libgfortran/generated/maxloc2_16_s4.c
    trunk/libgfortran/generated/maxloc2_4_s1.c
    trunk/libgfortran/generated/maxloc2_4_s4.c
    trunk/libgfortran/generated/maxloc2_8_s1.c
    trunk/libgfortran/generated/maxloc2_8_s4.c
    trunk/libgfortran/generated/maxval0_s1.c
    trunk/libgfortran/generated/maxval0_s4.c
    trunk/libgfortran/generated/maxval1_s1.c
    trunk/libgfortran/generated/maxval1_s4.c
    trunk/libgfortran/generated/minloc0_16_s1.c
    trunk/libgfortran/generated/minloc0_16_s4.c
    trunk/libgfortran/generated/minloc0_4_s1.c
    trunk/libgfortran/generated/minloc0_4_s4.c
    trunk/libgfortran/generated/minloc0_8_s1.c
    trunk/libgfortran/generated/minloc0_8_s4.c
    trunk/libgfortran/generated/minloc1_16_s1.c
    trunk/libgfortran/generated/minloc1_16_s4.c
    trunk/libgfortran/generated/minloc1_4_s1.c
    trunk/libgfortran/generated/minloc1_4_s4.c
    trunk/libgfortran/generated/minloc1_8_s1.c
    trunk/libgfortran/generated/minloc1_8_s4.c
    trunk/libgfortran/generated/minloc2_16_s1.c
    trunk/libgfortran/generated/minloc2_16_s4.c
    trunk/libgfortran/generated/minloc2_4_s1.c
    trunk/libgfortran/generated/minloc2_4_s4.c
    trunk/libgfortran/generated/minloc2_8_s1.c
    trunk/libgfortran/generated/minloc2_8_s4.c
    trunk/libgfortran/generated/minval0_s1.c
    trunk/libgfortran/generated/minval0_s4.c
    trunk/libgfortran/generated/minval1_s1.c
    trunk/libgfortran/generated/minval1_s4.c
    trunk/libgfortran/gfortran.map
    trunk/libgfortran/libgfortran.h
    trunk/libgfortran/m4/iparm.m4
Comment 18 Thomas Koenig 2018-10-28 11:08:13 UTC
Implemented, closing.
Comment 19 Thomas Koenig 2018-11-01 11:37:40 UTC
Author: tkoenig
Date: Thu Nov  1 11:37:08 2018
New Revision: 265715

URL: https://gcc.gnu.org/viewcvs?rev=265715&root=gcc&view=rev
Log:
2018-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.texi (File format of unformatted sequential files):
	Replace random comma with period.
	* intrinsic.texi (Intrinsic Procedures): Add FINDLOC to menu.
	(FINDLOC): Document.
	(MAXLOC): Add refrence to FINDLOC.
	(MINLOC): Likewise.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.texi
    trunk/gcc/fortran/intrinsic.texi
Comment 20 Thomas Koenig 2018-11-01 20:13:29 UTC
Author: tkoenig
Date: Thu Nov  1 20:12:57 2018
New Revision: 265732

URL: https://gcc.gnu.org/viewcvs?rev=265732&root=gcc&view=rev
Log:
2017-11-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/54613
    * gfortran.dg/findloc_1.f90: Actually commit.
    * gfortran.dg/findloc_2.f90: Actually commit.
    * gfortran.dg/findloc_3.f90: Actually commit.
    * gfortran.dg/findloc_4.f90: Actually commit.
    * gfortran.dg/findloc_5.f90: Actually commit.
    * gfortran.dg/findloc_6.f90: Actually commit.


Added:
    trunk/gcc/testsuite/gfortran.dg/findloc_1.f90
    trunk/gcc/testsuite/gfortran.dg/findloc_2.f90
    trunk/gcc/testsuite/gfortran.dg/findloc_3.f90
    trunk/gcc/testsuite/gfortran.dg/findloc_4.f90
    trunk/gcc/testsuite/gfortran.dg/findloc_5.f90
    trunk/gcc/testsuite/gfortran.dg/findloc_6.f90
    trunk/gcc/testsuite/gfortran.dg/findloc_7.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 21 Jakub Jelinek 2019-05-17 17:24:02 UTC
Author: jakub
Date: Fri May 17 17:23:30 2019
New Revision: 271334

URL: https://gcc.gnu.org/viewcvs?rev=271334&root=gcc&view=rev
Log:
	PR fortran/54613
	* gfortran.map (GFORTRAN_9.2): New symbol version, export
	_gfortran_{,m,s}findloc0_i2 in it.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/gfortran.map
Comment 22 Jakub Jelinek 2019-05-17 17:24:59 UTC
Author: jakub
Date: Fri May 17 17:24:27 2019
New Revision: 271335

URL: https://gcc.gnu.org/viewcvs?rev=271335&root=gcc&view=rev
Log:
	PR fortran/54613
	* gfortran.map (GFORTRAN_9.2): Export _gfortran_{,m,s}findloc{0,1}_r10.
	* Makefile.am (i_findloc0_c): Add $(srcdir)/generated/findloc0_r10.c.
	(i_findloc1_c): Add $(srcdir)/generated/findloc1_r10.c.
	* Makefile.in: Regenerated.
	* generated/findloc0_r10.c: Generated.
	* generated/findloc1_r10.c: Generated.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in
    trunk/libgfortran/gfortran.map
Comment 23 Jakub Jelinek 2019-05-17 17:51:26 UTC
Author: jakub
Date: Fri May 17 17:50:55 2019
New Revision: 271336

URL: https://gcc.gnu.org/viewcvs?rev=271336&root=gcc&view=rev
Log:
	PR fortran/54613
	* gfortran.map (GFORTRAN_9.2): Export _gfortran_{,m,s}findloc{0,1}_r10.
	* Makefile.am (i_findloc0_c): Add $(srcdir)/generated/findloc0_r10.c.
	(i_findloc1_c): Add $(srcdir)/generated/findloc1_r10.c.
	* Makefile.in: Regenerated.
	* generated/findloc0_r10.c: Generated.
	* generated/findloc1_r10.c: Generated.

Added:
    trunk/libgfortran/generated/findloc0_r10.c
    trunk/libgfortran/generated/findloc1_r10.c
Comment 24 Jakub Jelinek 2019-05-17 19:55:17 UTC
Author: jakub
Date: Fri May 17 19:54:46 2019
New Revision: 271357

URL: https://gcc.gnu.org/viewcvs?rev=271357&root=gcc&view=rev
Log:
	PR fortran/54613
	* gfortran.map (GFORTRAN_9.2): New symbol version, export
	_gfortran_{,m,s}findloc0_i2 in it.

Modified:
    branches/gcc-9-branch/libgfortran/ChangeLog
    branches/gcc-9-branch/libgfortran/gfortran.map
Comment 25 Jakub Jelinek 2019-05-17 19:56:45 UTC
Author: jakub
Date: Fri May 17 19:56:14 2019
New Revision: 271358

URL: https://gcc.gnu.org/viewcvs?rev=271358&root=gcc&view=rev
Log:
	PR fortran/54613
	* gfortran.map (GFORTRAN_9.2): Export _gfortran_{,m,s}findloc{0,1}_r10.
	* Makefile.am (i_findloc0_c): Add $(srcdir)/generated/findloc0_r10.c.
	(i_findloc1_c): Add $(srcdir)/generated/findloc1_r10.c.
	* Makefile.in: Regenerated.
	* generated/findloc0_r10.c: Generated.
	* generated/findloc1_r10.c: Generated.

Added:
    branches/gcc-9-branch/libgfortran/generated/findloc0_r10.c
    branches/gcc-9-branch/libgfortran/generated/findloc1_r10.c
Modified:
    branches/gcc-9-branch/libgfortran/ChangeLog
    branches/gcc-9-branch/libgfortran/Makefile.am
    branches/gcc-9-branch/libgfortran/Makefile.in
    branches/gcc-9-branch/libgfortran/gfortran.map