Commit 80927a56 by Jakub Jelinek Committed by Jakub Jelinek

re PR fortran/40643 (maxloc/minloc: Wrong result for NaN at position 1)

	PR fortran/40643
	PR fortran/31067
	* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc,
	gfc_conv_intrinsic_minmaxval): Handle Infinities and NaNs properly,
	optimize.
	* trans-array.c (gfc_trans_scalarized_loop_end): No longer static.
	* trans-array.h (gfc_trans_scalarized_loop_end): New prototype.

	* libgfortran.h (GFC_REAL_4_INFINITY, GFC_REAL_8_INFINITY,
	GFC_REAL_10_INFINITY, GFC_REAL_16_INFINITY, GFC_REAL_4_QUIET_NAN,
	GFC_REAL_8_QUIET_NAN, GFC_REAL_10_QUIET_NAN, GFC_REAL_16_QUIET_NAN):
	Define.
	* m4/iparm.m4 (atype_inf, atype_nan): Define.
	* m4/ifunction.m4: Formatting.
	* m4/iforeach.m4: Likewise.
	(START_FOREACH_FUNCTION): Initialize dest to all 1s, not all 0s.
	(START_FOREACH_BLOCK, FINISH_FOREACH_FUNCTION,
	FINISH_MASKED_FOREACH_FUNCTION): Run foreach block inside a loop
	until count[0] == extent[0].
	* m4/minval.m4: Formatting.  Handle NaNs and infinities.  Optimize.
	* m4/maxval.m4: Likewise.
	* m4/minloc0.m4: Likewise.
	* m4/maxloc0.m4: Likewise.
	* m4/minloc1.m4: Likewise.
	* m4/maxloc1.m4: Likewise.
	* generated/maxloc0_16_i16.c: Regenerated.
	* generated/maxloc0_16_i1.c: Likewise.
	* generated/maxloc0_16_i2.c: Likewise.
	* generated/maxloc0_16_i4.c: Likewise.
	* generated/maxloc0_16_i8.c: Likewise.
	* generated/maxloc0_16_r10.c: Likewise.
	* generated/maxloc0_16_r16.c: Likewise.
	* generated/maxloc0_16_r4.c: Likewise.
	* generated/maxloc0_16_r8.c: Likewise.
	* generated/maxloc0_4_i16.c: Likewise.
	* generated/maxloc0_4_i1.c: Likewise.
	* generated/maxloc0_4_i2.c: Likewise.
	* generated/maxloc0_4_i4.c: Likewise.
	* generated/maxloc0_4_i8.c: Likewise.
	* generated/maxloc0_4_r10.c: Likewise.
	* generated/maxloc0_4_r16.c: Likewise.
	* generated/maxloc0_4_r4.c: Likewise.
	* generated/maxloc0_4_r8.c: Likewise.
	* generated/maxloc0_8_i16.c: Likewise.
	* generated/maxloc0_8_i1.c: Likewise.
	* generated/maxloc0_8_i2.c: Likewise.
	* generated/maxloc0_8_i4.c: Likewise.
	* generated/maxloc0_8_i8.c: Likewise.
	* generated/maxloc0_8_r10.c: Likewise.
	* generated/maxloc0_8_r16.c: Likewise.
	* generated/maxloc0_8_r4.c: Likewise.
	* generated/maxloc0_8_r8.c: Likewise.
	* generated/maxloc1_16_i16.c: Likewise.
	* generated/maxloc1_16_i1.c: Likewise.
	* generated/maxloc1_16_i2.c: Likewise.
	* generated/maxloc1_16_i4.c: Likewise.
	* generated/maxloc1_16_i8.c: Likewise.
	* generated/maxloc1_16_r10.c: Likewise.
	* generated/maxloc1_16_r16.c: Likewise.
	* generated/maxloc1_16_r4.c: Likewise.
	* generated/maxloc1_16_r8.c: Likewise.
	* generated/maxloc1_4_i16.c: Likewise.
	* generated/maxloc1_4_i1.c: Likewise.
	* generated/maxloc1_4_i2.c: Likewise.
	* generated/maxloc1_4_i4.c: Likewise.
	* generated/maxloc1_4_i8.c: Likewise.
	* generated/maxloc1_4_r10.c: Likewise.
	* generated/maxloc1_4_r16.c: Likewise.
	* generated/maxloc1_4_r4.c: Likewise.
	* generated/maxloc1_4_r8.c: Likewise.
	* generated/maxloc1_8_i16.c: Likewise.
	* generated/maxloc1_8_i1.c: Likewise.
	* generated/maxloc1_8_i2.c: Likewise.
	* generated/maxloc1_8_i4.c: Likewise.
	* generated/maxloc1_8_i8.c: Likewise.
	* generated/maxloc1_8_r10.c: Likewise.
	* generated/maxloc1_8_r16.c: Likewise.
	* generated/maxloc1_8_r4.c: Likewise.
	* generated/maxloc1_8_r8.c: Likewise.
	* generated/maxval_i16.c: Likewise.
	* generated/maxval_i1.c: Likewise.
	* generated/maxval_i2.c: Likewise.
	* generated/maxval_i4.c: Likewise.
	* generated/maxval_i8.c: Likewise.
	* generated/maxval_r10.c: Likewise.
	* generated/maxval_r16.c: Likewise.
	* generated/maxval_r4.c: Likewise.
	* generated/maxval_r8.c: Likewise.
	* generated/minloc0_16_i16.c: Likewise.
	* generated/minloc0_16_i1.c: Likewise.
	* generated/minloc0_16_i2.c: Likewise.
	* generated/minloc0_16_i4.c: Likewise.
	* generated/minloc0_16_i8.c: Likewise.
	* generated/minloc0_16_r10.c: Likewise.
	* generated/minloc0_16_r16.c: Likewise.
	* generated/minloc0_16_r4.c: Likewise.
	* generated/minloc0_16_r8.c: Likewise.
	* generated/minloc0_4_i16.c: Likewise.
	* generated/minloc0_4_i1.c: Likewise.
	* generated/minloc0_4_i2.c: Likewise.
	* generated/minloc0_4_i4.c: Likewise.
	* generated/minloc0_4_i8.c: Likewise.
	* generated/minloc0_4_r10.c: Likewise.
	* generated/minloc0_4_r16.c: Likewise.
	* generated/minloc0_4_r4.c: Likewise.
	* generated/minloc0_4_r8.c: Likewise.
	* generated/minloc0_8_i16.c: Likewise.
	* generated/minloc0_8_i1.c: Likewise.
	* generated/minloc0_8_i2.c: Likewise.
	* generated/minloc0_8_i4.c: Likewise.
	* generated/minloc0_8_i8.c: Likewise.
	* generated/minloc0_8_r10.c: Likewise.
	* generated/minloc0_8_r16.c: Likewise.
	* generated/minloc0_8_r4.c: Likewise.
	* generated/minloc0_8_r8.c: Likewise.
	* generated/minloc1_16_i16.c: Likewise.
	* generated/minloc1_16_i1.c: Likewise.
	* generated/minloc1_16_i2.c: Likewise.
	* generated/minloc1_16_i4.c: Likewise.
	* generated/minloc1_16_i8.c: Likewise.
	* generated/minloc1_16_r10.c: Likewise.
	* generated/minloc1_16_r16.c: Likewise.
	* generated/minloc1_16_r4.c: Likewise.
	* generated/minloc1_16_r8.c: Likewise.
	* generated/minloc1_4_i16.c: Likewise.
	* generated/minloc1_4_i1.c: Likewise.
	* generated/minloc1_4_i2.c: Likewise.
	* generated/minloc1_4_i4.c: Likewise.
	* generated/minloc1_4_i8.c: Likewise.
	* generated/minloc1_4_r10.c: Likewise.
	* generated/minloc1_4_r16.c: Likewise.
	* generated/minloc1_4_r4.c: Likewise.
	* generated/minloc1_4_r8.c: Likewise.
	* generated/minloc1_8_i16.c: Likewise.
	* generated/minloc1_8_i1.c: Likewise.
	* generated/minloc1_8_i2.c: Likewise.
	* generated/minloc1_8_i4.c: Likewise.
	* generated/minloc1_8_i8.c: Likewise.
	* generated/minloc1_8_r10.c: Likewise.
	* generated/minloc1_8_r16.c: Likewise.
	* generated/minloc1_8_r4.c: Likewise.
	* generated/minloc1_8_r8.c: Likewise.
	* generated/minval_i16.c: Likewise.
	* generated/minval_i1.c: Likewise.
	* generated/minval_i2.c: Likewise.
	* generated/minval_i4.c: Likewise.
	* generated/minval_i8.c: Likewise.
	* generated/minval_r10.c: Likewise.
	* generated/minval_r16.c: Likewise.
	* generated/minval_r4.c: Likewise.
	* generated/minval_r8.c: Likewise.
	* generated/product_c10.c: Likewise.
	* generated/product_c16.c: Likewise.
	* generated/product_c4.c: Likewise.
	* generated/product_c8.c: Likewise.
	* generated/product_i16.c: Likewise.
	* generated/product_i1.c: Likewise.
	* generated/product_i2.c: Likewise.
	* generated/product_i4.c: Likewise.
	* generated/product_i8.c: Likewise.
	* generated/product_r10.c: Likewise.
	* generated/product_r16.c: Likewise.
	* generated/product_r4.c: Likewise.
	* generated/product_r8.c: Likewise.
	* generated/sum_c10.c: Likewise.
	* generated/sum_c16.c: Likewise.
	* generated/sum_c4.c: Likewise.
	* generated/sum_c8.c: Likewise.
	* generated/sum_i16.c: Likewise.
	* generated/sum_i1.c: Likewise.
	* generated/sum_i2.c: Likewise.
	* generated/sum_i4.c: Likewise.
	* generated/sum_i8.c: Likewise.
	* generated/sum_r10.c: Likewise.
	* generated/sum_r16.c: Likewise.
	* generated/sum_r4.c: Likewise.
	* generated/sum_r8.c: Likewise.

	* gfortran.dg/maxlocval_2.f90: New test.
	* gfortran.dg/maxlocval_3.f90: New test.
	* gfortran.dg/maxlocval_4.f90: New test.
	* gfortran.dg/minlocval_1.f90: New test.
	* gfortran.dg/minlocval_2.f90: New test.
	* gfortran.dg/minlocval_3.f90: New test.
	* gfortran.dg/minlocval_4.f90: New test.

From-SVN: r150041
parent 3a802a9e
2009-07-24 Jakub Jelinek <jakub@redhat.com>
PR fortran/40643
PR fortran/31067
* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc,
gfc_conv_intrinsic_minmaxval): Handle Infinities and NaNs properly,
optimize.
* trans-array.c (gfc_trans_scalarized_loop_end): No longer static.
* trans-array.h (gfc_trans_scalarized_loop_end): New prototype.
2009-07-23 Jakub Jelinek <jakub@redhat.com> 2009-07-23 Jakub Jelinek <jakub@redhat.com>
PR fortran/40839 PR fortran/40839
......
...@@ -2755,7 +2755,7 @@ gfc_start_scalarized_body (gfc_loopinfo * loop, stmtblock_t * pbody) ...@@ -2755,7 +2755,7 @@ gfc_start_scalarized_body (gfc_loopinfo * loop, stmtblock_t * pbody)
/* Generates the actual loop code for a scalarization loop. */ /* Generates the actual loop code for a scalarization loop. */
static void void
gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n, gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n,
stmtblock_t * pbody) stmtblock_t * pbody)
{ {
...@@ -2822,7 +2822,8 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n, ...@@ -2822,7 +2822,8 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n,
loopbody = gfc_finish_block (pbody); loopbody = gfc_finish_block (pbody);
/* Initialize the loopvar. */ /* Initialize the loopvar. */
gfc_add_modify (&loop->code[n], loop->loopvar[n], loop->from[n]); if (loop->loopvar[n] != loop->from[n])
gfc_add_modify (&loop->code[n], loop->loopvar[n], loop->from[n]);
exit_label = gfc_build_label_decl (NULL_TREE); exit_label = gfc_build_label_decl (NULL_TREE);
......
/* Header for array handling functions /* Header for array handling functions
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Paul Brook Contributed by Paul Brook
...@@ -84,6 +84,8 @@ void gfc_copy_loopinfo_to_se (gfc_se *, gfc_loopinfo *); ...@@ -84,6 +84,8 @@ void gfc_copy_loopinfo_to_se (gfc_se *, gfc_loopinfo *);
/* Marks the start of a scalarized expression, and declares loop variables. */ /* Marks the start of a scalarized expression, and declares loop variables. */
void gfc_start_scalarized_body (gfc_loopinfo *, stmtblock_t *); void gfc_start_scalarized_body (gfc_loopinfo *, stmtblock_t *);
/* Generates one actual loop for a scalarized expression. */
void gfc_trans_scalarized_loop_end (gfc_loopinfo *, int, stmtblock_t *);
/* Generates the actual loops for a scalarized expression. */ /* Generates the actual loops for a scalarized expression. */
void gfc_trans_scalarizing_loops (gfc_loopinfo *, stmtblock_t *); void gfc_trans_scalarizing_loops (gfc_loopinfo *, stmtblock_t *);
/* Mark the end of the main loop body and the start of the copying loop. */ /* Mark the end of the main loop body and the start of the copying loop. */
......
2009-07-24 Jakub Jelinek <jakub@redhat.com>
PR fortran/40643
PR fortran/31067
* gfortran.dg/maxlocval_2.f90: New test.
* gfortran.dg/maxlocval_3.f90: New test.
* gfortran.dg/maxlocval_4.f90: New test.
* gfortran.dg/minlocval_1.f90: New test.
* gfortran.dg/minlocval_2.f90: New test.
* gfortran.dg/minlocval_3.f90: New test.
* gfortran.dg/minlocval_4.f90: New test.
2009-07-23 Joseph Myers <joseph@codesourcery.com> 2009-07-23 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/dll-4.c: Allow foo1 and foo2 in either order in * gcc.dg/dll-4.c: Allow foo1 and foo2 in either order in
......
! { dg-do run }
real :: a(3), nan, minf, pinf
real, allocatable :: c(:)
logical :: l
logical :: l2(3)
nan = 0.0
minf = 0.0
pinf = 0.0
nan = 0.0/nan
minf = -1.0/minf
pinf = 1.0/pinf
allocate (c(3))
a(:) = nan
if (maxloc (a, dim = 1).ne.1) call abort
if (.not.isnan(maxval (a, dim = 1))) call abort
a(:) = minf
if (maxloc (a, dim = 1).ne.1) call abort
if (maxval (a, dim = 1).ne.minf) call abort
a(1:2) = nan
if (maxloc (a, dim = 1).ne.3) call abort
if (maxval (a, dim = 1).ne.minf) call abort
a(2) = 1.0
if (maxloc (a, dim = 1).ne.2) call abort
if (maxval (a, dim = 1).ne.1) call abort
a(2) = pinf
if (maxloc (a, dim = 1).ne.2) call abort
if (maxval (a, dim = 1).ne.pinf) call abort
c(:) = nan
if (maxloc (c, dim = 1).ne.1) call abort
if (.not.isnan(maxval (c, dim = 1))) call abort
c(:) = minf
if (maxloc (c, dim = 1).ne.1) call abort
if (maxval (c, dim = 1).ne.minf) call abort
c(1:2) = nan
if (maxloc (c, dim = 1).ne.3) call abort
if (maxval (c, dim = 1).ne.minf) call abort
c(2) = 1.0
if (maxloc (c, dim = 1).ne.2) call abort
if (maxval (c, dim = 1).ne.1) call abort
c(2) = pinf
if (maxloc (c, dim = 1).ne.2) call abort
if (maxval (c, dim = 1).ne.pinf) call abort
l = .false.
l2(:) = .false.
a(:) = nan
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.-huge(minf)) call abort
a(:) = minf
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.-huge(minf)) call abort
a(1:2) = nan
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.-huge(minf)) call abort
a(2) = 1.0
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.-huge(minf)) call abort
a(2) = pinf
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.-huge(minf)) call abort
c(:) = nan
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.-huge(minf)) call abort
c(:) = minf
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.-huge(minf)) call abort
c(1:2) = nan
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.-huge(minf)) call abort
c(2) = 1.0
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.-huge(minf)) call abort
c(2) = pinf
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.-huge(minf)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.-huge(minf)) call abort
l = .true.
l2(:) = .true.
a(:) = nan
if (maxloc (a, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(maxval (a, dim = 1, mask = l))) call abort
if (maxloc (a, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(maxval (a, dim = 1, mask = l2))) call abort
a(:) = minf
if (maxloc (a, dim = 1, mask = l).ne.1) call abort
if (maxval (a, dim = 1, mask = l).ne.minf) call abort
if (maxloc (a, dim = 1, mask = l2).ne.1) call abort
if (maxval (a, dim = 1, mask = l2).ne.minf) call abort
a(1:2) = nan
if (maxloc (a, dim = 1, mask = l).ne.3) call abort
if (maxval (a, dim = 1, mask = l).ne.minf) call abort
if (maxloc (a, dim = 1, mask = l2).ne.3) call abort
if (maxval (a, dim = 1, mask = l2).ne.minf) call abort
a(2) = 1.0
if (maxloc (a, dim = 1, mask = l).ne.2) call abort
if (maxval (a, dim = 1, mask = l).ne.1) call abort
if (maxloc (a, dim = 1, mask = l2).ne.2) call abort
if (maxval (a, dim = 1, mask = l2).ne.1) call abort
a(2) = pinf
if (maxloc (a, dim = 1, mask = l).ne.2) call abort
if (maxval (a, dim = 1, mask = l).ne.pinf) call abort
if (maxloc (a, dim = 1, mask = l2).ne.2) call abort
if (maxval (a, dim = 1, mask = l2).ne.pinf) call abort
c(:) = nan
if (maxloc (c, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(maxval (c, dim = 1, mask = l))) call abort
if (maxloc (c, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(maxval (c, dim = 1, mask = l2))) call abort
c(:) = minf
if (maxloc (c, dim = 1, mask = l).ne.1) call abort
if (maxval (c, dim = 1, mask = l).ne.minf) call abort
if (maxloc (c, dim = 1, mask = l2).ne.1) call abort
if (maxval (c, dim = 1, mask = l2).ne.minf) call abort
c(1:2) = nan
if (maxloc (c, dim = 1, mask = l).ne.3) call abort
if (maxval (c, dim = 1, mask = l).ne.minf) call abort
if (maxloc (c, dim = 1, mask = l2).ne.3) call abort
if (maxval (c, dim = 1, mask = l2).ne.minf) call abort
c(2) = 1.0
if (maxloc (c, dim = 1, mask = l).ne.2) call abort
if (maxval (c, dim = 1, mask = l).ne.1) call abort
if (maxloc (c, dim = 1, mask = l2).ne.2) call abort
if (maxval (c, dim = 1, mask = l2).ne.1) call abort
c(2) = pinf
if (maxloc (c, dim = 1, mask = l).ne.2) call abort
if (maxval (c, dim = 1, mask = l).ne.pinf) call abort
if (maxloc (c, dim = 1, mask = l2).ne.2) call abort
if (maxval (c, dim = 1, mask = l2).ne.pinf) call abort
deallocate (c)
allocate (c(-2:-3))
if (maxloc (c, dim = 1).ne.0) call abort
if (maxval (c, dim = 1).ne.-huge(minf)) call abort
end
! { dg-do run }
integer :: a(3), h
integer, allocatable :: c(:)
logical :: l
logical :: l2(3)
h = -huge(h)
h = h - 1
allocate (c(3))
a(:) = 5
if (maxloc (a, dim = 1).ne.1) call abort
if (maxval (a, dim = 1).ne.5) call abort
a(2) = huge(h)
if (maxloc (a, dim = 1).ne.2) call abort
if (maxval (a, dim = 1).ne.huge(h)) call abort
a(:) = h
if (maxloc (a, dim = 1).ne.1) call abort
if (maxval (a, dim = 1).ne.h) call abort
a(3) = -huge(h)
if (maxloc (a, dim = 1).ne.3) call abort
if (maxval (a, dim = 1).ne.-huge(h)) call abort
c(:) = 5
if (maxloc (c, dim = 1).ne.1) call abort
if (maxval (c, dim = 1).ne.5) call abort
c(2) = huge(h)
if (maxloc (c, dim = 1).ne.2) call abort
if (maxval (c, dim = 1).ne.huge(h)) call abort
c(:) = h
if (maxloc (c, dim = 1).ne.1) call abort
if (maxval (c, dim = 1).ne.h) call abort
c(3) = -huge(h)
if (maxloc (c, dim = 1).ne.3) call abort
if (maxval (c, dim = 1).ne.-huge(h)) call abort
l = .false.
l2(:) = .false.
a(:) = 5
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.h) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.h) call abort
a(2) = huge(h)
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.h) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.h) call abort
a(:) = h
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.h) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.h) call abort
a(3) = -huge(h)
if (maxloc (a, dim = 1, mask = l).ne.0) call abort
if (maxval (a, dim = 1, mask = l).ne.h) call abort
if (maxloc (a, dim = 1, mask = l2).ne.0) call abort
if (maxval (a, dim = 1, mask = l2).ne.h) call abort
c(:) = 5
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.h) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.h) call abort
c(2) = huge(h)
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.h) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.h) call abort
c(:) = h
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.h) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.h) call abort
c(3) = -huge(h)
if (maxloc (c, dim = 1, mask = l).ne.0) call abort
if (maxval (c, dim = 1, mask = l).ne.h) call abort
if (maxloc (c, dim = 1, mask = l2).ne.0) call abort
if (maxval (c, dim = 1, mask = l2).ne.h) call abort
l = .true.
l2(:) = .true.
a(:) = 5
if (maxloc (a, dim = 1, mask = l).ne.1) call abort
if (maxval (a, dim = 1, mask = l).ne.5) call abort
if (maxloc (a, dim = 1, mask = l2).ne.1) call abort
if (maxval (a, dim = 1, mask = l2).ne.5) call abort
a(2) = huge(h)
if (maxloc (a, dim = 1, mask = l).ne.2) call abort
if (maxval (a, dim = 1, mask = l).ne.huge(h)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.2) call abort
if (maxval (a, dim = 1, mask = l2).ne.huge(h)) call abort
a(:) = h
if (maxloc (a, dim = 1, mask = l).ne.1) call abort
if (maxval (a, dim = 1, mask = l).ne.h) call abort
if (maxloc (a, dim = 1, mask = l2).ne.1) call abort
if (maxval (a, dim = 1, mask = l2).ne.h) call abort
a(3) = -huge(h)
if (maxloc (a, dim = 1, mask = l).ne.3) call abort
if (maxval (a, dim = 1, mask = l).ne.-huge(h)) call abort
if (maxloc (a, dim = 1, mask = l2).ne.3) call abort
if (maxval (a, dim = 1, mask = l2).ne.-huge(h)) call abort
c(:) = 5
if (maxloc (c, dim = 1, mask = l).ne.1) call abort
if (maxval (c, dim = 1, mask = l).ne.5) call abort
if (maxloc (c, dim = 1, mask = l2).ne.1) call abort
if (maxval (c, dim = 1, mask = l2).ne.5) call abort
c(2) = huge(h)
if (maxloc (c, dim = 1, mask = l).ne.2) call abort
if (maxval (c, dim = 1, mask = l).ne.huge(h)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.2) call abort
if (maxval (c, dim = 1, mask = l2).ne.huge(h)) call abort
c(:) = h
if (maxloc (c, dim = 1, mask = l).ne.1) call abort
if (maxval (c, dim = 1, mask = l).ne.h) call abort
if (maxloc (c, dim = 1, mask = l2).ne.1) call abort
if (maxval (c, dim = 1, mask = l2).ne.h) call abort
c(3) = -huge(h)
if (maxloc (c, dim = 1, mask = l).ne.3) call abort
if (maxval (c, dim = 1, mask = l).ne.-huge(h)) call abort
if (maxloc (c, dim = 1, mask = l2).ne.3) call abort
if (maxval (c, dim = 1, mask = l2).ne.-huge(h)) call abort
deallocate (c)
allocate (c(-2:-3))
if (maxloc (c, dim = 1).ne.0) call abort
if (maxval (c, dim = 1).ne.h) call abort
end
! { dg-do run }
real :: a(3,3), b(3), nan, minf, pinf, h
logical :: l, l2
logical :: l3(3,3), l4(3,3), l5(3,3)
nan = 0.0
minf = 0.0
pinf = 0.0
nan = 0.0/nan
minf = -1.0/minf
pinf = 1.0/pinf
h = -huge(h)
l = .false.
l2 = .true.
l3 = .false.
l4 = .true.
l5 = .true.
l5(1,1) = .false.
l5(1,2) = .false.
l5(2,3) = .false.
a = reshape ((/ nan, nan, nan, minf, minf, minf, minf, pinf, minf /), (/ 3, 3 /))
if (maxval (a).ne.pinf) call abort
if (any (maxloc (a).ne.(/ 2, 3 /))) call abort
b = maxval (a, dim = 1)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, minf, pinf /))) call abort
if (any (maxloc (a, dim = 1).ne.(/ 1, 1, 2 /))) call abort
b = maxval (a, dim = 2)
if (any (b.ne.(/ minf, pinf, minf /))) call abort
if (any (maxloc (a, dim = 2).ne.(/ 2, 3, 2 /))) call abort
if (maxval (a, mask = l).ne.h) call abort
if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
b = maxval (a, dim = 1, mask = l)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (maxloc (a, dim = 1, mask = l).ne.(/ 0, 0, 0 /))) call abort
b = maxval (a, dim = 2, mask = l)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (maxloc (a, dim = 2, mask = l).ne.(/ 0, 0, 0 /))) call abort
if (maxval (a, mask = l3).ne.h) call abort
if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
b = maxval (a, dim = 1, mask = l3)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (maxloc (a, dim = 1, mask = l3).ne.(/ 0, 0, 0 /))) call abort
b = maxval (a, dim = 2, mask = l3)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (maxloc (a, dim = 2, mask = l3).ne.(/ 0, 0, 0 /))) call abort
if (maxval (a, mask = l2).ne.pinf) call abort
if (maxval (a, mask = l4).ne.pinf) call abort
if (any (maxloc (a, mask = l2).ne.(/ 2, 3 /))) call abort
if (any (maxloc (a, mask = l4).ne.(/ 2, 3 /))) call abort
b = maxval (a, dim = 1, mask = l2)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, minf, pinf /))) call abort
if (any (maxloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
b = maxval (a, dim = 2, mask = l2)
if (any (b.ne.(/ minf, pinf, minf /))) call abort
if (any (maxloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
b = maxval (a, dim = 1, mask = l4)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, minf, pinf /))) call abort
if (any (maxloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
b = maxval (a, dim = 2, mask = l4)
if (any (b.ne.(/ minf, pinf, minf /))) call abort
if (any (maxloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
if (maxval (a, mask = l5).ne.minf) call abort
if (any (maxloc (a, mask = l5).ne.(/ 2, 2 /))) call abort
b = maxval (a, dim = 1, mask = l5)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, minf, minf /))) call abort
if (any (maxloc (a, dim = 1, mask = l5).ne.(/ 2, 2, 1 /))) call abort
b = maxval (a, dim = 2, mask = l5)
if (any (b.ne.(/ minf, minf, minf /))) call abort
if (any (maxloc (a, dim = 2, mask = l5).ne.(/ 3, 2, 2 /))) call abort
a = nan
if (.not.isnan(maxval (a))) call abort
if (maxval (a, mask = l).ne.h) call abort
if (.not.isnan(maxval (a, mask = l2))) call abort
if (maxval (a, mask = l3).ne.h) call abort
if (.not.isnan(maxval (a, mask = l4))) call abort
if (.not.isnan(maxval (a, mask = l5))) call abort
if (any (maxloc (a).ne.(/ 1, 1 /))) call abort
if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
if (any (maxloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
if (any (maxloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
if (any (maxloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
a = minf
if (maxval (a).ne.minf) call abort
if (maxval (a, mask = l).ne.h) call abort
if (maxval (a, mask = l2).ne.minf) call abort
if (maxval (a, mask = l3).ne.h) call abort
if (maxval (a, mask = l4).ne.minf) call abort
if (maxval (a, mask = l5).ne.minf) call abort
if (any (maxloc (a).ne.(/ 1, 1 /))) call abort
if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
if (any (maxloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
if (any (maxloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
if (any (maxloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
a = nan
a(1,3) = minf
if (maxval (a).ne.minf) call abort
if (maxval (a, mask = l).ne.h) call abort
if (maxval (a, mask = l2).ne.minf) call abort
if (maxval (a, mask = l3).ne.h) call abort
if (maxval (a, mask = l4).ne.minf) call abort
if (maxval (a, mask = l5).ne.minf) call abort
if (any (maxloc (a).ne.(/ 1, 3 /))) call abort
if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
if (any (maxloc (a, mask = l2).ne.(/ 1, 3 /))) call abort
if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
if (any (maxloc (a, mask = l4).ne.(/ 1, 3 /))) call abort
if (any (maxloc (a, mask = l5).ne.(/ 1, 3 /))) call abort
end
! { dg-do run }
real :: a(3), nan, minf, pinf
real, allocatable :: c(:)
logical :: l
logical :: l2(3)
nan = 0.0
minf = 0.0
pinf = 0.0
nan = 0.0/nan
minf = -1.0/minf
pinf = 1.0/pinf
allocate (c(3))
a(:) = nan
if (minloc (a, dim = 1).ne.1) call abort
if (.not.isnan(minval (a, dim = 1))) call abort
a(:) = pinf
if (minloc (a, dim = 1).ne.1) call abort
if (minval (a, dim = 1).ne.pinf) call abort
a(1:2) = nan
if (minloc (a, dim = 1).ne.3) call abort
if (minval (a, dim = 1).ne.pinf) call abort
a(2) = 1.0
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.1) call abort
a(2) = minf
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.minf) call abort
c(:) = nan
if (minloc (c, dim = 1).ne.1) call abort
if (.not.isnan(minval (c, dim = 1))) call abort
c(:) = pinf
if (minloc (c, dim = 1).ne.1) call abort
if (minval (c, dim = 1).ne.pinf) call abort
c(1:2) = nan
if (minloc (c, dim = 1).ne.3) call abort
if (minval (c, dim = 1).ne.pinf) call abort
c(2) = 1.0
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.1) call abort
c(2) = minf
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.minf) call abort
l = .false.
l2(:) = .false.
a(:) = nan
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(:) = pinf
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(1:2) = nan
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(2) = 1.0
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(2) = minf
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(:) = nan
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(:) = pinf
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(1:2) = nan
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(2) = 1.0
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(2) = minf
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
l = .true.
l2(:) = .true.
a(:) = nan
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(minval (a, dim = 1, mask = l))) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(minval (a, dim = 1, mask = l2))) call abort
a(:) = pinf
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (minval (a, dim = 1, mask = l).ne.pinf) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (minval (a, dim = 1, mask = l2).ne.pinf) call abort
a(1:2) = nan
if (minloc (a, dim = 1, mask = l).ne.3) call abort
if (minval (a, dim = 1, mask = l).ne.pinf) call abort
if (minloc (a, dim = 1, mask = l2).ne.3) call abort
if (minval (a, dim = 1, mask = l2).ne.pinf) call abort
a(2) = 1.0
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.1) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.1) call abort
a(2) = minf
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.minf) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.minf) call abort
c(:) = nan
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(minval (c, dim = 1, mask = l))) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(minval (c, dim = 1, mask = l2))) call abort
c(:) = pinf
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (minval (c, dim = 1, mask = l).ne.pinf) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (minval (c, dim = 1, mask = l2).ne.pinf) call abort
c(1:2) = nan
if (minloc (c, dim = 1, mask = l).ne.3) call abort
if (minval (c, dim = 1, mask = l).ne.pinf) call abort
if (minloc (c, dim = 1, mask = l2).ne.3) call abort
if (minval (c, dim = 1, mask = l2).ne.pinf) call abort
c(2) = 1.0
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.1) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.1) call abort
c(2) = minf
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.minf) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.minf) call abort
deallocate (c)
allocate (c(-2:-3))
if (minloc (c, dim = 1).ne.0) call abort
if (minval (c, dim = 1).ne.huge(pinf)) call abort
end
! { dg-do run }
integer :: a(3), h
integer, allocatable :: c(:)
logical :: l
logical :: l2(3)
h = -huge(h)
h = h - 1
allocate (c(3))
a(:) = 5
if (minloc (a, dim = 1).ne.1) call abort
if (minval (a, dim = 1).ne.5) call abort
a(2) = h
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.h) call abort
a(:) = huge(h)
if (minloc (a, dim = 1).ne.1) call abort
if (minval (a, dim = 1).ne.huge(h)) call abort
a(3) = huge(h) - 1
if (minloc (a, dim = 1).ne.3) call abort
if (minval (a, dim = 1).ne.huge(h)-1) call abort
c(:) = 5
if (minloc (c, dim = 1).ne.1) call abort
if (minval (c, dim = 1).ne.5) call abort
c(2) = h
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.h) call abort
c(:) = huge(h)
if (minloc (c, dim = 1).ne.1) call abort
if (minval (c, dim = 1).ne.huge(h)) call abort
c(3) = huge(h) - 1
if (minloc (c, dim = 1).ne.3) call abort
if (minval (c, dim = 1).ne.huge(h)-1) call abort
l = .false.
l2(:) = .false.
a(:) = 5
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(h)) call abort
a(2) = h
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(h)) call abort
a(:) = huge(h)
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(h)) call abort
a(3) = huge(h) - 1
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(h)) call abort
c(:) = 5
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(h)) call abort
c(2) = h
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(h)) call abort
c(:) = huge(h)
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(h)) call abort
c(3) = huge(h) - 1
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(h)) call abort
l = .true.
l2(:) = .true.
a(:) = 5
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (minval (a, dim = 1, mask = l).ne.5) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (minval (a, dim = 1, mask = l2).ne.5) call abort
a(2) = h
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.h) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.h) call abort
a(:) = huge(h)
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (minval (a, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(h)) call abort
a(3) = huge(h) - 1
if (minloc (a, dim = 1, mask = l).ne.3) call abort
if (minval (a, dim = 1, mask = l).ne.huge(h)-1) call abort
if (minloc (a, dim = 1, mask = l2).ne.3) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(h)-1) call abort
c(:) = 5
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (minval (c, dim = 1, mask = l).ne.5) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (minval (c, dim = 1, mask = l2).ne.5) call abort
c(2) = h
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.h) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.h) call abort
c(:) = huge(h)
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (minval (c, dim = 1, mask = l).ne.huge(h)) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(h)) call abort
c(3) = huge(h) - 1
if (minloc (c, dim = 1, mask = l).ne.3) call abort
if (minval (c, dim = 1, mask = l).ne.huge(h)-1) call abort
if (minloc (c, dim = 1, mask = l2).ne.3) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(h)-1) call abort
deallocate (c)
allocate (c(-2:-3))
if (minloc (c, dim = 1).ne.0) call abort
if (minval (c, dim = 1).ne.huge(h)) call abort
end
! { dg-do run }
real :: a(3,3), b(3), nan, minf, pinf, h
logical :: l, l2
logical :: l3(3,3), l4(3,3), l5(3,3)
nan = 0.0
minf = 0.0
pinf = 0.0
nan = 0.0/nan
minf = -1.0/minf
pinf = 1.0/pinf
h = huge(h)
l = .false.
l2 = .true.
l3 = .false.
l4 = .true.
l5 = .true.
l5(1,1) = .false.
l5(1,2) = .false.
l5(2,3) = .false.
a = reshape ((/ nan, nan, nan, pinf, pinf, pinf, pinf, minf, pinf /), (/ 3, 3 /))
if (minval (a).ne.minf) call abort
if (any (minloc (a).ne.(/ 2, 3 /))) call abort
b = minval (a, dim = 1)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, pinf, minf /))) call abort
if (any (minloc (a, dim = 1).ne.(/ 1, 1, 2 /))) call abort
b = minval (a, dim = 2)
if (any (b.ne.(/ pinf, minf, pinf /))) call abort
if (any (minloc (a, dim = 2).ne.(/ 2, 3, 2 /))) call abort
if (minval (a, mask = l).ne.h) call abort
if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
b = minval (a, dim = 1, mask = l)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (minloc (a, dim = 1, mask = l).ne.(/ 0, 0, 0 /))) call abort
b = minval (a, dim = 2, mask = l)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (minloc (a, dim = 2, mask = l).ne.(/ 0, 0, 0 /))) call abort
if (minval (a, mask = l3).ne.h) call abort
if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
b = minval (a, dim = 1, mask = l3)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (minloc (a, dim = 1, mask = l3).ne.(/ 0, 0, 0 /))) call abort
b = minval (a, dim = 2, mask = l3)
if (any (b.ne.(/ h, h, h /))) call abort
if (any (minloc (a, dim = 2, mask = l3).ne.(/ 0, 0, 0 /))) call abort
if (minval (a, mask = l2).ne.minf) call abort
if (minval (a, mask = l4).ne.minf) call abort
if (any (minloc (a, mask = l2).ne.(/ 2, 3 /))) call abort
if (any (minloc (a, mask = l4).ne.(/ 2, 3 /))) call abort
b = minval (a, dim = 1, mask = l2)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, pinf, minf /))) call abort
if (any (minloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
b = minval (a, dim = 2, mask = l2)
if (any (b.ne.(/ pinf, minf, pinf /))) call abort
if (any (minloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
b = minval (a, dim = 1, mask = l4)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, pinf, minf /))) call abort
if (any (minloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
b = minval (a, dim = 2, mask = l4)
if (any (b.ne.(/ pinf, minf, pinf /))) call abort
if (any (minloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
if (minval (a, mask = l5).ne.pinf) call abort
if (any (minloc (a, mask = l5).ne.(/ 2, 2 /))) call abort
b = minval (a, dim = 1, mask = l5)
if (.not.isnan(b(1))) call abort
b(1) = 0.0
if (any (b.ne.(/ 0.0, pinf, pinf /))) call abort
if (any (minloc (a, dim = 1, mask = l5).ne.(/ 2, 2, 1 /))) call abort
b = minval (a, dim = 2, mask = l5)
if (any (b.ne.(/ pinf, pinf, pinf /))) call abort
if (any (minloc (a, dim = 2, mask = l5).ne.(/ 3, 2, 2 /))) call abort
a = nan
if (.not.isnan(minval (a))) call abort
if (minval (a, mask = l).ne.h) call abort
if (.not.isnan(minval (a, mask = l2))) call abort
if (minval (a, mask = l3).ne.h) call abort
if (.not.isnan(minval (a, mask = l4))) call abort
if (.not.isnan(minval (a, mask = l5))) call abort
if (any (minloc (a).ne.(/ 1, 1 /))) call abort
if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
if (any (minloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
if (any (minloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
if (any (minloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
a = pinf
if (minval (a).ne.pinf) call abort
if (minval (a, mask = l).ne.h) call abort
if (minval (a, mask = l2).ne.pinf) call abort
if (minval (a, mask = l3).ne.h) call abort
if (minval (a, mask = l4).ne.pinf) call abort
if (minval (a, mask = l5).ne.pinf) call abort
if (any (minloc (a).ne.(/ 1, 1 /))) call abort
if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
if (any (minloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
if (any (minloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
if (any (minloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
a = nan
a(1,3) = pinf
if (minval (a).ne.pinf) call abort
if (minval (a, mask = l).ne.h) call abort
if (minval (a, mask = l2).ne.pinf) call abort
if (minval (a, mask = l3).ne.h) call abort
if (minval (a, mask = l4).ne.pinf) call abort
if (minval (a, mask = l5).ne.pinf) call abort
if (any (minloc (a).ne.(/ 1, 3 /))) call abort
if (any (minloc (a, mask = l).ne.(/ 0, 0 /))) call abort
if (any (minloc (a, mask = l2).ne.(/ 1, 3 /))) call abort
if (any (minloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
if (any (minloc (a, mask = l4).ne.(/ 1, 3 /))) call abort
if (any (minloc (a, mask = l5).ne.(/ 1, 3 /))) call abort
end
2009-07-24 Jakub Jelinek <jakub@redhat.com>
PR fortran/40643
PR fortran/31067
* libgfortran.h (GFC_REAL_4_INFINITY, GFC_REAL_8_INFINITY,
GFC_REAL_10_INFINITY, GFC_REAL_16_INFINITY, GFC_REAL_4_QUIET_NAN,
GFC_REAL_8_QUIET_NAN, GFC_REAL_10_QUIET_NAN, GFC_REAL_16_QUIET_NAN):
Define.
* m4/iparm.m4 (atype_inf, atype_nan): Define.
* m4/ifunction.m4: Formatting.
* m4/iforeach.m4: Likewise.
(START_FOREACH_FUNCTION): Initialize dest to all 1s, not all 0s.
(START_FOREACH_BLOCK, FINISH_FOREACH_FUNCTION,
FINISH_MASKED_FOREACH_FUNCTION): Run foreach block inside a loop
until count[0] == extent[0].
* m4/minval.m4: Formatting. Handle NaNs and infinities. Optimize.
* m4/maxval.m4: Likewise.
* m4/minloc0.m4: Likewise.
* m4/maxloc0.m4: Likewise.
* m4/minloc1.m4: Likewise.
* m4/maxloc1.m4: Likewise.
* generated/maxloc0_16_i16.c: Regenerated.
* generated/maxloc0_16_i1.c: Likewise.
* generated/maxloc0_16_i2.c: Likewise.
* generated/maxloc0_16_i4.c: Likewise.
* generated/maxloc0_16_i8.c: Likewise.
* generated/maxloc0_16_r10.c: Likewise.
* generated/maxloc0_16_r16.c: Likewise.
* generated/maxloc0_16_r4.c: Likewise.
* generated/maxloc0_16_r8.c: Likewise.
* generated/maxloc0_4_i16.c: Likewise.
* generated/maxloc0_4_i1.c: Likewise.
* generated/maxloc0_4_i2.c: Likewise.
* generated/maxloc0_4_i4.c: Likewise.
* generated/maxloc0_4_i8.c: Likewise.
* generated/maxloc0_4_r10.c: Likewise.
* generated/maxloc0_4_r16.c: Likewise.
* generated/maxloc0_4_r4.c: Likewise.
* generated/maxloc0_4_r8.c: Likewise.
* generated/maxloc0_8_i16.c: Likewise.
* generated/maxloc0_8_i1.c: Likewise.
* generated/maxloc0_8_i2.c: Likewise.
* generated/maxloc0_8_i4.c: Likewise.
* generated/maxloc0_8_i8.c: Likewise.
* generated/maxloc0_8_r10.c: Likewise.
* generated/maxloc0_8_r16.c: Likewise.
* generated/maxloc0_8_r4.c: Likewise.
* generated/maxloc0_8_r8.c: Likewise.
* generated/maxloc1_16_i16.c: Likewise.
* generated/maxloc1_16_i1.c: Likewise.
* generated/maxloc1_16_i2.c: Likewise.
* generated/maxloc1_16_i4.c: Likewise.
* generated/maxloc1_16_i8.c: Likewise.
* generated/maxloc1_16_r10.c: Likewise.
* generated/maxloc1_16_r16.c: Likewise.
* generated/maxloc1_16_r4.c: Likewise.
* generated/maxloc1_16_r8.c: Likewise.
* generated/maxloc1_4_i16.c: Likewise.
* generated/maxloc1_4_i1.c: Likewise.
* generated/maxloc1_4_i2.c: Likewise.
* generated/maxloc1_4_i4.c: Likewise.
* generated/maxloc1_4_i8.c: Likewise.
* generated/maxloc1_4_r10.c: Likewise.
* generated/maxloc1_4_r16.c: Likewise.
* generated/maxloc1_4_r4.c: Likewise.
* generated/maxloc1_4_r8.c: Likewise.
* generated/maxloc1_8_i16.c: Likewise.
* generated/maxloc1_8_i1.c: Likewise.
* generated/maxloc1_8_i2.c: Likewise.
* generated/maxloc1_8_i4.c: Likewise.
* generated/maxloc1_8_i8.c: Likewise.
* generated/maxloc1_8_r10.c: Likewise.
* generated/maxloc1_8_r16.c: Likewise.
* generated/maxloc1_8_r4.c: Likewise.
* generated/maxloc1_8_r8.c: Likewise.
* generated/maxval_i16.c: Likewise.
* generated/maxval_i1.c: Likewise.
* generated/maxval_i2.c: Likewise.
* generated/maxval_i4.c: Likewise.
* generated/maxval_i8.c: Likewise.
* generated/maxval_r10.c: Likewise.
* generated/maxval_r16.c: Likewise.
* generated/maxval_r4.c: Likewise.
* generated/maxval_r8.c: Likewise.
* generated/minloc0_16_i16.c: Likewise.
* generated/minloc0_16_i1.c: Likewise.
* generated/minloc0_16_i2.c: Likewise.
* generated/minloc0_16_i4.c: Likewise.
* generated/minloc0_16_i8.c: Likewise.
* generated/minloc0_16_r10.c: Likewise.
* generated/minloc0_16_r16.c: Likewise.
* generated/minloc0_16_r4.c: Likewise.
* generated/minloc0_16_r8.c: Likewise.
* generated/minloc0_4_i16.c: Likewise.
* generated/minloc0_4_i1.c: Likewise.
* generated/minloc0_4_i2.c: Likewise.
* generated/minloc0_4_i4.c: Likewise.
* generated/minloc0_4_i8.c: Likewise.
* generated/minloc0_4_r10.c: Likewise.
* generated/minloc0_4_r16.c: Likewise.
* generated/minloc0_4_r4.c: Likewise.
* generated/minloc0_4_r8.c: Likewise.
* generated/minloc0_8_i16.c: Likewise.
* generated/minloc0_8_i1.c: Likewise.
* generated/minloc0_8_i2.c: Likewise.
* generated/minloc0_8_i4.c: Likewise.
* generated/minloc0_8_i8.c: Likewise.
* generated/minloc0_8_r10.c: Likewise.
* generated/minloc0_8_r16.c: Likewise.
* generated/minloc0_8_r4.c: Likewise.
* generated/minloc0_8_r8.c: Likewise.
* generated/minloc1_16_i16.c: Likewise.
* generated/minloc1_16_i1.c: Likewise.
* generated/minloc1_16_i2.c: Likewise.
* generated/minloc1_16_i4.c: Likewise.
* generated/minloc1_16_i8.c: Likewise.
* generated/minloc1_16_r10.c: Likewise.
* generated/minloc1_16_r16.c: Likewise.
* generated/minloc1_16_r4.c: Likewise.
* generated/minloc1_16_r8.c: Likewise.
* generated/minloc1_4_i16.c: Likewise.
* generated/minloc1_4_i1.c: Likewise.
* generated/minloc1_4_i2.c: Likewise.
* generated/minloc1_4_i4.c: Likewise.
* generated/minloc1_4_i8.c: Likewise.
* generated/minloc1_4_r10.c: Likewise.
* generated/minloc1_4_r16.c: Likewise.
* generated/minloc1_4_r4.c: Likewise.
* generated/minloc1_4_r8.c: Likewise.
* generated/minloc1_8_i16.c: Likewise.
* generated/minloc1_8_i1.c: Likewise.
* generated/minloc1_8_i2.c: Likewise.
* generated/minloc1_8_i4.c: Likewise.
* generated/minloc1_8_i8.c: Likewise.
* generated/minloc1_8_r10.c: Likewise.
* generated/minloc1_8_r16.c: Likewise.
* generated/minloc1_8_r4.c: Likewise.
* generated/minloc1_8_r8.c: Likewise.
* generated/minval_i16.c: Likewise.
* generated/minval_i1.c: Likewise.
* generated/minval_i2.c: Likewise.
* generated/minval_i4.c: Likewise.
* generated/minval_i8.c: Likewise.
* generated/minval_r10.c: Likewise.
* generated/minval_r16.c: Likewise.
* generated/minval_r4.c: Likewise.
* generated/minval_r8.c: Likewise.
* generated/product_c10.c: Likewise.
* generated/product_c16.c: Likewise.
* generated/product_c4.c: Likewise.
* generated/product_c8.c: Likewise.
* generated/product_i16.c: Likewise.
* generated/product_i1.c: Likewise.
* generated/product_i2.c: Likewise.
* generated/product_i4.c: Likewise.
* generated/product_i8.c: Likewise.
* generated/product_r10.c: Likewise.
* generated/product_r16.c: Likewise.
* generated/product_r4.c: Likewise.
* generated/product_r8.c: Likewise.
* generated/sum_c10.c: Likewise.
* generated/sum_c16.c: Likewise.
* generated/sum_c4.c: Likewise.
* generated/sum_c8.c: Likewise.
* generated/sum_i16.c: Likewise.
* generated/sum_i1.c: Likewise.
* generated/sum_i2.c: Likewise.
* generated/sum_i4.c: Likewise.
* generated/sum_i8.c: Likewise.
* generated/sum_r10.c: Likewise.
* generated/sum_r16.c: Likewise.
* generated/sum_r4.c: Likewise.
* generated/sum_r8.c: Likewise.
2009-07-22 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2009-07-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/32784 PR libfortran/32784
......
...@@ -63,8 +63,8 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_1 maxval; GFC_INTEGER_1 maxval;
#if defined(GFC_INTEGER_1_QUIET_NAN)
maxval = (-GFC_INTEGER_1_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_1_INFINITY)
maxval = -GFC_INTEGER_1_INFINITY;
#else
maxval = (-GFC_INTEGER_1_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_1_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
{ {
GFC_INTEGER_1 maxval; GFC_INTEGER_1 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_1_HUGE-1); #if defined(GFC_INTEGER_1_INFINITY)
maxval = -GFC_INTEGER_1_INFINITY;
#else
maxval = (-GFC_INTEGER_1_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_1_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_16 maxval; GFC_INTEGER_16 maxval;
#if defined(GFC_INTEGER_16_QUIET_NAN)
maxval = (-GFC_INTEGER_16_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_16_INFINITY)
maxval = -GFC_INTEGER_16_INFINITY;
#else
maxval = (-GFC_INTEGER_16_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_16_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
{ {
GFC_INTEGER_16 maxval; GFC_INTEGER_16 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_16_HUGE-1); #if defined(GFC_INTEGER_16_INFINITY)
maxval = -GFC_INTEGER_16_INFINITY;
#else
maxval = (-GFC_INTEGER_16_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_16_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_2 maxval; GFC_INTEGER_2 maxval;
#if defined(GFC_INTEGER_2_QUIET_NAN)
maxval = (-GFC_INTEGER_2_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_2_INFINITY)
maxval = -GFC_INTEGER_2_INFINITY;
#else
maxval = (-GFC_INTEGER_2_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_2_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
{ {
GFC_INTEGER_2 maxval; GFC_INTEGER_2 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_2_HUGE-1); #if defined(GFC_INTEGER_2_INFINITY)
maxval = -GFC_INTEGER_2_INFINITY;
#else
maxval = (-GFC_INTEGER_2_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_2_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_4 maxval; GFC_INTEGER_4 maxval;
#if defined(GFC_INTEGER_4_QUIET_NAN)
maxval = (-GFC_INTEGER_4_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_4_INFINITY)
maxval = -GFC_INTEGER_4_INFINITY;
#else
maxval = (-GFC_INTEGER_4_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_4_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
{ {
GFC_INTEGER_4 maxval; GFC_INTEGER_4 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_4_HUGE-1); #if defined(GFC_INTEGER_4_INFINITY)
maxval = -GFC_INTEGER_4_INFINITY;
#else
maxval = (-GFC_INTEGER_4_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_4_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_8 maxval; GFC_INTEGER_8 maxval;
#if defined(GFC_INTEGER_8_QUIET_NAN)
maxval = (-GFC_INTEGER_8_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_8_INFINITY)
maxval = -GFC_INTEGER_8_INFINITY;
#else
maxval = (-GFC_INTEGER_8_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_8_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
{ {
GFC_INTEGER_8 maxval; GFC_INTEGER_8 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_8_HUGE-1); #if defined(GFC_INTEGER_8_INFINITY)
maxval = -GFC_INTEGER_8_INFINITY;
#else
maxval = (-GFC_INTEGER_8_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_8_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_REAL_10 maxval; GFC_REAL_10 maxval;
#if defined(GFC_REAL_10_QUIET_NAN)
maxval = -GFC_REAL_10_HUGE; int fast = 0;
#endif
#if defined(GFC_REAL_10_INFINITY)
maxval = -GFC_REAL_10_INFINITY;
#else
maxval = -GFC_REAL_10_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_REAL_10_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
{ {
GFC_REAL_10 maxval; GFC_REAL_10 maxval;
int fast = 0;
maxval = -GFC_REAL_10_HUGE; #if defined(GFC_REAL_10_INFINITY)
maxval = -GFC_REAL_10_INFINITY;
#else
maxval = -GFC_REAL_10_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_REAL_10_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_REAL_16 maxval; GFC_REAL_16 maxval;
#if defined(GFC_REAL_16_QUIET_NAN)
maxval = -GFC_REAL_16_HUGE; int fast = 0;
#endif
#if defined(GFC_REAL_16_INFINITY)
maxval = -GFC_REAL_16_INFINITY;
#else
maxval = -GFC_REAL_16_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_REAL_16_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
{ {
GFC_REAL_16 maxval; GFC_REAL_16 maxval;
int fast = 0;
maxval = -GFC_REAL_16_HUGE; #if defined(GFC_REAL_16_INFINITY)
maxval = -GFC_REAL_16_INFINITY;
#else
maxval = -GFC_REAL_16_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_REAL_16_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_REAL_4 maxval; GFC_REAL_4 maxval;
#if defined(GFC_REAL_4_QUIET_NAN)
maxval = -GFC_REAL_4_HUGE; int fast = 0;
#endif
#if defined(GFC_REAL_4_INFINITY)
maxval = -GFC_REAL_4_INFINITY;
#else
maxval = -GFC_REAL_4_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_REAL_4_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
{ {
GFC_REAL_4 maxval; GFC_REAL_4 maxval;
int fast = 0;
maxval = -GFC_REAL_4_HUGE; #if defined(GFC_REAL_4_INFINITY)
maxval = -GFC_REAL_4_INFINITY;
#else
maxval = -GFC_REAL_4_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_REAL_4_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_REAL_8 maxval; GFC_REAL_8 maxval;
#if defined(GFC_REAL_8_QUIET_NAN)
maxval = -GFC_REAL_8_HUGE; int fast = 0;
#endif
#if defined(GFC_REAL_8_INFINITY)
maxval = -GFC_REAL_8_INFINITY;
#else
maxval = -GFC_REAL_8_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_REAL_8_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
{ {
GFC_REAL_8 maxval; GFC_REAL_8 maxval;
int fast = 0;
maxval = -GFC_REAL_8_HUGE; #if defined(GFC_REAL_8_INFINITY)
maxval = -GFC_REAL_8_INFINITY;
#else
maxval = -GFC_REAL_8_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_REAL_8_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_1 maxval; GFC_INTEGER_1 maxval;
#if defined(GFC_INTEGER_1_QUIET_NAN)
maxval = (-GFC_INTEGER_1_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_1_INFINITY)
maxval = -GFC_INTEGER_1_INFINITY;
#else
maxval = (-GFC_INTEGER_1_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_1_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
{ {
GFC_INTEGER_1 maxval; GFC_INTEGER_1 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_1_HUGE-1); #if defined(GFC_INTEGER_1_INFINITY)
maxval = -GFC_INTEGER_1_INFINITY;
#else
maxval = (-GFC_INTEGER_1_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_1_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_16 maxval; GFC_INTEGER_16 maxval;
#if defined(GFC_INTEGER_16_QUIET_NAN)
maxval = (-GFC_INTEGER_16_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_16_INFINITY)
maxval = -GFC_INTEGER_16_INFINITY;
#else
maxval = (-GFC_INTEGER_16_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_16_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
{ {
GFC_INTEGER_16 maxval; GFC_INTEGER_16 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_16_HUGE-1); #if defined(GFC_INTEGER_16_INFINITY)
maxval = -GFC_INTEGER_16_INFINITY;
#else
maxval = (-GFC_INTEGER_16_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_16_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_2 maxval; GFC_INTEGER_2 maxval;
#if defined(GFC_INTEGER_2_QUIET_NAN)
maxval = (-GFC_INTEGER_2_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_2_INFINITY)
maxval = -GFC_INTEGER_2_INFINITY;
#else
maxval = (-GFC_INTEGER_2_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_2_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
{ {
GFC_INTEGER_2 maxval; GFC_INTEGER_2 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_2_HUGE-1); #if defined(GFC_INTEGER_2_INFINITY)
maxval = -GFC_INTEGER_2_INFINITY;
#else
maxval = (-GFC_INTEGER_2_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_2_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_4 maxval; GFC_INTEGER_4 maxval;
#if defined(GFC_INTEGER_4_QUIET_NAN)
maxval = (-GFC_INTEGER_4_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_4_INFINITY)
maxval = -GFC_INTEGER_4_INFINITY;
#else
maxval = (-GFC_INTEGER_4_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_4_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
{ {
GFC_INTEGER_4 maxval; GFC_INTEGER_4 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_4_HUGE-1); #if defined(GFC_INTEGER_4_INFINITY)
maxval = -GFC_INTEGER_4_INFINITY;
#else
maxval = (-GFC_INTEGER_4_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_4_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_INTEGER_8 maxval; GFC_INTEGER_8 maxval;
#if defined(GFC_INTEGER_8_QUIET_NAN)
maxval = (-GFC_INTEGER_8_HUGE-1); int fast = 0;
#endif
#if defined(GFC_INTEGER_8_INFINITY)
maxval = -GFC_INTEGER_8_INFINITY;
#else
maxval = (-GFC_INTEGER_8_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_INTEGER_8_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
{ {
GFC_INTEGER_8 maxval; GFC_INTEGER_8 maxval;
int fast = 0;
maxval = (-GFC_INTEGER_8_HUGE-1); #if defined(GFC_INTEGER_8_INFINITY)
maxval = -GFC_INTEGER_8_INFINITY;
#else
maxval = (-GFC_INTEGER_8_HUGE-1);
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_INTEGER_8_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_REAL_10 maxval; GFC_REAL_10 maxval;
#if defined(GFC_REAL_10_QUIET_NAN)
maxval = -GFC_REAL_10_HUGE; int fast = 0;
#endif
#if defined(GFC_REAL_10_INFINITY)
maxval = -GFC_REAL_10_INFINITY;
#else
maxval = -GFC_REAL_10_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_REAL_10_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
{ {
GFC_REAL_10 maxval; GFC_REAL_10 maxval;
int fast = 0;
maxval = -GFC_REAL_10_HUGE; #if defined(GFC_REAL_10_INFINITY)
maxval = -GFC_REAL_10_INFINITY;
#else
maxval = -GFC_REAL_10_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_REAL_10_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
...@@ -63,8 +63,8 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, ...@@ -63,8 +63,8 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
else else
{ {
if (unlikely (compile_options.bounds_check)) if (unlikely (compile_options.bounds_check))
bounds_iforeach_return ((array_t *) retarray, (array_t *) array, bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
"MAXLOC"); "MAXLOC");
} }
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
...@@ -87,51 +87,83 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, ...@@ -87,51 +87,83 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
/* Initialize the return value. */ /* Initialize the return value. */
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
dest[n * dstride] = 0; dest[n * dstride] = 1;
{ {
GFC_REAL_16 maxval; GFC_REAL_16 maxval;
#if defined(GFC_REAL_16_QUIET_NAN)
maxval = -GFC_REAL_16_HUGE; int fast = 0;
#endif
#if defined(GFC_REAL_16_INFINITY)
maxval = -GFC_REAL_16_INFINITY;
#else
maxval = -GFC_REAL_16_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*base > maxval || !dest[0]) #if defined(GFC_REAL_16_QUIET_NAN)
{ }
maxval = *base; while (0);
for (n = 0; n < rank; n++) if (unlikely (!fast))
dest[n * dstride] = count[n] + 1; {
} do
/* Implementation end. */ {
} if (*base >= maxval)
/* Advance to the next element. */ {
count[0]++; fast = 1;
base += sstride[0]; maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
base += sstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
#endif
if (*base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
...@@ -219,50 +251,87 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray, ...@@ -219,50 +251,87 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
{ {
GFC_REAL_16 maxval; GFC_REAL_16 maxval;
int fast = 0;
maxval = -GFC_REAL_16_HUGE; #if defined(GFC_REAL_16_INFINITY)
maxval = -GFC_REAL_16_INFINITY;
#else
maxval = -GFC_REAL_16_HUGE;
#endif
while (base) while (base)
{ {
{ do
/* Implementation start. */ {
/* Implementation start. */
if (*mbase && (*base > maxval || !dest[0])) }
{ while (0);
maxval = *base; if (unlikely (!fast))
for (n = 0; n < rank; n++) {
dest[n * dstride] = count[n] + 1; do
} {
/* Implementation end. */ if (*mbase)
} {
/* Advance to the next element. */ #if defined(GFC_REAL_16_QUIET_NAN)
count[0]++; if (unlikely (dest[0] == 0))
base += sstride[0]; for (n = 0; n < rank; n++)
mbase += mstride[0]; dest[n * dstride] = count[n] + 1;
if (*base >= maxval)
#endif
{
fast = 1;
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
break;
}
}
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
if (likely (fast))
continue;
}
else do
{
if (*mbase && *base > maxval)
{
maxval = *base;
for (n = 0; n < rank; n++)
dest[n * dstride] = count[n] + 1;
}
/* Implementation end. */
/* Advance to the next element. */
base += sstride[0];
mbase += mstride[0];
}
while (++count[0] != extent[0]);
n = 0; n = 0;
while (count[n] == extent[n]) do
{ {
/* When we get to the end of a dimension, reset it and increment /* When we get to the end of a dimension, reset it and increment
the next dimension. */ the next dimension. */
count[n] = 0; count[n] = 0;
/* We could precalculate these products, but this is a less /* We could precalculate these products, but this is a less
frequently used path so probably not worth it. */ frequently used path so probably not worth it. */
base -= sstride[n] * extent[n]; base -= sstride[n] * extent[n];
mbase -= mstride[n] * extent[n]; mbase -= mstride[n] * extent[n];
n++; n++;
if (n == rank) if (n == rank)
{ {
/* Break out of the loop. */ /* Break out of the loop. */
base = NULL; base = NULL;
break; break;
} }
else else
{ {
count[n]++; count[n]++;
base += sstride[n]; base += sstride[n];
mbase += mstride[n]; mbase += mstride[n];
} }
} }
while (count[n] == extent[n]);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment