From: Thomas Koenig Date: Tue, 8 May 2018 07:47:19 +0000 (+0000) Subject: re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) X-Git-Tag: basepoints/gcc-10~6949 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b573f931988b43a322ee454241b2af3a74f2fa84;p=thirdparty%2Fgcc.git re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-05-08 Thomas Koenig PR fortran/54613 * check.c (gfc_check_minmaxloc): Remove error for BACK not being implemented. Use gfc_logical_4_kind for BACK. * simplify.c (min_max_choose): Add optional argument back_val. Handle it. (simplify_minmaxloc_to_scalar): Add argument back_val. Pass back_val to min_max_choose. (simplify_minmaxloc_to_nodim): Likewise. (simplify_minmaxloc_to_array): Likewise. (gfc_simplify_minmaxloc): Add argument back, handle it. Pass back_val to specific simplification functions. (gfc_simplify_minloc): Remove ATTRIBUTE_UNUSED from argument back, pass it on to gfc_simplify_minmaxloc. (gfc_simplify_maxloc): Likewise. * trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Adjust comment. If BACK is true, use greater or equal (or lesser or equal) insteal of greater (or lesser). Mark the condition of having found a value which exceeds the limit as unlikely. 2018-05-08 Thomas Koenig PR fortran/54613 * m4/iforeach-s.m4: Remove assertion that back is zero. * m4/iforeach.m4: Likewise. Remove leading 'do' before implementation start. * m4/ifunction-s.m4: Remove assertion that back is zero. * m4/ifunction.m4: Likewise. Remove for loop if HAVE_BACK_ARG is defined. * m4/maxloc0.m4: Reorganize loops. Split loops between >= and =, depending if back is true. Mark the condition of having found a value which exceeds the limit as unlikely. * m4/minloc0.m4: Likewise. * m4/maxloc1.m4: Likewise. * m4/minloc1.m4: Likewise. * m4/maxloc1s.m4: Handle back argument. * m4/minloc1s.m4: Likewise. * m4/maxloc2s.m4: Remove assertion that back is zero. Remove special handling of loop start. Handle back argument. * m4/minloc2s.m4: Likewise. * generated/iall_i1.c: Regenerated. * generated/iall_i16.c: Regenerated. * generated/iall_i2.c: Regenerated. * generated/iall_i4.c: Regenerated. * generated/iall_i8.c: Regenerated. * generated/iany_i1.c: Regenerated. * generated/iany_i16.c: Regenerated. * generated/iany_i2.c: Regenerated. * generated/iany_i4.c: Regenerated. * generated/iany_i8.c: Regenerated. * generated/iparity_i1.c: Regenerated. * generated/iparity_i16.c: Regenerated. * generated/iparity_i2.c: Regenerated. * generated/iparity_i4.c: Regenerated. * generated/iparity_i8.c: Regenerated. * generated/maxloc0_16_i1.c: Regenerated. * generated/maxloc0_16_i16.c: Regenerated. * generated/maxloc0_16_i2.c: Regenerated. * generated/maxloc0_16_i4.c: Regenerated. * generated/maxloc0_16_i8.c: Regenerated. * generated/maxloc0_16_r10.c: Regenerated. * generated/maxloc0_16_r16.c: Regenerated. * generated/maxloc0_16_r4.c: Regenerated. * generated/maxloc0_16_r8.c: Regenerated. * generated/maxloc0_16_s1.c: Regenerated. * generated/maxloc0_16_s4.c: Regenerated. * generated/maxloc0_4_i1.c: Regenerated. * generated/maxloc0_4_i16.c: Regenerated. * generated/maxloc0_4_i2.c: Regenerated. * generated/maxloc0_4_i4.c: Regenerated. * generated/maxloc0_4_i8.c: Regenerated. * generated/maxloc0_4_r10.c: Regenerated. * generated/maxloc0_4_r16.c: Regenerated. * generated/maxloc0_4_r4.c: Regenerated. * generated/maxloc0_4_r8.c: Regenerated. * generated/maxloc0_4_s1.c: Regenerated. * generated/maxloc0_4_s4.c: Regenerated. * generated/maxloc0_8_i1.c: Regenerated. * generated/maxloc0_8_i16.c: Regenerated. * generated/maxloc0_8_i2.c: Regenerated. * generated/maxloc0_8_i4.c: Regenerated. * generated/maxloc0_8_i8.c: Regenerated. * generated/maxloc0_8_r10.c: Regenerated. * generated/maxloc0_8_r16.c: Regenerated. * generated/maxloc0_8_r4.c: Regenerated. * generated/maxloc0_8_r8.c: Regenerated. * generated/maxloc0_8_s1.c: Regenerated. * generated/maxloc0_8_s4.c: Regenerated. * generated/maxloc1_16_i1.c: Regenerated. * generated/maxloc1_16_i16.c: Regenerated. * generated/maxloc1_16_i2.c: Regenerated. * generated/maxloc1_16_i4.c: Regenerated. * generated/maxloc1_16_i8.c: Regenerated. * generated/maxloc1_16_r10.c: Regenerated. * generated/maxloc1_16_r16.c: Regenerated. * generated/maxloc1_16_r4.c: Regenerated. * generated/maxloc1_16_r8.c: Regenerated. * generated/maxloc1_16_s1.c: Regenerated. * generated/maxloc1_16_s4.c: Regenerated. * generated/maxloc1_4_i1.c: Regenerated. * generated/maxloc1_4_i16.c: Regenerated. * generated/maxloc1_4_i2.c: Regenerated. * generated/maxloc1_4_i4.c: Regenerated. * generated/maxloc1_4_i8.c: Regenerated. * generated/maxloc1_4_r10.c: Regenerated. * generated/maxloc1_4_r16.c: Regenerated. * generated/maxloc1_4_r4.c: Regenerated. * generated/maxloc1_4_r8.c: Regenerated. * generated/maxloc1_4_s1.c: Regenerated. * generated/maxloc1_4_s4.c: Regenerated. * generated/maxloc1_8_i1.c: Regenerated. * generated/maxloc1_8_i16.c: Regenerated. * generated/maxloc1_8_i2.c: Regenerated. * generated/maxloc1_8_i4.c: Regenerated. * generated/maxloc1_8_i8.c: Regenerated. * generated/maxloc1_8_r10.c: Regenerated. * generated/maxloc1_8_r16.c: Regenerated. * generated/maxloc1_8_r4.c: Regenerated. * generated/maxloc1_8_r8.c: Regenerated. * generated/maxloc1_8_s1.c: Regenerated. * generated/maxloc1_8_s4.c: Regenerated. * generated/maxloc2_16_s1.c: Regenerated. * generated/maxloc2_16_s4.c: Regenerated. * generated/maxloc2_4_s1.c: Regenerated. * generated/maxloc2_4_s4.c: Regenerated. * generated/maxloc2_8_s1.c: Regenerated. * generated/maxloc2_8_s4.c: Regenerated. * generated/maxval_i1.c: Regenerated. * generated/maxval_i16.c: Regenerated. * generated/maxval_i2.c: Regenerated. * generated/maxval_i4.c: Regenerated. * generated/maxval_i8.c: Regenerated. * generated/maxval_r10.c: Regenerated. * generated/maxval_r16.c: Regenerated. * generated/maxval_r4.c: Regenerated. * generated/maxval_r8.c: Regenerated. * generated/minloc0_16_i1.c: Regenerated. * generated/minloc0_16_i16.c: Regenerated. * generated/minloc0_16_i2.c: Regenerated. * generated/minloc0_16_i4.c: Regenerated. * generated/minloc0_16_i8.c: Regenerated. * generated/minloc0_16_r10.c: Regenerated. * generated/minloc0_16_r16.c: Regenerated. * generated/minloc0_16_r4.c: Regenerated. * generated/minloc0_16_r8.c: Regenerated. * generated/minloc0_16_s1.c: Regenerated. * generated/minloc0_16_s4.c: Regenerated. * generated/minloc0_4_i1.c: Regenerated. * generated/minloc0_4_i16.c: Regenerated. * generated/minloc0_4_i2.c: Regenerated. * generated/minloc0_4_i4.c: Regenerated. * generated/minloc0_4_i8.c: Regenerated. * generated/minloc0_4_r10.c: Regenerated. * generated/minloc0_4_r16.c: Regenerated. * generated/minloc0_4_r4.c: Regenerated. * generated/minloc0_4_r8.c: Regenerated. * generated/minloc0_4_s1.c: Regenerated. * generated/minloc0_4_s4.c: Regenerated. * generated/minloc0_8_i1.c: Regenerated. * generated/minloc0_8_i16.c: Regenerated. * generated/minloc0_8_i2.c: Regenerated. * generated/minloc0_8_i4.c: Regenerated. * generated/minloc0_8_i8.c: Regenerated. * generated/minloc0_8_r10.c: Regenerated. * generated/minloc0_8_r16.c: Regenerated. * generated/minloc0_8_r4.c: Regenerated. * generated/minloc0_8_r8.c: Regenerated. * generated/minloc0_8_s1.c: Regenerated. * generated/minloc0_8_s4.c: Regenerated. * generated/minloc1_16_i1.c: Regenerated. * generated/minloc1_16_i16.c: Regenerated. * generated/minloc1_16_i2.c: Regenerated. * generated/minloc1_16_i4.c: Regenerated. * generated/minloc1_16_i8.c: Regenerated. * generated/minloc1_16_r10.c: Regenerated. * generated/minloc1_16_r16.c: Regenerated. * generated/minloc1_16_r4.c: Regenerated. * generated/minloc1_16_r8.c: Regenerated. * generated/minloc1_16_s1.c: Regenerated. * generated/minloc1_16_s4.c: Regenerated. * generated/minloc1_4_i1.c: Regenerated. * generated/minloc1_4_i16.c: Regenerated. * generated/minloc1_4_i2.c: Regenerated. * generated/minloc1_4_i4.c: Regenerated. * generated/minloc1_4_i8.c: Regenerated. * generated/minloc1_4_r10.c: Regenerated. * generated/minloc1_4_r16.c: Regenerated. * generated/minloc1_4_r4.c: Regenerated. * generated/minloc1_4_r8.c: Regenerated. * generated/minloc1_4_s1.c: Regenerated. * generated/minloc1_4_s4.c: Regenerated. * generated/minloc1_8_i1.c: Regenerated. * generated/minloc1_8_i16.c: Regenerated. * generated/minloc1_8_i2.c: Regenerated. * generated/minloc1_8_i4.c: Regenerated. * generated/minloc1_8_i8.c: Regenerated. * generated/minloc1_8_r10.c: Regenerated. * generated/minloc1_8_r16.c: Regenerated. * generated/minloc1_8_r4.c: Regenerated. * generated/minloc1_8_r8.c: Regenerated. * generated/minloc1_8_s1.c: Regenerated. * generated/minloc1_8_s4.c: Regenerated. * generated/minloc2_16_s1.c: Regenerated. * generated/minloc2_16_s4.c: Regenerated. * generated/minloc2_4_s1.c: Regenerated. * generated/minloc2_4_s4.c: Regenerated. * generated/minloc2_8_s1.c: Regenerated. * generated/minloc2_8_s4.c: Regenerated. * generated/minval_i1.c: Regenerated. * generated/minval_i16.c: Regenerated. * generated/minval_i2.c: Regenerated. * generated/minval_i4.c: Regenerated. * generated/minval_i8.c: Regenerated. * generated/minval_r10.c: Regenerated. * generated/minval_r16.c: Regenerated. * generated/minval_r4.c: Regenerated. * generated/minval_r8.c: Regenerated. * generated/norm2_r10.c: Regenerated. * generated/norm2_r16.c: Regenerated. * generated/norm2_r4.c: Regenerated. * generated/norm2_r8.c: Regenerated. * generated/parity_l1.c: Regenerated. * generated/parity_l16.c: Regenerated. * generated/parity_l2.c: Regenerated. * generated/parity_l4.c: Regenerated. * generated/parity_l8.c: Regenerated. * generated/product_c10.c: Regenerated. * generated/product_c16.c: Regenerated. * generated/product_c4.c: Regenerated. * generated/product_c8.c: Regenerated. * generated/product_i1.c: Regenerated. * generated/product_i16.c: Regenerated. * generated/product_i2.c: Regenerated. * generated/product_i4.c: Regenerated. * generated/product_i8.c: Regenerated. * generated/product_r10.c: Regenerated. * generated/product_r16.c: Regenerated. * generated/product_r4.c: Regenerated. * generated/product_r8.c: Regenerated. * generated/sum_c10.c: Regenerated. * generated/sum_c16.c: Regenerated. * generated/sum_c4.c: Regenerated. * generated/sum_c8.c: Regenerated. * generated/sum_i1.c: Regenerated. * generated/sum_i16.c: Regenerated. * generated/sum_i2.c: Regenerated. * generated/sum_i4.c: Regenerated. * generated/sum_i8.c: Regenerated. * generated/sum_r10.c: Regenerated. * generated/sum_r16.c: Regenerated. * generated/sum_r4.c: Regenerated. * generated/sum_r8.c: Regenerated. 2018-05-08 Thomas Koenig PR fortran/54613 * gfortran.dg/minmaxloc_12.f90: New test case. * gfortran.dg/minmaxloc_13.f90: New test case. From-SVN: r260023 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3735dc6a9616..91a84feb6565 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,24 @@ +2018-05-08 Thomas Koenig + + PR fortran/54613 + * check.c (gfc_check_minmaxloc): Remove error for BACK not being + implemented. Use gfc_logical_4_kind for BACK. + * simplify.c (min_max_choose): Add optional argument back_val. + Handle it. + (simplify_minmaxloc_to_scalar): Add argument back_val. Pass + back_val to min_max_choose. + (simplify_minmaxloc_to_nodim): Likewise. + (simplify_minmaxloc_to_array): Likewise. + (gfc_simplify_minmaxloc): Add argument back, handle it. + Pass back_val to specific simplification functions. + (gfc_simplify_minloc): Remove ATTRIBUTE_UNUSED from argument back, + pass it on to gfc_simplify_minmaxloc. + (gfc_simplify_maxloc): Likewise. + * trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Adjust + comment. If BACK is true, use greater or equal (or lesser or + equal) insteal of greater (or lesser). Mark the condition of + having found a value which exceeds the limit as unlikely. + 2018-05-07 Jeff Law * scanner.c (preprocessor_line): Call linemap_add after a line diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 83bd004eaac2..61b72c12bbe9 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -3306,18 +3306,10 @@ gfc_check_minloc_maxloc (gfc_actual_arglist *ap) { if (!type_check (b, 4, BT_LOGICAL) || !scalar_check (b,4)) return false; - - /* TODO: Remove this once BACK is actually implemented. */ - if (b->expr_type != EXPR_CONSTANT || b->value.logical != 0) - { - gfc_error ("BACK argument to %qs intrinsic not yet " - "implemented", gfc_current_intrinsic); - return false; - } } else { - b = gfc_get_logical_expr (gfc_default_logical_kind, NULL, 0); + b = gfc_get_logical_expr (gfc_logical_4_kind, NULL, 0); ap->next->next->next->next->expr = b; } diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index a970e017c903..fdd85edf62c6 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. If not see /* Prototypes. */ -static int min_max_choose (gfc_expr *, gfc_expr *, int); +static int min_max_choose (gfc_expr *, gfc_expr *, int, bool back_val = false); gfc_expr gfc_bad_expr; @@ -4877,7 +4877,7 @@ gfc_simplify_merge_bits (gfc_expr *i, gfc_expr *j, gfc_expr *mask_expr) /* Selects between current value and extremum for simplify_min_max and simplify_minval_maxval. */ static int -min_max_choose (gfc_expr *arg, gfc_expr *extremum, int sign) +min_max_choose (gfc_expr *arg, gfc_expr *extremum, int sign, bool back_val) { int ret; @@ -4940,6 +4940,9 @@ min_max_choose (gfc_expr *arg, gfc_expr *extremum, int sign) default: gfc_internal_error ("simplify_min_max(): Bad type in arglist"); } + if (back_val && ret == 0) + ret = 1; + return ret; } @@ -5059,7 +5062,7 @@ gfc_simplify_maxval (gfc_expr *array, gfc_expr* dim, gfc_expr *mask) static gfc_expr * simplify_minmaxloc_to_scalar (gfc_expr *result, gfc_expr *array, gfc_expr *mask, - gfc_expr *extremum, int sign) + gfc_expr *extremum, int sign, bool back_val) { gfc_expr *a, *m; gfc_constructor *array_ctor, *mask_ctor; @@ -5094,7 +5097,7 @@ simplify_minmaxloc_to_scalar (gfc_expr *result, gfc_expr *array, gfc_expr *mask, if (!m->value.logical) continue; } - if (min_max_choose (a, extremum, sign) > 0) + if (min_max_choose (a, extremum, sign, back_val) > 0) mpz_set (result->value.integer, count); } mpz_clear (count); @@ -5106,7 +5109,8 @@ simplify_minmaxloc_to_scalar (gfc_expr *result, gfc_expr *array, gfc_expr *mask, static gfc_expr * simplify_minmaxloc_nodim (gfc_expr *result, gfc_expr *extremum, - gfc_expr *array, gfc_expr *mask, int sign) + gfc_expr *array, gfc_expr *mask, int sign, + bool back_val) { ssize_t res[GFC_MAX_DIMENSIONS]; int i, n; @@ -5158,7 +5162,7 @@ simplify_minmaxloc_nodim (gfc_expr *result, gfc_expr *extremum, else ma = true; - if (ma && min_max_choose (a, extremum, sign) > 0) + if (ma && min_max_choose (a, extremum, sign, back_val) > 0) { for (i = 0; irank; i++) res[i] = count[i]; @@ -5225,7 +5229,7 @@ new_array (bt type, int kind, int n, locus *where) static gfc_expr * simplify_minmaxloc_to_array (gfc_expr *result, gfc_expr *array, gfc_expr *dim, gfc_expr *mask, - gfc_expr *extremum, int sign) + gfc_expr *extremum, int sign, bool back_val) { mpz_t size; int done, i, n, arraysize, resultsize, dim_index, dim_extent, dim_stride; @@ -5313,7 +5317,7 @@ simplify_minmaxloc_to_array (gfc_expr *result, gfc_expr *array, ex = gfc_copy_expr (extremum); for (src = base, n = 0; n < dim_extent; src += dim_stride, ++n) { - if (*src && min_max_choose (*src, ex, sign) > 0) + if (*src && min_max_choose (*src, ex, sign, back_val) > 0) mpz_set_si ((*dest)->value.integer, n + 1); } @@ -5367,12 +5371,13 @@ simplify_minmaxloc_to_array (gfc_expr *result, gfc_expr *array, gfc_expr * gfc_simplify_minmaxloc (gfc_expr *array, gfc_expr *dim, gfc_expr *mask, - gfc_expr *kind, int sign) + gfc_expr *kind, gfc_expr *back, int sign) { gfc_expr *result; gfc_expr *extremum; int ikind; int init_val; + bool back_val = false; if (!is_constant_array_expr (array) || !gfc_is_constant_expr (dim)) @@ -5391,6 +5396,14 @@ gfc_simplify_minmaxloc (gfc_expr *array, gfc_expr *dim, gfc_expr *mask, else ikind = gfc_default_integer_kind; + if (back) + { + if (back->expr_type != EXPR_CONSTANT) + return NULL; + + back_val = back->value.logical; + } + if (sign < 0) init_val = INT_MAX; else if (sign > 0) @@ -5408,29 +5421,32 @@ gfc_simplify_minmaxloc (gfc_expr *array, gfc_expr *dim, gfc_expr *mask, init_result_expr (result, 0, array); if (array->rank == 1) - return simplify_minmaxloc_to_scalar (result, array, mask, extremum, sign); + return simplify_minmaxloc_to_scalar (result, array, mask, extremum, + sign, back_val); else - return simplify_minmaxloc_to_array (result, array, dim, mask, extremum, sign); + return simplify_minmaxloc_to_array (result, array, dim, mask, extremum, + sign, back_val); } else { result = new_array (BT_INTEGER, ikind, array->rank, &array->where); - return simplify_minmaxloc_nodim (result, extremum, array, mask, sign); + return simplify_minmaxloc_nodim (result, extremum, array, mask, + sign, back_val); } } gfc_expr * gfc_simplify_minloc (gfc_expr *array, gfc_expr *dim, gfc_expr *mask, gfc_expr *kind, - gfc_expr *back ATTRIBUTE_UNUSED) + gfc_expr *back) { - return gfc_simplify_minmaxloc (array, dim, mask, kind, -1); + return gfc_simplify_minmaxloc (array, dim, mask, kind, back, -1); } gfc_expr * gfc_simplify_maxloc (gfc_expr *array, gfc_expr *dim, gfc_expr *mask, gfc_expr *kind, - gfc_expr *back ATTRIBUTE_UNUSED) + gfc_expr *back) { - return gfc_simplify_minmaxloc (array, dim, mask, kind, 1); + return gfc_simplify_minmaxloc (array, dim, mask, kind, back, 1); } gfc_expr * diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 87b3ca72c05a..651a97f1d3f7 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -4684,7 +4684,20 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, gfc_expr * expr) S++; } For 3) and 5), if mask is scalar, this all goes into a conditional, - setting pos = 0; in the else branch. */ + setting pos = 0; in the else branch. + + Since we now also support the BACK argument, instead of using + if (a[S] < limit), we now use + + if (back) + cond = a[S] <= limit; + else + cond = a[S] < limit; + if (cond) { + .... + + The optimizer is smart enough to move the condition out of the loop. + The are now marked as unlikely to for further speedup. */ static void gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) @@ -4702,6 +4715,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) tree offset; tree nonempty; tree lab1, lab2; + tree b_if, b_else; gfc_loopinfo loop; gfc_actual_arglist *actual; gfc_ss *arrayss; @@ -4710,6 +4724,8 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_se maskse; gfc_expr *arrayexpr; gfc_expr *maskexpr; + gfc_expr *backexpr; + gfc_se backse; tree pos; int n; @@ -4766,6 +4782,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) actual = actual->next->next; gcc_assert (actual); maskexpr = actual->expr; + backexpr = actual->next->next->expr; nonempty = NULL; if (maskexpr && maskexpr->rank != 0) { @@ -4904,6 +4921,10 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_conv_expr_val (&arrayse, arrayexpr); gfc_add_block_to_block (&block, &arrayse.pre); + gfc_init_se (&backse, NULL); + gfc_conv_expr_val (&backse, backexpr); + gfc_add_block_to_block (&block, &backse.pre); + /* We do the following if this is a more extreme value. */ gfc_start_block (&ifblock); @@ -4943,9 +4964,33 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) op == GT_EXPR ? GE_EXPR : LE_EXPR, logical_type_node, arrayse.expr, limit); else - cond = fold_build2_loc (input_location, op, logical_type_node, - arrayse.expr, limit); + { + tree ifbody2, elsebody2; + + /* We switch to > or >= depending on the value of the BACK argument. */ + cond = gfc_create_var (logical_type_node, "cond"); + + gfc_start_block (&ifblock); + b_if = fold_build2_loc (input_location, op == GT_EXPR ? GE_EXPR : LE_EXPR, + logical_type_node, arrayse.expr, limit); + + gfc_add_modify (&ifblock, cond, b_if); + ifbody2 = gfc_finish_block (&ifblock); + + gfc_start_block (&elseblock); + b_else = fold_build2_loc (input_location, op, logical_type_node, + arrayse.expr, limit); + + gfc_add_modify (&elseblock, cond, b_else); + elsebody2 = gfc_finish_block (&elseblock); + + tmp = fold_build3_loc (input_location, COND_EXPR, logical_type_node, + backse.expr, ifbody2, elsebody2); + + gfc_add_expr_to_block (&block, tmp); + } + cond = gfc_unlikely (cond, PRED_BUILTIN_EXPECT); ifbody = build3_v (COND_EXPR, cond, ifbody, build_empty_stmt (input_location)); } @@ -5014,11 +5059,35 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) ifbody = gfc_finish_block (&ifblock); - cond = fold_build2_loc (input_location, op, logical_type_node, - arrayse.expr, limit); + /* We switch to > or >= depending on the value of the BACK argument. */ + { + tree ifbody2, elsebody2; + + cond = gfc_create_var (logical_type_node, "cond"); + + gfc_start_block (&ifblock); + b_if = fold_build2_loc (input_location, op == GT_EXPR ? GE_EXPR : LE_EXPR, + logical_type_node, arrayse.expr, limit); + + gfc_add_modify (&ifblock, cond, b_if); + ifbody2 = gfc_finish_block (&ifblock); + gfc_start_block (&elseblock); + b_else = fold_build2_loc (input_location, op, logical_type_node, + arrayse.expr, limit); + + gfc_add_modify (&elseblock, cond, b_else); + elsebody2 = gfc_finish_block (&elseblock); + + tmp = fold_build3_loc (input_location, COND_EXPR, logical_type_node, + backse.expr, ifbody2, elsebody2); + } + + gfc_add_expr_to_block (&block, tmp); + cond = gfc_unlikely (cond, PRED_BUILTIN_EXPECT); tmp = build3_v (COND_EXPR, cond, ifbody, build_empty_stmt (input_location)); + gfc_add_expr_to_block (&block, tmp); if (maskss) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index df4bacbdb870..6a94c0695323 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-05-08 Thomas Koenig + + PR fortran/54613 + * gfortran.dg/minmaxloc_12.f90: New test case. + * gfortran.dg/minmaxloc_13.f90: New test case. + 2018-05-07 Nathan Sidwell * g++.dg/cpp0x/range-for10.C: Delete. diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_12.f90 b/gcc/testsuite/gfortran.dg/minmaxloc_12.f90 new file mode 100644 index 000000000000..54bebba826f4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/minmaxloc_12.f90 @@ -0,0 +1,67 @@ +! { dg-do run } +! Test compile-time simplification of minloc and maxloc with BACK argument +program main + integer, parameter :: i1(*) = [ 1,2,3,1,2,3]; + integer, parameter :: d1 = minloc(i1,dim=1,back=.true.) + integer, parameter :: d2 = minloc(i1,dim=1,back=.false.) + integer, parameter :: d3 = maxloc(i1,dim=1,back=.true.) + integer, parameter :: d4 = maxloc(i1,dim=1,back=.false.) + integer, parameter :: i2(4,4) = reshape([1,2,1,2,2,3,3,2,3,4,4,3,4,5,5,4], & + [4,4]); + integer, parameter :: d5(2) = minloc(i2,back=.true.) + integer, parameter :: d6(2) = maxloc(i2,back=.true.) + integer, parameter :: d7(4) = minloc(i2,dim=1,back=.true.) + integer, parameter :: d25(4) = minloc(i2,dim=2,mask=i2<2,back=.true.) + integer, parameter :: d26(4) = maxloc(i2,dim=1,mask=i2<3,back=.true.) + + integer, parameter :: i3(4,4) = transpose(i2) + integer, parameter :: d8(4) = minloc(i3,dim=2,back=.true.) + integer, parameter :: i4(4,4) = reshape([1,2,1,2,2,1,2,1,1,2,1,2,2,1,2,1],& + ([4,4])) + integer, parameter :: d9(4) = minloc(i4,dim=1,mask=i4>1,back=.true.) + + integer, parameter :: d10(4) = maxloc(i4,dim=1,mask=i4>1,back=.true.) + character(len=2), parameter :: c0(9) = ["aa", "bb", "aa", & + "cc", "bb", "cc", "aa", "bb", "aa"] + character(len=2), parameter :: c1 (3,3) = reshape(c0, [3,3]); + integer, parameter :: d11(2) = minloc(c1,back=.true.) + integer, parameter :: d12(2) = maxloc(c1,back=.true.) + integer, parameter :: d13(2) = minloc(c1,mask=c1>"aa",back=.true.) + integer, parameter :: d14(2) = maxloc(c1,mask=c1<"cc",back=.true.) + integer, parameter :: d15(3) = minloc(c1,dim=1,back=.true.) + integer, parameter :: d16(3) = maxloc(c1,dim=1,back=.true.) + integer, parameter :: d17(3) = minloc(c1,dim=2,back=.true.) + integer, parameter :: d18(3) = maxloc(c1,dim=2,back=.true.) + integer, parameter :: d19 = minloc(c0,dim=1,back=.true.) + integer, parameter :: d20 = maxloc(c0,dim=1,back=.true.) + integer, parameter :: d21 = minloc(c0,dim=1,mask=c0>"aa",back=.true.) + integer, parameter :: d22 = maxloc(c0,dim=1,mask=c0<"cc",back=.true.) + integer, parameter :: d23(3) = minloc(c1,dim=2,mask=c1>"aa",back=.true.) + integer, parameter :: d24(3) = maxloc(c1,dim=2,mask=c1<"cc",back=.true.) + + if (d1 /= 4) STOP 2078 + if (d2 /= 1) STOP 2079 + if (d3 /= 6) STOP 2080 + if (d4 /= 3) STOP 2081 + if (any (d5 /= [3,1])) STOP 2082 + if (any (d6 /= [3,4])) STOP 2083 + if (any (d7 /= [3,4,4,4])) STOP 2084 + if (any (d8 /= d7)) STOP 2085 + if (any (d9 /= [4,3,4,3])) STOP 2086 + if (any (d10 /= d9)) STOP 2087 + if (any(d11 /= [3,3])) STOP 2088 + if (any(d12 /= [3,2])) STOP 2089 + if (any(d13 /= [2,3])) STOP 2090 + if (any(d14 /= [2,3])) STOP 2091 + if (any(d15 /= [3,2,3])) STOP 2092 + if (any(d16 /= [2,3,2])) STOP 2093 + if (any(d17 /= [3,3,3])) STOP 2094 + if (any(d18 /= [2,3,2])) STOP 2095 + if (d19 /= 9) STOP 2096 + if (d20 /= 6) STOP 2097 + if (d21 /= 8 .or. d22 /= 8) STOP 2098 + if (any(d23 /= [2,3,2])) STOP 2099 + if (any(d24 /= 3)) STOP 2100 + if (any(d25 /= [1,0,1,0])) STOP 2101 + if (any(d26 /= [4,4,0,0])) STOP 2102 +end program main diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_13.f90 b/gcc/testsuite/gfortran.dg/minmaxloc_13.f90 new file mode 100644 index 000000000000..3ebfdc921ec3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/minmaxloc_13.f90 @@ -0,0 +1,103 @@ +! { dg-do run } +! Test run-time of MINLOC and MAXLOC with BACK +program main + implicit none + integer:: i1(6) + integer:: d1 + integer:: d2 + integer:: d3 + integer:: d4 + integer:: i2(4,4) + integer:: d5(2) + integer:: d6(2) + integer:: d7(4) + integer:: d25(4) + integer:: d26(4) + + integer:: i3(4,4) + integer:: d8(4) + integer:: i4(4,4) + integer:: d9(4) + + integer:: d10(4) + character(len=2) :: c0(9) + character(len=2) :: c1(3,3) + integer:: d11(2) + integer:: d12(2) + integer:: d13(2) + integer:: d14(2) + integer:: d15(3) + integer:: d16(3) + integer:: d17(3) + integer:: d18(3) + integer:: d19 + integer:: d20 + integer:: d21 + integer:: d22 + integer:: d23(3) + integer:: d24(3) + + i1 = [ 1,2,3,1,2,3]; + d1 = minloc(i1,dim=1,back=.true.) + d2 = minloc(i1,dim=1,back=.false.) + d3 = maxloc(i1,dim=1,back=.true.) + d4 = maxloc(i1,dim=1,back=.false.) + i2 = reshape([1,2,1,2,2,3,3,2,3,4,4,3,4,5,5,4], & + [4,4]); + d5 = minloc(i2,back=.true.) + d6 = maxloc(i2,back=.true.) + d7= minloc(i2,dim=1,back=.true.) + d25 = minloc(i2,dim=2,mask=i2<2,back=.true.) + d26 = maxloc(i2,dim=1,mask=i2<3,back=.true.) + + i3 = transpose(i2) + d8 = minloc(i3,dim=2,back=.true.) + i4 = reshape([1,2,1,2,2,1,2,1,1,2,1,2,2,1,2,1],& + ([4,4])) + d9 = minloc(i4,dim=1,mask=i4>1,back=.true.) + + d10 = maxloc(i4,dim=1,mask=i4>1,back=.true.) + c0 = ["aa", "bb", "aa", & + "cc", "bb", "cc", "aa", "bb", "aa"] + c1 = reshape(c0, [3,3]); + d11 = minloc(c1,back=.true.) + d12 = maxloc(c1,back=.true.) + d13 = minloc(c1,mask=c1>"aa",back=.true.) + d14 = maxloc(c1,mask=c1<"cc",back=.true.) + d15 = minloc(c1,dim=1,back=.true.) + d16 = maxloc(c1,dim=1,back=.true.) + d17 = minloc(c1,dim=2,back=.true.) + d18 = maxloc(c1,dim=2,back=.true.) + d19 = minloc(c0,dim=1,back=.true.) + d20 = maxloc(c0,dim=1,back=.true.) + d21 = minloc(c0,dim=1,mask=c0>"aa",back=.true.) + d22 = maxloc(c0,dim=1,mask=c0<"cc",back=.true.) + d23 = minloc(c1,dim=2,mask=c1>"aa",back=.true.) + d24 = maxloc(c1,dim=2,mask=c1<"cc",back=.true.) + + if (d1 /= 4) STOP 2626 + if (d2 /= 1) STOP 2627 + if (d3 /= 6) STOP 2628 + if (d4 /= 3) STOP 2629 + if (any (d5 /= [3,1])) STOP 2630 + if (any (d6 /= [3,4])) STOP 2631 + if (any (d7 /= [3,4,4,4])) STOP 2632 + if (any (d8 /= d7)) STOP 2633 + if (any (d9 /= [4,3,4,3])) STOP 2634 + if (any (d10 /= d9)) STOP 2635 + if (any(d11 /= [3,3])) STOP 2636 + if (any(d12 /= [3,2])) STOP 2637 + if (any(d13 /= [2,3])) STOP 2638 + if (any(d14 /= [2,3])) STOP 2639 + if (any(d15 /= [3,2,3])) STOP 2640 + if (any(d16 /= [2,3,2])) STOP 2641 + if (any(d17 /= [3,3,3])) STOP 2642 + if (any(d18 /= [2,3,2])) STOP 2643 + if (d19 /= 9) STOP 2644 + if (d20 /= 6) STOP 2645 + if (d21 /= 8 .or. d22 /= 8) STOP 2646 + if (any(d23 /= [2,3,2])) STOP 2647 + if (any(d24 /= 3)) STOP 2648 + if (any(d25 /= [1,0,1,0])) STOP 2649 + if (any(d26 /= [4,4,0,0])) STOP 2650 +end program diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 355f568a0625..7a232acafaba 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,236 @@ +2018-05-08 Thomas Koenig + + PR fortran/54613 + * m4/iforeach-s.m4: Remove assertion that back is zero. + * m4/iforeach.m4: Likewise. Remove leading 'do' + before implementation start. + * m4/ifunction-s.m4: Remove assertion that back is zero. + * m4/ifunction.m4: Likewise. Remove for loop if HAVE_BACK_ARG + is defined. + * m4/maxloc0.m4: Reorganize loops. Split loops between >= and =, + depending if back is true. Mark the condition of having + found a value which exceeds the limit as unlikely. + * m4/minloc0.m4: Likewise. + * m4/maxloc1.m4: Likewise. + * m4/minloc1.m4: Likewise. + * m4/maxloc1s.m4: Handle back argument. + * m4/minloc1s.m4: Likewise. + * m4/maxloc2s.m4: Remove assertion that back is zero. + Remove special handling of loop start. Handle back argument. + * m4/minloc2s.m4: Likewise. + * generated/iall_i1.c: Regenerated. + * generated/iall_i16.c: Regenerated. + * generated/iall_i2.c: Regenerated. + * generated/iall_i4.c: Regenerated. + * generated/iall_i8.c: Regenerated. + * generated/iany_i1.c: Regenerated. + * generated/iany_i16.c: Regenerated. + * generated/iany_i2.c: Regenerated. + * generated/iany_i4.c: Regenerated. + * generated/iany_i8.c: Regenerated. + * generated/iparity_i1.c: Regenerated. + * generated/iparity_i16.c: Regenerated. + * generated/iparity_i2.c: Regenerated. + * generated/iparity_i4.c: Regenerated. + * generated/iparity_i8.c: Regenerated. + * generated/maxloc0_16_i1.c: Regenerated. + * generated/maxloc0_16_i16.c: Regenerated. + * generated/maxloc0_16_i2.c: Regenerated. + * generated/maxloc0_16_i4.c: Regenerated. + * generated/maxloc0_16_i8.c: Regenerated. + * generated/maxloc0_16_r10.c: Regenerated. + * generated/maxloc0_16_r16.c: Regenerated. + * generated/maxloc0_16_r4.c: Regenerated. + * generated/maxloc0_16_r8.c: Regenerated. + * generated/maxloc0_16_s1.c: Regenerated. + * generated/maxloc0_16_s4.c: Regenerated. + * generated/maxloc0_4_i1.c: Regenerated. + * generated/maxloc0_4_i16.c: Regenerated. + * generated/maxloc0_4_i2.c: Regenerated. + * generated/maxloc0_4_i4.c: Regenerated. + * generated/maxloc0_4_i8.c: Regenerated. + * generated/maxloc0_4_r10.c: Regenerated. + * generated/maxloc0_4_r16.c: Regenerated. + * generated/maxloc0_4_r4.c: Regenerated. + * generated/maxloc0_4_r8.c: Regenerated. + * generated/maxloc0_4_s1.c: Regenerated. + * generated/maxloc0_4_s4.c: Regenerated. + * generated/maxloc0_8_i1.c: Regenerated. + * generated/maxloc0_8_i16.c: Regenerated. + * generated/maxloc0_8_i2.c: Regenerated. + * generated/maxloc0_8_i4.c: Regenerated. + * generated/maxloc0_8_i8.c: Regenerated. + * generated/maxloc0_8_r10.c: Regenerated. + * generated/maxloc0_8_r16.c: Regenerated. + * generated/maxloc0_8_r4.c: Regenerated. + * generated/maxloc0_8_r8.c: Regenerated. + * generated/maxloc0_8_s1.c: Regenerated. + * generated/maxloc0_8_s4.c: Regenerated. + * generated/maxloc1_16_i1.c: Regenerated. + * generated/maxloc1_16_i16.c: Regenerated. + * generated/maxloc1_16_i2.c: Regenerated. + * generated/maxloc1_16_i4.c: Regenerated. + * generated/maxloc1_16_i8.c: Regenerated. + * generated/maxloc1_16_r10.c: Regenerated. + * generated/maxloc1_16_r16.c: Regenerated. + * generated/maxloc1_16_r4.c: Regenerated. + * generated/maxloc1_16_r8.c: Regenerated. + * generated/maxloc1_16_s1.c: Regenerated. + * generated/maxloc1_16_s4.c: Regenerated. + * generated/maxloc1_4_i1.c: Regenerated. + * generated/maxloc1_4_i16.c: Regenerated. + * generated/maxloc1_4_i2.c: Regenerated. + * generated/maxloc1_4_i4.c: Regenerated. + * generated/maxloc1_4_i8.c: Regenerated. + * generated/maxloc1_4_r10.c: Regenerated. + * generated/maxloc1_4_r16.c: Regenerated. + * generated/maxloc1_4_r4.c: Regenerated. + * generated/maxloc1_4_r8.c: Regenerated. + * generated/maxloc1_4_s1.c: Regenerated. + * generated/maxloc1_4_s4.c: Regenerated. + * generated/maxloc1_8_i1.c: Regenerated. + * generated/maxloc1_8_i16.c: Regenerated. + * generated/maxloc1_8_i2.c: Regenerated. + * generated/maxloc1_8_i4.c: Regenerated. + * generated/maxloc1_8_i8.c: Regenerated. + * generated/maxloc1_8_r10.c: Regenerated. + * generated/maxloc1_8_r16.c: Regenerated. + * generated/maxloc1_8_r4.c: Regenerated. + * generated/maxloc1_8_r8.c: Regenerated. + * generated/maxloc1_8_s1.c: Regenerated. + * generated/maxloc1_8_s4.c: Regenerated. + * generated/maxloc2_16_s1.c: Regenerated. + * generated/maxloc2_16_s4.c: Regenerated. + * generated/maxloc2_4_s1.c: Regenerated. + * generated/maxloc2_4_s4.c: Regenerated. + * generated/maxloc2_8_s1.c: Regenerated. + * generated/maxloc2_8_s4.c: Regenerated. + * generated/maxval_i1.c: Regenerated. + * generated/maxval_i16.c: Regenerated. + * generated/maxval_i2.c: Regenerated. + * generated/maxval_i4.c: Regenerated. + * generated/maxval_i8.c: Regenerated. + * generated/maxval_r10.c: Regenerated. + * generated/maxval_r16.c: Regenerated. + * generated/maxval_r4.c: Regenerated. + * generated/maxval_r8.c: Regenerated. + * generated/minloc0_16_i1.c: Regenerated. + * generated/minloc0_16_i16.c: Regenerated. + * generated/minloc0_16_i2.c: Regenerated. + * generated/minloc0_16_i4.c: Regenerated. + * generated/minloc0_16_i8.c: Regenerated. + * generated/minloc0_16_r10.c: Regenerated. + * generated/minloc0_16_r16.c: Regenerated. + * generated/minloc0_16_r4.c: Regenerated. + * generated/minloc0_16_r8.c: Regenerated. + * generated/minloc0_16_s1.c: Regenerated. + * generated/minloc0_16_s4.c: Regenerated. + * generated/minloc0_4_i1.c: Regenerated. + * generated/minloc0_4_i16.c: Regenerated. + * generated/minloc0_4_i2.c: Regenerated. + * generated/minloc0_4_i4.c: Regenerated. + * generated/minloc0_4_i8.c: Regenerated. + * generated/minloc0_4_r10.c: Regenerated. + * generated/minloc0_4_r16.c: Regenerated. + * generated/minloc0_4_r4.c: Regenerated. + * generated/minloc0_4_r8.c: Regenerated. + * generated/minloc0_4_s1.c: Regenerated. + * generated/minloc0_4_s4.c: Regenerated. + * generated/minloc0_8_i1.c: Regenerated. + * generated/minloc0_8_i16.c: Regenerated. + * generated/minloc0_8_i2.c: Regenerated. + * generated/minloc0_8_i4.c: Regenerated. + * generated/minloc0_8_i8.c: Regenerated. + * generated/minloc0_8_r10.c: Regenerated. + * generated/minloc0_8_r16.c: Regenerated. + * generated/minloc0_8_r4.c: Regenerated. + * generated/minloc0_8_r8.c: Regenerated. + * generated/minloc0_8_s1.c: Regenerated. + * generated/minloc0_8_s4.c: Regenerated. + * generated/minloc1_16_i1.c: Regenerated. + * generated/minloc1_16_i16.c: Regenerated. + * generated/minloc1_16_i2.c: Regenerated. + * generated/minloc1_16_i4.c: Regenerated. + * generated/minloc1_16_i8.c: Regenerated. + * generated/minloc1_16_r10.c: Regenerated. + * generated/minloc1_16_r16.c: Regenerated. + * generated/minloc1_16_r4.c: Regenerated. + * generated/minloc1_16_r8.c: Regenerated. + * generated/minloc1_16_s1.c: Regenerated. + * generated/minloc1_16_s4.c: Regenerated. + * generated/minloc1_4_i1.c: Regenerated. + * generated/minloc1_4_i16.c: Regenerated. + * generated/minloc1_4_i2.c: Regenerated. + * generated/minloc1_4_i4.c: Regenerated. + * generated/minloc1_4_i8.c: Regenerated. + * generated/minloc1_4_r10.c: Regenerated. + * generated/minloc1_4_r16.c: Regenerated. + * generated/minloc1_4_r4.c: Regenerated. + * generated/minloc1_4_r8.c: Regenerated. + * generated/minloc1_4_s1.c: Regenerated. + * generated/minloc1_4_s4.c: Regenerated. + * generated/minloc1_8_i1.c: Regenerated. + * generated/minloc1_8_i16.c: Regenerated. + * generated/minloc1_8_i2.c: Regenerated. + * generated/minloc1_8_i4.c: Regenerated. + * generated/minloc1_8_i8.c: Regenerated. + * generated/minloc1_8_r10.c: Regenerated. + * generated/minloc1_8_r16.c: Regenerated. + * generated/minloc1_8_r4.c: Regenerated. + * generated/minloc1_8_r8.c: Regenerated. + * generated/minloc1_8_s1.c: Regenerated. + * generated/minloc1_8_s4.c: Regenerated. + * generated/minloc2_16_s1.c: Regenerated. + * generated/minloc2_16_s4.c: Regenerated. + * generated/minloc2_4_s1.c: Regenerated. + * generated/minloc2_4_s4.c: Regenerated. + * generated/minloc2_8_s1.c: Regenerated. + * generated/minloc2_8_s4.c: Regenerated. + * generated/minval_i1.c: Regenerated. + * generated/minval_i16.c: Regenerated. + * generated/minval_i2.c: Regenerated. + * generated/minval_i4.c: Regenerated. + * generated/minval_i8.c: Regenerated. + * generated/minval_r10.c: Regenerated. + * generated/minval_r16.c: Regenerated. + * generated/minval_r4.c: Regenerated. + * generated/minval_r8.c: Regenerated. + * generated/norm2_r10.c: Regenerated. + * generated/norm2_r16.c: Regenerated. + * generated/norm2_r4.c: Regenerated. + * generated/norm2_r8.c: Regenerated. + * generated/parity_l1.c: Regenerated. + * generated/parity_l16.c: Regenerated. + * generated/parity_l2.c: Regenerated. + * generated/parity_l4.c: Regenerated. + * generated/parity_l8.c: Regenerated. + * generated/product_c10.c: Regenerated. + * generated/product_c16.c: Regenerated. + * generated/product_c4.c: Regenerated. + * generated/product_c8.c: Regenerated. + * generated/product_i1.c: Regenerated. + * generated/product_i16.c: Regenerated. + * generated/product_i2.c: Regenerated. + * generated/product_i4.c: Regenerated. + * generated/product_i8.c: Regenerated. + * generated/product_r10.c: Regenerated. + * generated/product_r16.c: Regenerated. + * generated/product_r4.c: Regenerated. + * generated/product_r8.c: Regenerated. + * generated/sum_c10.c: Regenerated. + * generated/sum_c16.c: Regenerated. + * generated/sum_c4.c: Regenerated. + * generated/sum_c8.c: Regenerated. + * generated/sum_i1.c: Regenerated. + * generated/sum_i16.c: Regenerated. + * generated/sum_i2.c: Regenerated. + * generated/sum_i4.c: Regenerated. + * generated/sum_i8.c: Regenerated. + * generated/sum_r10.c: Regenerated. + * generated/sum_r16.c: Regenerated. + * generated/sum_r4.c: Regenerated. + * generated/sum_r8.c: Regenerated. + 2018-04-24 H.J. Lu * configure: Regenerated. diff --git a/libgfortran/generated/iall_i1.c b/libgfortran/generated/iall_i1.c index a171ed210530..f02f7afa4b08 100644 --- a/libgfortran/generated/iall_i1.c +++ b/libgfortran/generated/iall_i1.c @@ -51,10 +51,6 @@ iall_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iall_i1 (gfc_array_i1 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result &= *src; } @@ -222,9 +220,6 @@ miall_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iall_i16.c b/libgfortran/generated/iall_i16.c index 80c89e828dd8..e739fad7abd3 100644 --- a/libgfortran/generated/iall_i16.c +++ b/libgfortran/generated/iall_i16.c @@ -51,10 +51,6 @@ iall_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iall_i16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result &= *src; } @@ -222,9 +220,6 @@ miall_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iall_i2.c b/libgfortran/generated/iall_i2.c index 618b02479b27..ff958a9cd332 100644 --- a/libgfortran/generated/iall_i2.c +++ b/libgfortran/generated/iall_i2.c @@ -51,10 +51,6 @@ iall_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iall_i2 (gfc_array_i2 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result &= *src; } @@ -222,9 +220,6 @@ miall_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iall_i4.c b/libgfortran/generated/iall_i4.c index 808e073003d1..ece32e481d92 100644 --- a/libgfortran/generated/iall_i4.c +++ b/libgfortran/generated/iall_i4.c @@ -51,10 +51,6 @@ iall_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iall_i4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result &= *src; } @@ -222,9 +220,6 @@ miall_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iall_i8.c b/libgfortran/generated/iall_i8.c index c487b6cacfb2..f181f153c741 100644 --- a/libgfortran/generated/iall_i8.c +++ b/libgfortran/generated/iall_i8.c @@ -51,10 +51,6 @@ iall_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iall_i8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result &= *src; } @@ -222,9 +220,6 @@ miall_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iany_i1.c b/libgfortran/generated/iany_i1.c index 0890eed633ab..20088edee3a7 100644 --- a/libgfortran/generated/iany_i1.c +++ b/libgfortran/generated/iany_i1.c @@ -51,10 +51,6 @@ iany_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iany_i1 (gfc_array_i1 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result |= *src; } @@ -222,9 +220,6 @@ miany_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iany_i16.c b/libgfortran/generated/iany_i16.c index 126db338d337..90844e884f42 100644 --- a/libgfortran/generated/iany_i16.c +++ b/libgfortran/generated/iany_i16.c @@ -51,10 +51,6 @@ iany_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iany_i16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result |= *src; } @@ -222,9 +220,6 @@ miany_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iany_i2.c b/libgfortran/generated/iany_i2.c index 3a26b2ced842..e73438953013 100644 --- a/libgfortran/generated/iany_i2.c +++ b/libgfortran/generated/iany_i2.c @@ -51,10 +51,6 @@ iany_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iany_i2 (gfc_array_i2 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result |= *src; } @@ -222,9 +220,6 @@ miany_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iany_i4.c b/libgfortran/generated/iany_i4.c index 8b81d001be10..48043eefd2ab 100644 --- a/libgfortran/generated/iany_i4.c +++ b/libgfortran/generated/iany_i4.c @@ -51,10 +51,6 @@ iany_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iany_i4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result |= *src; } @@ -222,9 +220,6 @@ miany_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iany_i8.c b/libgfortran/generated/iany_i8.c index 9ffc9b6c89ae..078160b24b73 100644 --- a/libgfortran/generated/iany_i8.c +++ b/libgfortran/generated/iany_i8.c @@ -51,10 +51,6 @@ iany_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iany_i8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result |= *src; } @@ -222,9 +220,6 @@ miany_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iparity_i1.c b/libgfortran/generated/iparity_i1.c index b4d4240291c7..911f9f5a6e54 100644 --- a/libgfortran/generated/iparity_i1.c +++ b/libgfortran/generated/iparity_i1.c @@ -51,10 +51,6 @@ iparity_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iparity_i1 (gfc_array_i1 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result ^= *src; } @@ -222,9 +220,6 @@ miparity_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iparity_i16.c b/libgfortran/generated/iparity_i16.c index 96cb108b0eed..b434f01b4f14 100644 --- a/libgfortran/generated/iparity_i16.c +++ b/libgfortran/generated/iparity_i16.c @@ -51,10 +51,6 @@ iparity_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iparity_i16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result ^= *src; } @@ -222,9 +220,6 @@ miparity_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iparity_i2.c b/libgfortran/generated/iparity_i2.c index b077f29c3811..998df01fd8d3 100644 --- a/libgfortran/generated/iparity_i2.c +++ b/libgfortran/generated/iparity_i2.c @@ -51,10 +51,6 @@ iparity_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iparity_i2 (gfc_array_i2 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result ^= *src; } @@ -222,9 +220,6 @@ miparity_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iparity_i4.c b/libgfortran/generated/iparity_i4.c index 1b5dfe0397ae..a0c515c77173 100644 --- a/libgfortran/generated/iparity_i4.c +++ b/libgfortran/generated/iparity_i4.c @@ -51,10 +51,6 @@ iparity_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iparity_i4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result ^= *src; } @@ -222,9 +220,6 @@ miparity_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/iparity_i8.c b/libgfortran/generated/iparity_i8.c index 056a59bfaeae..3225513273e6 100644 --- a/libgfortran/generated/iparity_i8.c +++ b/libgfortran/generated/iparity_i8.c @@ -51,10 +51,6 @@ iparity_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ iparity_i8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result ^= *src; } @@ -222,9 +220,6 @@ miparity_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxloc0_16_i1.c b/libgfortran/generated/maxloc0_16_i1.c index 25398cc79892..3bb69059e554 100644 --- a/libgfortran/generated/maxloc0_16_i1.c +++ b/libgfortran/generated/maxloc0_16_i1.c @@ -47,7 +47,6 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_1_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_i1 (gfc_array_i16 * const restrict, gfc_array_i1 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_i16.c b/libgfortran/generated/maxloc0_16_i16.c index 3a4a7446274c..7c2967fedde5 100644 --- a/libgfortran/generated/maxloc0_16_i16.c +++ b/libgfortran/generated/maxloc0_16_i16.c @@ -47,7 +47,6 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_i16 (gfc_array_i16 * const restrict, gfc_array_i16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_i2.c b/libgfortran/generated/maxloc0_16_i2.c index 0ff8ca0b183b..87edb85cdc63 100644 --- a/libgfortran/generated/maxloc0_16_i2.c +++ b/libgfortran/generated/maxloc0_16_i2.c @@ -47,7 +47,6 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_2_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_i2 (gfc_array_i16 * const restrict, gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_i4.c b/libgfortran/generated/maxloc0_16_i4.c index 84cff67ea087..38daf6d77a7d 100644 --- a/libgfortran/generated/maxloc0_16_i4.c +++ b/libgfortran/generated/maxloc0_16_i4.c @@ -47,7 +47,6 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_i4 (gfc_array_i16 * const restrict, gfc_array_i4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_i8.c b/libgfortran/generated/maxloc0_16_i8.c index e276295027b1..f48e943d9fce 100644 --- a/libgfortran/generated/maxloc0_16_i8.c +++ b/libgfortran/generated/maxloc0_16_i8.c @@ -47,7 +47,6 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_i8 (gfc_array_i16 * const restrict, gfc_array_i8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_r10.c b/libgfortran/generated/maxloc0_16_r10.c index 384487fadeb1..f1dc89be33e7 100644 --- a/libgfortran/generated/maxloc0_16_r10.c +++ b/libgfortran/generated/maxloc0_16_r10.c @@ -47,7 +47,6 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_10_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_r10 (gfc_array_i16 * const restrict, gfc_array_r10 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_r16.c b/libgfortran/generated/maxloc0_16_r16.c index 10c7673f73c1..7003a60ac688 100644 --- a/libgfortran/generated/maxloc0_16_r16.c +++ b/libgfortran/generated/maxloc0_16_r16.c @@ -47,7 +47,6 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_r16 (gfc_array_i16 * const restrict, gfc_array_r16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_r4.c b/libgfortran/generated/maxloc0_16_r4.c index b7aaa3d5cefd..0ada2d1b2088 100644 --- a/libgfortran/generated/maxloc0_16_r4.c +++ b/libgfortran/generated/maxloc0_16_r4.c @@ -47,7 +47,6 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_r4 (gfc_array_i16 * const restrict, gfc_array_r4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_r8.c b/libgfortran/generated/maxloc0_16_r8.c index 2ca3479d3f9f..75b59841aaae 100644 --- a/libgfortran/generated/maxloc0_16_r8.c +++ b/libgfortran/generated/maxloc0_16_r8.c @@ -47,7 +47,6 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, } } - extern void mmaxloc0_16_r8 (gfc_array_i16 * const restrict, gfc_array_r8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_16_s1.c b/libgfortran/generated/maxloc0_16_s1.c index a05d17893e3f..33f73e7d62ca 100644 --- a/libgfortran/generated/maxloc0_16_s1.c +++ b/libgfortran/generated/maxloc0_16_s1.c @@ -61,10 +61,6 @@ maxloc0_16_s1 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ maxloc0_16_s1 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_1 *maxval; - maxval = base; + maxval = NULL; while (base) { @@ -115,7 +111,8 @@ maxloc0_16_s1 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mmaxloc0_16_s1 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mmaxloc0_16_s1 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) + if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/maxloc0_16_s4.c b/libgfortran/generated/maxloc0_16_s4.c index f6adf95c356e..8eec34160cb0 100644 --- a/libgfortran/generated/maxloc0_16_s4.c +++ b/libgfortran/generated/maxloc0_16_s4.c @@ -61,10 +61,6 @@ maxloc0_16_s4 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ maxloc0_16_s4 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_4 *maxval; - maxval = base; + maxval = NULL; while (base) { @@ -115,7 +111,8 @@ maxloc0_16_s4 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mmaxloc0_16_s4 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mmaxloc0_16_s4 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) + if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/maxloc0_4_i1.c b/libgfortran/generated/maxloc0_4_i1.c index dc31e1d4b658..63a5d544c72f 100644 --- a/libgfortran/generated/maxloc0_4_i1.c +++ b/libgfortran/generated/maxloc0_4_i1.c @@ -47,7 +47,6 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_1_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_i1 (gfc_array_i4 * const restrict, gfc_array_i1 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_i16.c b/libgfortran/generated/maxloc0_4_i16.c index f7226001282c..b515ee0c097e 100644 --- a/libgfortran/generated/maxloc0_4_i16.c +++ b/libgfortran/generated/maxloc0_4_i16.c @@ -47,7 +47,6 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_i16 (gfc_array_i4 * const restrict, gfc_array_i16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_i2.c b/libgfortran/generated/maxloc0_4_i2.c index f78e20ec405a..563aebe28b7f 100644 --- a/libgfortran/generated/maxloc0_4_i2.c +++ b/libgfortran/generated/maxloc0_4_i2.c @@ -47,7 +47,6 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_2_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_i2 (gfc_array_i4 * const restrict, gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_i4.c b/libgfortran/generated/maxloc0_4_i4.c index 58c3cf1d4b48..7760807bac28 100644 --- a/libgfortran/generated/maxloc0_4_i4.c +++ b/libgfortran/generated/maxloc0_4_i4.c @@ -47,7 +47,6 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_i4 (gfc_array_i4 * const restrict, gfc_array_i4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_i8.c b/libgfortran/generated/maxloc0_4_i8.c index ded9b5bcadea..e9113183aab9 100644 --- a/libgfortran/generated/maxloc0_4_i8.c +++ b/libgfortran/generated/maxloc0_4_i8.c @@ -47,7 +47,6 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_i8 (gfc_array_i4 * const restrict, gfc_array_i8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_r10.c b/libgfortran/generated/maxloc0_4_r10.c index c64bd532380a..b335b2ed5eb0 100644 --- a/libgfortran/generated/maxloc0_4_r10.c +++ b/libgfortran/generated/maxloc0_4_r10.c @@ -47,7 +47,6 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_10_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_r10 (gfc_array_i4 * const restrict, gfc_array_r10 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_r16.c b/libgfortran/generated/maxloc0_4_r16.c index 4fd46a3371bc..6a27d69f0776 100644 --- a/libgfortran/generated/maxloc0_4_r16.c +++ b/libgfortran/generated/maxloc0_4_r16.c @@ -47,7 +47,6 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_r16 (gfc_array_i4 * const restrict, gfc_array_r16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_r4.c b/libgfortran/generated/maxloc0_4_r4.c index c168aee4d57e..76732d7f6bb9 100644 --- a/libgfortran/generated/maxloc0_4_r4.c +++ b/libgfortran/generated/maxloc0_4_r4.c @@ -47,7 +47,6 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_r4 (gfc_array_i4 * const restrict, gfc_array_r4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_r8.c b/libgfortran/generated/maxloc0_4_r8.c index 655a6527304f..13e371030b79 100644 --- a/libgfortran/generated/maxloc0_4_r8.c +++ b/libgfortran/generated/maxloc0_4_r8.c @@ -47,7 +47,6 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray, } } - extern void mmaxloc0_4_r8 (gfc_array_i4 * const restrict, gfc_array_r8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_4_s1.c b/libgfortran/generated/maxloc0_4_s1.c index b13a9b94146d..ba8e63401187 100644 --- a/libgfortran/generated/maxloc0_4_s1.c +++ b/libgfortran/generated/maxloc0_4_s1.c @@ -61,10 +61,6 @@ maxloc0_4_s1 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ maxloc0_4_s1 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_1 *maxval; - maxval = base; + maxval = NULL; while (base) { @@ -115,7 +111,8 @@ maxloc0_4_s1 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mmaxloc0_4_s1 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mmaxloc0_4_s1 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) + if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/maxloc0_4_s4.c b/libgfortran/generated/maxloc0_4_s4.c index 971e8680804a..90a54b6aed8a 100644 --- a/libgfortran/generated/maxloc0_4_s4.c +++ b/libgfortran/generated/maxloc0_4_s4.c @@ -61,10 +61,6 @@ maxloc0_4_s4 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ maxloc0_4_s4 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_4 *maxval; - maxval = base; + maxval = NULL; while (base) { @@ -115,7 +111,8 @@ maxloc0_4_s4 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mmaxloc0_4_s4 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mmaxloc0_4_s4 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) + if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/maxloc0_8_i1.c b/libgfortran/generated/maxloc0_8_i1.c index b86f0cb29467..c7852b5c8e78 100644 --- a/libgfortran/generated/maxloc0_8_i1.c +++ b/libgfortran/generated/maxloc0_8_i1.c @@ -47,7 +47,6 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_1_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_i1 (gfc_array_i8 * const restrict, gfc_array_i1 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_i16.c b/libgfortran/generated/maxloc0_8_i16.c index 710d26097b6e..88d50d975189 100644 --- a/libgfortran/generated/maxloc0_8_i16.c +++ b/libgfortran/generated/maxloc0_8_i16.c @@ -47,7 +47,6 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_i16 (gfc_array_i8 * const restrict, gfc_array_i16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_i2.c b/libgfortran/generated/maxloc0_8_i2.c index e85fb07ab4bb..b763e3b462e4 100644 --- a/libgfortran/generated/maxloc0_8_i2.c +++ b/libgfortran/generated/maxloc0_8_i2.c @@ -47,7 +47,6 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_2_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_i2 (gfc_array_i8 * const restrict, gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_i4.c b/libgfortran/generated/maxloc0_8_i4.c index bb6d51ee69aa..e338364f9511 100644 --- a/libgfortran/generated/maxloc0_8_i4.c +++ b/libgfortran/generated/maxloc0_8_i4.c @@ -47,7 +47,6 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_i4 (gfc_array_i8 * const restrict, gfc_array_i4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_i8.c b/libgfortran/generated/maxloc0_8_i8.c index d6c6e850ed49..11fd73de774f 100644 --- a/libgfortran/generated/maxloc0_8_i8.c +++ b/libgfortran/generated/maxloc0_8_i8.c @@ -47,7 +47,6 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_i8 (gfc_array_i8 * const restrict, gfc_array_i8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_r10.c b/libgfortran/generated/maxloc0_8_r10.c index 333e57095fdc..315c8d7e613d 100644 --- a/libgfortran/generated/maxloc0_8_r10.c +++ b/libgfortran/generated/maxloc0_8_r10.c @@ -47,7 +47,6 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_10_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_r10 (gfc_array_i8 * const restrict, gfc_array_r10 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_r16.c b/libgfortran/generated/maxloc0_8_r16.c index ebb3118864d2..6fcc69ec3942 100644 --- a/libgfortran/generated/maxloc0_8_r16.c +++ b/libgfortran/generated/maxloc0_8_r16.c @@ -47,7 +47,6 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_r16 (gfc_array_i8 * const restrict, gfc_array_r16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_r4.c b/libgfortran/generated/maxloc0_8_r4.c index afc46960059c..3ecd60ed7ad4 100644 --- a/libgfortran/generated/maxloc0_8_r4.c +++ b/libgfortran/generated/maxloc0_8_r4.c @@ -47,7 +47,6 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_r4 (gfc_array_i8 * const restrict, gfc_array_r4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_r8.c b/libgfortran/generated/maxloc0_8_r8.c index e6a2feffa97d..299be1a5c0d3 100644 --- a/libgfortran/generated/maxloc0_8_r8.c +++ b/libgfortran/generated/maxloc0_8_r8.c @@ -47,7 +47,6 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - } + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*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]; @@ -167,7 +176,6 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray, } } - extern void mmaxloc0_8_r8 (gfc_array_i8 * const restrict, gfc_array_r8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*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]; diff --git a/libgfortran/generated/maxloc0_8_s1.c b/libgfortran/generated/maxloc0_8_s1.c index 2e95fa35d1c5..405162338c7e 100644 --- a/libgfortran/generated/maxloc0_8_s1.c +++ b/libgfortran/generated/maxloc0_8_s1.c @@ -61,10 +61,6 @@ maxloc0_8_s1 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ maxloc0_8_s1 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_1 *maxval; - maxval = base; + maxval = NULL; while (base) { @@ -115,7 +111,8 @@ maxloc0_8_s1 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mmaxloc0_8_s1 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mmaxloc0_8_s1 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) + if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/maxloc0_8_s4.c b/libgfortran/generated/maxloc0_8_s4.c index 5cc1f11fb852..40ea75d257ff 100644 --- a/libgfortran/generated/maxloc0_8_s4.c +++ b/libgfortran/generated/maxloc0_8_s4.c @@ -61,10 +61,6 @@ maxloc0_8_s4 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ maxloc0_8_s4 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_4 *maxval; - maxval = base; + maxval = NULL; while (base) { @@ -115,7 +111,8 @@ maxloc0_8_s4 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mmaxloc0_8_s4 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mmaxloc0_8_s4 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) + if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c index ff2124d28032..cb04e9417eea 100644 --- a/libgfortran/generated/maxloc1_16_i1.c +++ b/libgfortran/generated/maxloc1_16_i1.c @@ -54,10 +54,6 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c index 2b0bd54ba8ac..871bf028341d 100644 --- a/libgfortran/generated/maxloc1_16_i16.c +++ b/libgfortran/generated/maxloc1_16_i16.c @@ -54,10 +54,6 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c index 26c3f142b9f6..3bba4bc92979 100644 --- a/libgfortran/generated/maxloc1_16_i2.c +++ b/libgfortran/generated/maxloc1_16_i2.c @@ -54,10 +54,6 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c index aedc22a1cfd9..043a9874d720 100644 --- a/libgfortran/generated/maxloc1_16_i4.c +++ b/libgfortran/generated/maxloc1_16_i4.c @@ -54,10 +54,6 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c index d08561d4aff1..fe9704fa68be 100644 --- a/libgfortran/generated/maxloc1_16_i8.c +++ b/libgfortran/generated/maxloc1_16_i8.c @@ -54,10 +54,6 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c index a5929ee47e48..25b0449d5860 100644 --- a/libgfortran/generated/maxloc1_16_r10.c +++ b/libgfortran/generated/maxloc1_16_r10.c @@ -54,10 +54,6 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c index 09da74031d15..4b0bddc4104d 100644 --- a/libgfortran/generated/maxloc1_16_r16.c +++ b/libgfortran/generated/maxloc1_16_r16.c @@ -54,10 +54,6 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c index 927830008e2e..9a021a05cfe5 100644 --- a/libgfortran/generated/maxloc1_16_r4.c +++ b/libgfortran/generated/maxloc1_16_r4.c @@ -54,10 +54,6 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c index 84c0c650641a..2cb8db38fb58 100644 --- a/libgfortran/generated/maxloc1_16_r8.c +++ b/libgfortran/generated/maxloc1_16_r8.c @@ -54,10 +54,6 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_16)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_16_s1.c b/libgfortran/generated/maxloc1_16_s1.c index 84b12f3e26ce..ae17ccd788ed 100644 --- a/libgfortran/generated/maxloc1_16_s1.c +++ b/libgfortran/generated/maxloc1_16_s1.c @@ -66,10 +66,6 @@ maxloc1_16_s1 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ maxloc1_16_s1 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_1 *maxval; - maxval = base; - result = 1; + maxval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ maxloc1_16_s1 (gfc_array_i16 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, maxval, string_len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_16)n + 1; @@ -244,9 +241,6 @@ mmaxloc1_16_s1 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mmaxloc1_16_s1 (gfc_array_i16 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_16)n + 1; diff --git a/libgfortran/generated/maxloc1_16_s4.c b/libgfortran/generated/maxloc1_16_s4.c index 70696f2ac3f5..6b436d64a698 100644 --- a/libgfortran/generated/maxloc1_16_s4.c +++ b/libgfortran/generated/maxloc1_16_s4.c @@ -66,10 +66,6 @@ maxloc1_16_s4 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ maxloc1_16_s4 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_4 *maxval; - maxval = base; - result = 1; + maxval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ maxloc1_16_s4 (gfc_array_i16 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, maxval, string_len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_16)n + 1; @@ -244,9 +241,6 @@ mmaxloc1_16_s4 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mmaxloc1_16_s4 (gfc_array_i16 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_16)n + 1; diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c index 7fc1f88c2d9d..43d541e01f2d 100644 --- a/libgfortran/generated/maxloc1_4_i1.c +++ b/libgfortran/generated/maxloc1_4_i1.c @@ -54,10 +54,6 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c index 14b5e5578b8b..7d006abbd142 100644 --- a/libgfortran/generated/maxloc1_4_i16.c +++ b/libgfortran/generated/maxloc1_4_i16.c @@ -54,10 +54,6 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c index 9d5a98ed3412..6f3751be0210 100644 --- a/libgfortran/generated/maxloc1_4_i2.c +++ b/libgfortran/generated/maxloc1_4_i2.c @@ -54,10 +54,6 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c index 23d702850f43..47c5d825fe85 100644 --- a/libgfortran/generated/maxloc1_4_i4.c +++ b/libgfortran/generated/maxloc1_4_i4.c @@ -54,10 +54,6 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c index 178a20aa2ff5..e8380aa72069 100644 --- a/libgfortran/generated/maxloc1_4_i8.c +++ b/libgfortran/generated/maxloc1_4_i8.c @@ -54,10 +54,6 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c index f35961338bfc..fe922ba3f2f4 100644 --- a/libgfortran/generated/maxloc1_4_r10.c +++ b/libgfortran/generated/maxloc1_4_r10.c @@ -54,10 +54,6 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c index a0f283e7cecf..eeab770df1c5 100644 --- a/libgfortran/generated/maxloc1_4_r16.c +++ b/libgfortran/generated/maxloc1_4_r16.c @@ -54,10 +54,6 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c index aeb4b8f10686..c0b80b0817df 100644 --- a/libgfortran/generated/maxloc1_4_r4.c +++ b/libgfortran/generated/maxloc1_4_r4.c @@ -54,10 +54,6 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c index 43852049c9cd..3560c3b74342 100644 --- a/libgfortran/generated/maxloc1_4_r8.c +++ b/libgfortran/generated/maxloc1_4_r8.c @@ -54,10 +54,6 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_4)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_4_s1.c b/libgfortran/generated/maxloc1_4_s1.c index b7b7d8cfe935..cdcd7fb26523 100644 --- a/libgfortran/generated/maxloc1_4_s1.c +++ b/libgfortran/generated/maxloc1_4_s1.c @@ -66,10 +66,6 @@ maxloc1_4_s1 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ maxloc1_4_s1 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_1 *maxval; - maxval = base; - result = 1; + maxval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ maxloc1_4_s1 (gfc_array_i4 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, maxval, string_len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_4)n + 1; @@ -244,9 +241,6 @@ mmaxloc1_4_s1 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mmaxloc1_4_s1 (gfc_array_i4 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_4)n + 1; diff --git a/libgfortran/generated/maxloc1_4_s4.c b/libgfortran/generated/maxloc1_4_s4.c index da7594993d19..f1e79cf90020 100644 --- a/libgfortran/generated/maxloc1_4_s4.c +++ b/libgfortran/generated/maxloc1_4_s4.c @@ -66,10 +66,6 @@ maxloc1_4_s4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ maxloc1_4_s4 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_4 *maxval; - maxval = base; - result = 1; + maxval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ maxloc1_4_s4 (gfc_array_i4 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, maxval, string_len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_4)n + 1; @@ -244,9 +241,6 @@ mmaxloc1_4_s4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mmaxloc1_4_s4 (gfc_array_i4 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_4)n + 1; diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c index fa5bc4aadfd3..1ff5cd3c90c8 100644 --- a/libgfortran/generated/maxloc1_8_i1.c +++ b/libgfortran/generated/maxloc1_8_i1.c @@ -54,10 +54,6 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c index 2cf75312ece9..9341c2744df4 100644 --- a/libgfortran/generated/maxloc1_8_i16.c +++ b/libgfortran/generated/maxloc1_8_i16.c @@ -54,10 +54,6 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c index e32eafe2f057..4d443ae595ea 100644 --- a/libgfortran/generated/maxloc1_8_i2.c +++ b/libgfortran/generated/maxloc1_8_i2.c @@ -54,10 +54,6 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c index e348550787e8..2058ab2ad694 100644 --- a/libgfortran/generated/maxloc1_8_i4.c +++ b/libgfortran/generated/maxloc1_8_i4.c @@ -54,10 +54,6 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c index 802b74d94612..9dc002f6c724 100644 --- a/libgfortran/generated/maxloc1_8_i8.c +++ b/libgfortran/generated/maxloc1_8_i8.c @@ -54,10 +54,6 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c index bc5f1b1af2c0..1a963d18c56c 100644 --- a/libgfortran/generated/maxloc1_8_r10.c +++ b/libgfortran/generated/maxloc1_8_r10.c @@ -54,10 +54,6 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c index 54d12030c113..e04c70e50659 100644 --- a/libgfortran/generated/maxloc1_8_r16.c +++ b/libgfortran/generated/maxloc1_8_r16.c @@ -54,10 +54,6 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c index 5895585c4036..b06820bce61c 100644 --- a/libgfortran/generated/maxloc1_8_r4.c +++ b/libgfortran/generated/maxloc1_8_r4.c @@ -54,10 +54,6 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c index 8c79dd46ab07..1963746d4224 100644 --- a/libgfortran/generated/maxloc1_8_r8.c +++ b/libgfortran/generated/maxloc1_8_r8.c @@ -54,10 +54,6 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -174,10 +174,12 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; @@ -246,9 +248,6 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +395,23 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (GFC_INTEGER_8)n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/maxloc1_8_s1.c b/libgfortran/generated/maxloc1_8_s1.c index aab24491ba9d..2b16e0652456 100644 --- a/libgfortran/generated/maxloc1_8_s1.c +++ b/libgfortran/generated/maxloc1_8_s1.c @@ -66,10 +66,6 @@ maxloc1_8_s1 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ maxloc1_8_s1 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_1 *maxval; - maxval = base; - result = 1; + maxval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ maxloc1_8_s1 (gfc_array_i8 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, maxval, string_len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_8)n + 1; @@ -244,9 +241,6 @@ mmaxloc1_8_s1 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mmaxloc1_8_s1 (gfc_array_i8 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_8)n + 1; diff --git a/libgfortran/generated/maxloc1_8_s4.c b/libgfortran/generated/maxloc1_8_s4.c index f02e2a545260..c4557e0e0019 100644 --- a/libgfortran/generated/maxloc1_8_s4.c +++ b/libgfortran/generated/maxloc1_8_s4.c @@ -66,10 +66,6 @@ maxloc1_8_s4 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ maxloc1_8_s4 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_4 *maxval; - maxval = base; - result = 1; + maxval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ maxloc1_8_s4 (gfc_array_i8 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, maxval, string_len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_8)n + 1; @@ -244,9 +241,6 @@ mmaxloc1_8_s4 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mmaxloc1_8_s4 (gfc_array_i8 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (GFC_INTEGER_8)n + 1; diff --git a/libgfortran/generated/maxloc2_16_s1.c b/libgfortran/generated/maxloc2_16_s1.c index bfba7074bccb..9efa7cb77784 100644 --- a/libgfortran/generated/maxloc2_16_s1.c +++ b/libgfortran/generated/maxloc2_16_s1.c @@ -53,7 +53,6 @@ maxloc2_16_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_char const GFC_INTEGER_1 *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -62,15 +61,16 @@ maxloc2_16_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_char ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -95,7 +95,6 @@ mmaxloc2_16_s1 (gfc_array_s1 * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -133,7 +132,8 @@ mmaxloc2_16_s1 (gfc_array_s1 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/maxloc2_16_s4.c b/libgfortran/generated/maxloc2_16_s4.c index cf1235e92c9b..65573f8da4cf 100644 --- a/libgfortran/generated/maxloc2_16_s4.c +++ b/libgfortran/generated/maxloc2_16_s4.c @@ -53,7 +53,6 @@ maxloc2_16_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, gfc_char const GFC_INTEGER_4 *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -62,15 +61,16 @@ maxloc2_16_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, gfc_char ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -95,7 +95,6 @@ mmaxloc2_16_s4 (gfc_array_s4 * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -133,7 +132,8 @@ mmaxloc2_16_s4 (gfc_array_s4 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/maxloc2_4_s1.c b/libgfortran/generated/maxloc2_4_s1.c index e88ecca6eb43..68e02f55134a 100644 --- a/libgfortran/generated/maxloc2_4_s1.c +++ b/libgfortran/generated/maxloc2_4_s1.c @@ -53,7 +53,6 @@ maxloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charl const GFC_INTEGER_1 *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -62,15 +61,16 @@ maxloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charl ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -95,7 +95,6 @@ mmaxloc2_4_s1 (gfc_array_s1 * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -133,7 +132,8 @@ mmaxloc2_4_s1 (gfc_array_s1 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/maxloc2_4_s4.c b/libgfortran/generated/maxloc2_4_s4.c index adeba9321ec2..aa5a47aed4c6 100644 --- a/libgfortran/generated/maxloc2_4_s4.c +++ b/libgfortran/generated/maxloc2_4_s4.c @@ -53,7 +53,6 @@ maxloc2_4_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, gfc_charl const GFC_INTEGER_4 *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -62,15 +61,16 @@ maxloc2_4_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, gfc_charl ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -95,7 +95,6 @@ mmaxloc2_4_s4 (gfc_array_s4 * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -133,7 +132,8 @@ mmaxloc2_4_s4 (gfc_array_s4 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/maxloc2_8_s1.c b/libgfortran/generated/maxloc2_8_s1.c index 1a32e13949aa..c9c316017b56 100644 --- a/libgfortran/generated/maxloc2_8_s1.c +++ b/libgfortran/generated/maxloc2_8_s1.c @@ -53,7 +53,6 @@ maxloc2_8_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charl const GFC_INTEGER_1 *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -62,15 +61,16 @@ maxloc2_8_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charl ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -95,7 +95,6 @@ mmaxloc2_8_s1 (gfc_array_s1 * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -133,7 +132,8 @@ mmaxloc2_8_s1 (gfc_array_s1 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/maxloc2_8_s4.c b/libgfortran/generated/maxloc2_8_s4.c index ae22a51c5274..f707b140c473 100644 --- a/libgfortran/generated/maxloc2_8_s4.c +++ b/libgfortran/generated/maxloc2_8_s4.c @@ -53,7 +53,6 @@ maxloc2_8_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, gfc_charl const GFC_INTEGER_4 *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -62,15 +61,16 @@ maxloc2_8_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, gfc_charl ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -95,7 +95,6 @@ mmaxloc2_8_s4 (gfc_array_s4 * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -133,7 +132,8 @@ mmaxloc2_8_s4 (gfc_array_s4 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c index 2c6b865d60a2..86c9fb901896 100644 --- a/libgfortran/generated/maxval_i1.c +++ b/libgfortran/generated/maxval_i1.c @@ -51,10 +51,6 @@ maxval_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_i1 (gfc_array_i1 * const restrict retarray, *dest = (-GFC_INTEGER_1_HUGE-1); else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c index 060463601a75..30a440e042a7 100644 --- a/libgfortran/generated/maxval_i16.c +++ b/libgfortran/generated/maxval_i16.c @@ -51,10 +51,6 @@ maxval_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_i16 (gfc_array_i16 * const restrict retarray, *dest = (-GFC_INTEGER_16_HUGE-1); else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c index bcd4343ae084..2a329060c39f 100644 --- a/libgfortran/generated/maxval_i2.c +++ b/libgfortran/generated/maxval_i2.c @@ -51,10 +51,6 @@ maxval_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_i2 (gfc_array_i2 * const restrict retarray, *dest = (-GFC_INTEGER_2_HUGE-1); else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c index bef1c291c354..2954e8ada4a2 100644 --- a/libgfortran/generated/maxval_i4.c +++ b/libgfortran/generated/maxval_i4.c @@ -51,10 +51,6 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, *dest = (-GFC_INTEGER_4_HUGE-1); else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c index 14deb70de470..fde234cfcbfb 100644 --- a/libgfortran/generated/maxval_i8.c +++ b/libgfortran/generated/maxval_i8.c @@ -51,10 +51,6 @@ maxval_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_i8 (gfc_array_i8 * const restrict retarray, *dest = (-GFC_INTEGER_8_HUGE-1); else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c index 85d6d83b24ab..9671fdfc98fe 100644 --- a/libgfortran/generated/maxval_r10.c +++ b/libgfortran/generated/maxval_r10.c @@ -51,10 +51,6 @@ maxval_r10 (gfc_array_r10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_r10 (gfc_array_r10 * const restrict retarray, *dest = -GFC_REAL_10_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c index 18ef36725a8d..14e6ce0d0911 100644 --- a/libgfortran/generated/maxval_r16.c +++ b/libgfortran/generated/maxval_r16.c @@ -51,10 +51,6 @@ maxval_r16 (gfc_array_r16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_r16 (gfc_array_r16 * const restrict retarray, *dest = -GFC_REAL_16_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c index 862fe633c0c6..9b5dba098186 100644 --- a/libgfortran/generated/maxval_r4.c +++ b/libgfortran/generated/maxval_r4.c @@ -51,10 +51,6 @@ maxval_r4 (gfc_array_r4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_r4 (gfc_array_r4 * const restrict retarray, *dest = -GFC_REAL_4_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c index 9315483d39e1..13f491114ab6 100644 --- a/libgfortran/generated/maxval_r8.c +++ b/libgfortran/generated/maxval_r8.c @@ -51,10 +51,6 @@ maxval_r8 (gfc_array_r8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ maxval_r8 (gfc_array_r8 * const restrict retarray, *dest = -GFC_REAL_8_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) if (*src >= result) @@ -236,9 +234,6 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minloc0_16_i1.c b/libgfortran/generated/minloc0_16_i1.c index 88720df56f7f..1e1cd6180a38 100644 --- a/libgfortran/generated/minloc0_16_i1.c +++ b/libgfortran/generated/minloc0_16_i1.c @@ -47,7 +47,6 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_1_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_i1 (gfc_array_i16 * const restrict, gfc_array_i1 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_i1 (gfc_array_i16 * const restrict, gfc_array_i1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_i1); diff --git a/libgfortran/generated/minloc0_16_i16.c b/libgfortran/generated/minloc0_16_i16.c index 4e2b6d0ca54b..b3663d6199d4 100644 --- a/libgfortran/generated/minloc0_16_i16.c +++ b/libgfortran/generated/minloc0_16_i16.c @@ -47,7 +47,6 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_i16 (gfc_array_i16 * const restrict, gfc_array_i16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_i16 (gfc_array_i16 * const restrict, gfc_array_i16 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_i16); diff --git a/libgfortran/generated/minloc0_16_i2.c b/libgfortran/generated/minloc0_16_i2.c index c9032c7a9703..3a173ea6f37f 100644 --- a/libgfortran/generated/minloc0_16_i2.c +++ b/libgfortran/generated/minloc0_16_i2.c @@ -47,7 +47,6 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_2_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_i2 (gfc_array_i16 * const restrict, gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_i2 (gfc_array_i16 * const restrict, gfc_array_i2 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_i2); diff --git a/libgfortran/generated/minloc0_16_i4.c b/libgfortran/generated/minloc0_16_i4.c index a27405a3ff60..4141fa1f22f1 100644 --- a/libgfortran/generated/minloc0_16_i4.c +++ b/libgfortran/generated/minloc0_16_i4.c @@ -47,7 +47,6 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_i4 (gfc_array_i16 * const restrict, gfc_array_i4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_i4 (gfc_array_i16 * const restrict, gfc_array_i4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_i4); diff --git a/libgfortran/generated/minloc0_16_i8.c b/libgfortran/generated/minloc0_16_i8.c index 6874f66ae56b..0d2f35044084 100644 --- a/libgfortran/generated/minloc0_16_i8.c +++ b/libgfortran/generated/minloc0_16_i8.c @@ -47,7 +47,6 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_i8 (gfc_array_i16 * const restrict, gfc_array_i8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_i8 (gfc_array_i16 * const restrict, gfc_array_i8 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_i8); diff --git a/libgfortran/generated/minloc0_16_r10.c b/libgfortran/generated/minloc0_16_r10.c index ad97459d4437..3fd940997986 100644 --- a/libgfortran/generated/minloc0_16_r10.c +++ b/libgfortran/generated/minloc0_16_r10.c @@ -47,7 +47,6 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_10_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_r10 (gfc_array_i16 * const restrict, gfc_array_r10 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_r10 (gfc_array_i16 * const restrict, gfc_array_r10 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_r10); diff --git a/libgfortran/generated/minloc0_16_r16.c b/libgfortran/generated/minloc0_16_r16.c index f8245ed30597..d04fdda43c96 100644 --- a/libgfortran/generated/minloc0_16_r16.c +++ b/libgfortran/generated/minloc0_16_r16.c @@ -47,7 +47,6 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_r16 (gfc_array_i16 * const restrict, gfc_array_r16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_r16 (gfc_array_i16 * const restrict, gfc_array_r16 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_r16); diff --git a/libgfortran/generated/minloc0_16_r4.c b/libgfortran/generated/minloc0_16_r4.c index ed41783dd5e6..8b029151031e 100644 --- a/libgfortran/generated/minloc0_16_r4.c +++ b/libgfortran/generated/minloc0_16_r4.c @@ -47,7 +47,6 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_r4 (gfc_array_i16 * const restrict, gfc_array_r4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_r4 (gfc_array_i16 * const restrict, gfc_array_r4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_r4); diff --git a/libgfortran/generated/minloc0_16_r8.c b/libgfortran/generated/minloc0_16_r8.c index 0799d4dfca8c..45ab7874177d 100644 --- a/libgfortran/generated/minloc0_16_r8.c +++ b/libgfortran/generated/minloc0_16_r8.c @@ -47,7 +47,6 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray, } } - extern void mminloc0_16_r8 (gfc_array_i16 * const restrict, gfc_array_r8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray, } } - extern void sminloc0_16_r8 (gfc_array_i16 * const restrict, gfc_array_r8 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_16_r8); diff --git a/libgfortran/generated/minloc0_16_s1.c b/libgfortran/generated/minloc0_16_s1.c index e566d749fb7c..95a38a6b5d93 100644 --- a/libgfortran/generated/minloc0_16_s1.c +++ b/libgfortran/generated/minloc0_16_s1.c @@ -61,10 +61,6 @@ minloc0_16_s1 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ minloc0_16_s1 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_1 *minval; - minval = base; + minval = NULL; while (base) { @@ -115,7 +111,8 @@ minloc0_16_s1 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, minval, len) < 0) + if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mminloc0_16_s1 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mminloc0_16_s1 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) + if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/minloc0_16_s4.c b/libgfortran/generated/minloc0_16_s4.c index 2a0b13c240f9..091afb7a6e9a 100644 --- a/libgfortran/generated/minloc0_16_s4.c +++ b/libgfortran/generated/minloc0_16_s4.c @@ -61,10 +61,6 @@ minloc0_16_s4 (gfc_array_i16 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ minloc0_16_s4 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_4 *minval; - minval = base; + minval = NULL; while (base) { @@ -115,7 +111,8 @@ minloc0_16_s4 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, minval, len) < 0) + if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mminloc0_16_s4 (gfc_array_i16 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mminloc0_16_s4 (gfc_array_i16 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) + if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/minloc0_4_i1.c b/libgfortran/generated/minloc0_4_i1.c index 577c9ddf6553..7120f000d89b 100644 --- a/libgfortran/generated/minloc0_4_i1.c +++ b/libgfortran/generated/minloc0_4_i1.c @@ -47,7 +47,6 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_1_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_i1 (gfc_array_i4 * const restrict, gfc_array_i1 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_i1 (gfc_array_i4 * const restrict, gfc_array_i1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_i1); diff --git a/libgfortran/generated/minloc0_4_i16.c b/libgfortran/generated/minloc0_4_i16.c index 48da69e39822..c9debdbd457e 100644 --- a/libgfortran/generated/minloc0_4_i16.c +++ b/libgfortran/generated/minloc0_4_i16.c @@ -47,7 +47,6 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_i16 (gfc_array_i4 * const restrict, gfc_array_i16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_i16 (gfc_array_i4 * const restrict, gfc_array_i16 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_i16); diff --git a/libgfortran/generated/minloc0_4_i2.c b/libgfortran/generated/minloc0_4_i2.c index 815ea85c2219..55fb58d40213 100644 --- a/libgfortran/generated/minloc0_4_i2.c +++ b/libgfortran/generated/minloc0_4_i2.c @@ -47,7 +47,6 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_2_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_i2 (gfc_array_i4 * const restrict, gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_i2 (gfc_array_i4 * const restrict, gfc_array_i2 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_i2); diff --git a/libgfortran/generated/minloc0_4_i4.c b/libgfortran/generated/minloc0_4_i4.c index 36b0a58f250a..351b4a1cc5c4 100644 --- a/libgfortran/generated/minloc0_4_i4.c +++ b/libgfortran/generated/minloc0_4_i4.c @@ -47,7 +47,6 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_i4 (gfc_array_i4 * const restrict, gfc_array_i4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_i4 (gfc_array_i4 * const restrict, gfc_array_i4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_i4); diff --git a/libgfortran/generated/minloc0_4_i8.c b/libgfortran/generated/minloc0_4_i8.c index a66280cd0742..a736c59a1056 100644 --- a/libgfortran/generated/minloc0_4_i8.c +++ b/libgfortran/generated/minloc0_4_i8.c @@ -47,7 +47,6 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_i8 (gfc_array_i4 * const restrict, gfc_array_i8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_i8 (gfc_array_i4 * const restrict, gfc_array_i8 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_i8); diff --git a/libgfortran/generated/minloc0_4_r10.c b/libgfortran/generated/minloc0_4_r10.c index 461ad0d477ba..f714417518b9 100644 --- a/libgfortran/generated/minloc0_4_r10.c +++ b/libgfortran/generated/minloc0_4_r10.c @@ -47,7 +47,6 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_10_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_r10 (gfc_array_i4 * const restrict, gfc_array_r10 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_r10 (gfc_array_i4 * const restrict, gfc_array_r10 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_r10); diff --git a/libgfortran/generated/minloc0_4_r16.c b/libgfortran/generated/minloc0_4_r16.c index 27e6d1d6a423..7d7ece40a957 100644 --- a/libgfortran/generated/minloc0_4_r16.c +++ b/libgfortran/generated/minloc0_4_r16.c @@ -47,7 +47,6 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_r16 (gfc_array_i4 * const restrict, gfc_array_r16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_r16 (gfc_array_i4 * const restrict, gfc_array_r16 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_r16); diff --git a/libgfortran/generated/minloc0_4_r4.c b/libgfortran/generated/minloc0_4_r4.c index 1b85544a292f..74757394d333 100644 --- a/libgfortran/generated/minloc0_4_r4.c +++ b/libgfortran/generated/minloc0_4_r4.c @@ -47,7 +47,6 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_r4 (gfc_array_i4 * const restrict, gfc_array_r4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_r4 (gfc_array_i4 * const restrict, gfc_array_r4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_r4); diff --git a/libgfortran/generated/minloc0_4_r8.c b/libgfortran/generated/minloc0_4_r8.c index 7c6d6bfbec2b..0ac6e6b3264c 100644 --- a/libgfortran/generated/minloc0_4_r8.c +++ b/libgfortran/generated/minloc0_4_r8.c @@ -47,7 +47,6 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray, } } - extern void mminloc0_4_r8 (gfc_array_i4 * const restrict, gfc_array_r8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray, } } - extern void sminloc0_4_r8 (gfc_array_i4 * const restrict, gfc_array_r8 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_4_r8); diff --git a/libgfortran/generated/minloc0_4_s1.c b/libgfortran/generated/minloc0_4_s1.c index 4d58df41b4f9..aeb0ae9f425f 100644 --- a/libgfortran/generated/minloc0_4_s1.c +++ b/libgfortran/generated/minloc0_4_s1.c @@ -61,10 +61,6 @@ minloc0_4_s1 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ minloc0_4_s1 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_1 *minval; - minval = base; + minval = NULL; while (base) { @@ -115,7 +111,8 @@ minloc0_4_s1 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, minval, len) < 0) + if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mminloc0_4_s1 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mminloc0_4_s1 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) + if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/minloc0_4_s4.c b/libgfortran/generated/minloc0_4_s4.c index bea56c06b3d3..f5b590658635 100644 --- a/libgfortran/generated/minloc0_4_s4.c +++ b/libgfortran/generated/minloc0_4_s4.c @@ -61,10 +61,6 @@ minloc0_4_s4 (gfc_array_i4 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ minloc0_4_s4 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_4 *minval; - minval = base; + minval = NULL; while (base) { @@ -115,7 +111,8 @@ minloc0_4_s4 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, minval, len) < 0) + if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mminloc0_4_s4 (gfc_array_i4 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mminloc0_4_s4 (gfc_array_i4 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) + if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/minloc0_8_i1.c b/libgfortran/generated/minloc0_8_i1.c index b0bccc89b991..46dfa7807fda 100644 --- a/libgfortran/generated/minloc0_8_i1.c +++ b/libgfortran/generated/minloc0_8_i1.c @@ -47,7 +47,6 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_1_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_i1 (gfc_array_i8 * const restrict, gfc_array_i1 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_i1 (gfc_array_i8 * const restrict, gfc_array_i1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_i1); diff --git a/libgfortran/generated/minloc0_8_i16.c b/libgfortran/generated/minloc0_8_i16.c index b4fb041b4a63..c3da87d0e76c 100644 --- a/libgfortran/generated/minloc0_8_i16.c +++ b/libgfortran/generated/minloc0_8_i16.c @@ -47,7 +47,6 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_i16 (gfc_array_i8 * const restrict, gfc_array_i16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_i16 (gfc_array_i8 * const restrict, gfc_array_i16 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_i16); diff --git a/libgfortran/generated/minloc0_8_i2.c b/libgfortran/generated/minloc0_8_i2.c index 13b39040f053..8455b7d406dc 100644 --- a/libgfortran/generated/minloc0_8_i2.c +++ b/libgfortran/generated/minloc0_8_i2.c @@ -47,7 +47,6 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_2_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_i2 (gfc_array_i8 * const restrict, gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_i2 (gfc_array_i8 * const restrict, gfc_array_i2 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_i2); diff --git a/libgfortran/generated/minloc0_8_i4.c b/libgfortran/generated/minloc0_8_i4.c index 5d4dc06353e3..2b0221674827 100644 --- a/libgfortran/generated/minloc0_8_i4.c +++ b/libgfortran/generated/minloc0_8_i4.c @@ -47,7 +47,6 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_i4 (gfc_array_i8 * const restrict, gfc_array_i4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_i4 (gfc_array_i8 * const restrict, gfc_array_i4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_i4); diff --git a/libgfortran/generated/minloc0_8_i8.c b/libgfortran/generated/minloc0_8_i8.c index d4cf9a4a9773..55aafa4c6340 100644 --- a/libgfortran/generated/minloc0_8_i8.c +++ b/libgfortran/generated/minloc0_8_i8.c @@ -47,7 +47,6 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_INTEGER_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_i8 (gfc_array_i8 * const restrict, gfc_array_i8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_i8 (gfc_array_i8 * const restrict, gfc_array_i8 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_i8); diff --git a/libgfortran/generated/minloc0_8_r10.c b/libgfortran/generated/minloc0_8_r10.c index c74fe0f6e8bd..14b8a62f5109 100644 --- a/libgfortran/generated/minloc0_8_r10.c +++ b/libgfortran/generated/minloc0_8_r10.c @@ -47,7 +47,6 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_10_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_r10 (gfc_array_i8 * const restrict, gfc_array_r10 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_r10 (gfc_array_i8 * const restrict, gfc_array_r10 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_r10); diff --git a/libgfortran/generated/minloc0_8_r16.c b/libgfortran/generated/minloc0_8_r16.c index 0ce3fd7b803d..e5c48fa77d62 100644 --- a/libgfortran/generated/minloc0_8_r16.c +++ b/libgfortran/generated/minloc0_8_r16.c @@ -47,7 +47,6 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_16_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_r16 (gfc_array_i8 * const restrict, gfc_array_r16 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_r16 (gfc_array_i8 * const restrict, gfc_array_r16 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_r16); diff --git a/libgfortran/generated/minloc0_8_r4.c b/libgfortran/generated/minloc0_8_r4.c index 66c5b74e40ad..caba6a7d49b0 100644 --- a/libgfortran/generated/minloc0_8_r4.c +++ b/libgfortran/generated/minloc0_8_r4.c @@ -47,7 +47,6 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_4_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_r4 (gfc_array_i8 * const restrict, gfc_array_r4 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_r4 (gfc_array_i8 * const restrict, gfc_array_r4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_r4); diff --git a/libgfortran/generated/minloc0_8_r8.c b/libgfortran/generated/minloc0_8_r8.c index bd6b217f7f99..876e9cbae29e 100644 --- a/libgfortran/generated/minloc0_8_r8.c +++ b/libgfortran/generated/minloc0_8_r8.c @@ -47,7 +47,6 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -101,13 +100,9 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ #if defined(GFC_REAL_8_QUIET_NAN) - } - while (0); if (unlikely (!fast)) { do @@ -126,15 +121,29 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -167,7 +176,6 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray, } } - extern void mminloc0_8_r8 (gfc_array_i8 * const restrict, gfc_array_r8 * const restrict, gfc_array_l1 * const restrict, GFC_LOGICAL_4); @@ -190,7 +198,6 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -261,12 +268,8 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray, #endif while (base) { - do - { /* Implementation start. */ - } - while (0); if (unlikely (!fast)) { do @@ -294,14 +297,28 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray, if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } /* Implementation end. */ /* Advance to the next element. */ base += sstride[0]; @@ -337,7 +354,6 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray, } } - extern void sminloc0_8_r8 (gfc_array_i8 * const restrict, gfc_array_r8 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); export_proto(sminloc0_8_r8); diff --git a/libgfortran/generated/minloc0_8_s1.c b/libgfortran/generated/minloc0_8_s1.c index dd9be96f3dc7..68b1800b4a9b 100644 --- a/libgfortran/generated/minloc0_8_s1.c +++ b/libgfortran/generated/minloc0_8_s1.c @@ -61,10 +61,6 @@ minloc0_8_s1 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ minloc0_8_s1 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_1 *minval; - minval = base; + minval = NULL; while (base) { @@ -115,7 +111,8 @@ minloc0_8_s1 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, minval, len) < 0) + if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mminloc0_8_s1 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mminloc0_8_s1 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) + if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/minloc0_8_s4.c b/libgfortran/generated/minloc0_8_s4.c index 46d29ec0b88c..715e074312a7 100644 --- a/libgfortran/generated/minloc0_8_s4.c +++ b/libgfortran/generated/minloc0_8_s4.c @@ -61,10 +61,6 @@ minloc0_8_s4 (gfc_array_i8 * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -107,7 +103,7 @@ minloc0_8_s4 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_4 *minval; - minval = base; + minval = NULL; while (base) { @@ -115,7 +111,8 @@ minloc0_8_s4 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (compare_fcn (base, minval, len) < 0) + if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -177,9 +174,6 @@ mminloc0_8_s4 (gfc_array_i8 * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -250,7 +244,9 @@ mminloc0_8_s4 (gfc_array_i8 * const restrict retarray, { /* Implementation start. */ - if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) + if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c index 20197c4ae0d2..132b2f1abae3 100644 --- a/libgfortran/generated/minloc1_16_i1.c +++ b/libgfortran/generated/minloc1_16_i1.c @@ -54,10 +54,6 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c index fc718a894c6d..83a8d5928c54 100644 --- a/libgfortran/generated/minloc1_16_i16.c +++ b/libgfortran/generated/minloc1_16_i16.c @@ -54,10 +54,6 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c index e9352b1d7304..a22e2c71770e 100644 --- a/libgfortran/generated/minloc1_16_i2.c +++ b/libgfortran/generated/minloc1_16_i2.c @@ -54,10 +54,6 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c index 9faa5b3947c3..f384ff10f0ab 100644 --- a/libgfortran/generated/minloc1_16_i4.c +++ b/libgfortran/generated/minloc1_16_i4.c @@ -54,10 +54,6 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c index 6ad4abedf04f..72b75b0329d9 100644 --- a/libgfortran/generated/minloc1_16_i8.c +++ b/libgfortran/generated/minloc1_16_i8.c @@ -54,10 +54,6 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c index 930d077cdf9f..53cf97dbd24b 100644 --- a/libgfortran/generated/minloc1_16_r10.c +++ b/libgfortran/generated/minloc1_16_r10.c @@ -54,10 +54,6 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c index 2003d8ff9ac3..93193cf92d6e 100644 --- a/libgfortran/generated/minloc1_16_r16.c +++ b/libgfortran/generated/minloc1_16_r16.c @@ -54,10 +54,6 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c index 7b9698342cbb..14369b697dce 100644 --- a/libgfortran/generated/minloc1_16_r4.c +++ b/libgfortran/generated/minloc1_16_r4.c @@ -54,10 +54,6 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c index d6839157cb14..8dfe8ec3effa 100644 --- a/libgfortran/generated/minloc1_16_r8.c +++ b/libgfortran/generated/minloc1_16_r8.c @@ -54,10 +54,6 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_16)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_16)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_16) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_16_s1.c b/libgfortran/generated/minloc1_16_s1.c index 898d124fdd35..5fea33ae1f71 100644 --- a/libgfortran/generated/minloc1_16_s1.c +++ b/libgfortran/generated/minloc1_16_s1.c @@ -66,10 +66,6 @@ minloc1_16_s1 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ minloc1_16_s1 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_1 *minval; - minval = base; - result = 1; + minval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ minloc1_16_s1 (gfc_array_i16 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, minval, string_len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_16)n + 1; @@ -244,9 +241,6 @@ mminloc1_16_s1 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mminloc1_16_s1 (gfc_array_i16 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_16)n + 1; diff --git a/libgfortran/generated/minloc1_16_s4.c b/libgfortran/generated/minloc1_16_s4.c index 82eb258e0090..46411b113bb3 100644 --- a/libgfortran/generated/minloc1_16_s4.c +++ b/libgfortran/generated/minloc1_16_s4.c @@ -66,10 +66,6 @@ minloc1_16_s4 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ minloc1_16_s4 (gfc_array_i16 * const restrict retarray, { const GFC_INTEGER_4 *minval; - minval = base; - result = 1; + minval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ minloc1_16_s4 (gfc_array_i16 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, minval, string_len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_16)n + 1; @@ -244,9 +241,6 @@ mminloc1_16_s4 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mminloc1_16_s4 (gfc_array_i16 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_16)n + 1; diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c index b36f2681fe4b..ce9b926f22d0 100644 --- a/libgfortran/generated/minloc1_4_i1.c +++ b/libgfortran/generated/minloc1_4_i1.c @@ -54,10 +54,6 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c index b4454e1aca74..871aa374a1a2 100644 --- a/libgfortran/generated/minloc1_4_i16.c +++ b/libgfortran/generated/minloc1_4_i16.c @@ -54,10 +54,6 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c index f8ab77ccded5..16f7e5ef7b7d 100644 --- a/libgfortran/generated/minloc1_4_i2.c +++ b/libgfortran/generated/minloc1_4_i2.c @@ -54,10 +54,6 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c index 6523d01fc9e0..08d919aabd09 100644 --- a/libgfortran/generated/minloc1_4_i4.c +++ b/libgfortran/generated/minloc1_4_i4.c @@ -54,10 +54,6 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c index ab1b6bae8b34..807f6fa016bf 100644 --- a/libgfortran/generated/minloc1_4_i8.c +++ b/libgfortran/generated/minloc1_4_i8.c @@ -54,10 +54,6 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c index a481ec459d3b..b2430c4ea6e5 100644 --- a/libgfortran/generated/minloc1_4_r10.c +++ b/libgfortran/generated/minloc1_4_r10.c @@ -54,10 +54,6 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c index f5fcb666c599..e81a0a77e90a 100644 --- a/libgfortran/generated/minloc1_4_r16.c +++ b/libgfortran/generated/minloc1_4_r16.c @@ -54,10 +54,6 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c index 212aa2541cb4..b82aeeaf7307 100644 --- a/libgfortran/generated/minloc1_4_r4.c +++ b/libgfortran/generated/minloc1_4_r4.c @@ -54,10 +54,6 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c index 1fa41f2e084f..3476a5e5adb6 100644 --- a/libgfortran/generated/minloc1_4_r8.c +++ b/libgfortran/generated/minloc1_4_r8.c @@ -54,10 +54,6 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_4)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_4)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_4) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_4_s1.c b/libgfortran/generated/minloc1_4_s1.c index 1b7e5514cc87..f0c583ffa52a 100644 --- a/libgfortran/generated/minloc1_4_s1.c +++ b/libgfortran/generated/minloc1_4_s1.c @@ -66,10 +66,6 @@ minloc1_4_s1 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ minloc1_4_s1 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_1 *minval; - minval = base; - result = 1; + minval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ minloc1_4_s1 (gfc_array_i4 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, minval, string_len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_4)n + 1; @@ -244,9 +241,6 @@ mminloc1_4_s1 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mminloc1_4_s1 (gfc_array_i4 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_4)n + 1; diff --git a/libgfortran/generated/minloc1_4_s4.c b/libgfortran/generated/minloc1_4_s4.c index b3c6010efdae..eaafec1018bd 100644 --- a/libgfortran/generated/minloc1_4_s4.c +++ b/libgfortran/generated/minloc1_4_s4.c @@ -66,10 +66,6 @@ minloc1_4_s4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ minloc1_4_s4 (gfc_array_i4 * const restrict retarray, { const GFC_INTEGER_4 *minval; - minval = base; - result = 1; + minval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ minloc1_4_s4 (gfc_array_i4 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, minval, string_len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_4)n + 1; @@ -244,9 +241,6 @@ mminloc1_4_s4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mminloc1_4_s4 (gfc_array_i4 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_4)n + 1; diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c index 66771b345231..f04fd8d72d82 100644 --- a/libgfortran/generated/minloc1_8_i1.c +++ b/libgfortran/generated/minloc1_8_i1.c @@ -54,10 +54,6 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c index 8c7bc1908e23..d42c5feea2ea 100644 --- a/libgfortran/generated/minloc1_8_i16.c +++ b/libgfortran/generated/minloc1_8_i16.c @@ -54,10 +54,6 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c index e31acb53b728..134617d49f37 100644 --- a/libgfortran/generated/minloc1_8_i2.c +++ b/libgfortran/generated/minloc1_8_i2.c @@ -54,10 +54,6 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c index 4402bdd8ffe7..20f0595ae1d1 100644 --- a/libgfortran/generated/minloc1_8_i4.c +++ b/libgfortran/generated/minloc1_8_i4.c @@ -54,10 +54,6 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c index 172cbb5d138a..653393c532eb 100644 --- a/libgfortran/generated/minloc1_8_i8.c +++ b/libgfortran/generated/minloc1_8_i8.c @@ -54,10 +54,6 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c index 557e87616b61..a51a290db1ff 100644 --- a/libgfortran/generated/minloc1_8_r10.c +++ b/libgfortran/generated/minloc1_8_r10.c @@ -54,10 +54,6 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c index 184dd1e098f3..e8e1b7452ad5 100644 --- a/libgfortran/generated/minloc1_8_r16.c +++ b/libgfortran/generated/minloc1_8_r16.c @@ -54,10 +54,6 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c index fd8102092581..f4a27e1c50d6 100644 --- a/libgfortran/generated/minloc1_8_r4.c +++ b/libgfortran/generated/minloc1_8_r4.c @@ -54,10 +54,6 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c index fc0ff7c90769..4cd0df1209f0 100644 --- a/libgfortran/generated/minloc1_8_r8.c +++ b/libgfortran/generated/minloc1_8_r8.c @@ -54,10 +54,6 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,10 +159,14 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -174,14 +174,26 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; @@ -246,9 +258,6 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -396,13 +405,23 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (GFC_INTEGER_8)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (GFC_INTEGER_8)n + 1; - } + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (GFC_INTEGER_8) n + 1; + } } *dest = result; } diff --git a/libgfortran/generated/minloc1_8_s1.c b/libgfortran/generated/minloc1_8_s1.c index b5b4fd506746..ee2547bc406c 100644 --- a/libgfortran/generated/minloc1_8_s1.c +++ b/libgfortran/generated/minloc1_8_s1.c @@ -66,10 +66,6 @@ minloc1_8_s1 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ minloc1_8_s1 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_1 *minval; - minval = base; - result = 1; + minval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ minloc1_8_s1 (gfc_array_i8 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, minval, string_len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_8)n + 1; @@ -244,9 +241,6 @@ mminloc1_8_s1 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mminloc1_8_s1 (gfc_array_i8 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_8)n + 1; diff --git a/libgfortran/generated/minloc1_8_s4.c b/libgfortran/generated/minloc1_8_s4.c index 4181630eca27..605c5de3aefb 100644 --- a/libgfortran/generated/minloc1_8_s4.c +++ b/libgfortran/generated/minloc1_8_s4.c @@ -66,10 +66,6 @@ minloc1_8_s4 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -165,8 +161,8 @@ minloc1_8_s4 (gfc_array_i8 * const restrict retarray, { const GFC_INTEGER_4 *minval; - minval = base; - result = 1; + minval = NULL; + result = 0; if (len <= 0) *dest = 0; else @@ -174,7 +170,8 @@ minloc1_8_s4 (gfc_array_i8 * const restrict retarray, for (n = 0; n < len; n++, src += delta) { - if (compare_fcn (src, minval, string_len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_8)n + 1; @@ -244,9 +241,6 @@ mminloc1_8_s4 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -377,7 +371,8 @@ mminloc1_8_s4 (gfc_array_i8 * const restrict retarray, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (GFC_INTEGER_8)n + 1; diff --git a/libgfortran/generated/minloc2_16_s1.c b/libgfortran/generated/minloc2_16_s1.c index 3685603ecc27..30fdd82d1780 100644 --- a/libgfortran/generated/minloc2_16_s1.c +++ b/libgfortran/generated/minloc2_16_s1.c @@ -51,10 +51,9 @@ minloc2_16_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, index_type sstride; index_type extent; const GFC_INTEGER_1 *src; - const GFC_INTEGER_1 *maxval; + const GFC_INTEGER_1 *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ minloc2_16_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ mminloc2_16_s1 (gfc_array_s1 * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,9 @@ mminloc2_16_s1 (gfc_array_s1 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/minloc2_16_s4.c b/libgfortran/generated/minloc2_16_s4.c index 256784fd8cef..4b0b873bd183 100644 --- a/libgfortran/generated/minloc2_16_s4.c +++ b/libgfortran/generated/minloc2_16_s4.c @@ -51,10 +51,9 @@ minloc2_16_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, index_type sstride; index_type extent; const GFC_INTEGER_4 *src; - const GFC_INTEGER_4 *maxval; + const GFC_INTEGER_4 *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ minloc2_16_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ mminloc2_16_s4 (gfc_array_s4 * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,9 @@ mminloc2_16_s4 (gfc_array_s4 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/minloc2_4_s1.c b/libgfortran/generated/minloc2_4_s1.c index 1ba34d1712e2..f4c8bb31e61a 100644 --- a/libgfortran/generated/minloc2_4_s1.c +++ b/libgfortran/generated/minloc2_4_s1.c @@ -51,10 +51,9 @@ minloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, index_type sstride; index_type extent; const GFC_INTEGER_1 *src; - const GFC_INTEGER_1 *maxval; + const GFC_INTEGER_1 *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ minloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ mminloc2_4_s1 (gfc_array_s1 * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,9 @@ mminloc2_4_s1 (gfc_array_s1 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/minloc2_4_s4.c b/libgfortran/generated/minloc2_4_s4.c index cd5053d71ff4..8e973f0b1d00 100644 --- a/libgfortran/generated/minloc2_4_s4.c +++ b/libgfortran/generated/minloc2_4_s4.c @@ -51,10 +51,9 @@ minloc2_4_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, index_type sstride; index_type extent; const GFC_INTEGER_4 *src; - const GFC_INTEGER_4 *maxval; + const GFC_INTEGER_4 *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ minloc2_4_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ mminloc2_4_s4 (gfc_array_s4 * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,9 @@ mminloc2_4_s4 (gfc_array_s4 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/minloc2_8_s1.c b/libgfortran/generated/minloc2_8_s1.c index 5c73d89f8e75..44b65bf24af8 100644 --- a/libgfortran/generated/minloc2_8_s1.c +++ b/libgfortran/generated/minloc2_8_s1.c @@ -51,10 +51,9 @@ minloc2_8_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, index_type sstride; index_type extent; const GFC_INTEGER_1 *src; - const GFC_INTEGER_1 *maxval; + const GFC_INTEGER_1 *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ minloc2_8_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ mminloc2_8_s1 (gfc_array_s1 * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,9 @@ mminloc2_8_s1 (gfc_array_s1 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/minloc2_8_s4.c b/libgfortran/generated/minloc2_8_s4.c index 9b40c9140cb5..f6f9341bcbb5 100644 --- a/libgfortran/generated/minloc2_8_s4.c +++ b/libgfortran/generated/minloc2_8_s4.c @@ -51,10 +51,9 @@ minloc2_8_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, index_type sstride; index_type extent; const GFC_INTEGER_4 *src; - const GFC_INTEGER_4 *maxval; + const GFC_INTEGER_4 *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ minloc2_8_s4 (gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ mminloc2_8_s4 (gfc_array_s4 * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,9 @@ mminloc2_8_s4 (gfc_array_s4 * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src; diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c index 7bb6f81b0e72..d78c04603d03 100644 --- a/libgfortran/generated/minval_i1.c +++ b/libgfortran/generated/minval_i1.c @@ -51,10 +51,6 @@ minval_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_i1 (gfc_array_i1 * const restrict retarray, *dest = GFC_INTEGER_1_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_1_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c index b2608bc102df..1dc3cf57281c 100644 --- a/libgfortran/generated/minval_i16.c +++ b/libgfortran/generated/minval_i16.c @@ -51,10 +51,6 @@ minval_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_i16 (gfc_array_i16 * const restrict retarray, *dest = GFC_INTEGER_16_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_16_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c index 6539ae10b601..ca8f11028e12 100644 --- a/libgfortran/generated/minval_i2.c +++ b/libgfortran/generated/minval_i2.c @@ -51,10 +51,6 @@ minval_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_i2 (gfc_array_i2 * const restrict retarray, *dest = GFC_INTEGER_2_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_2_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c index e2c16d2e8dab..59fc3b6a5be2 100644 --- a/libgfortran/generated/minval_i4.c +++ b/libgfortran/generated/minval_i4.c @@ -51,10 +51,6 @@ minval_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_i4 (gfc_array_i4 * const restrict retarray, *dest = GFC_INTEGER_4_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_4_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c index 9caafd97e04c..7f6e5de483d6 100644 --- a/libgfortran/generated/minval_i8.c +++ b/libgfortran/generated/minval_i8.c @@ -51,10 +51,6 @@ minval_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_i8 (gfc_array_i8 * const restrict retarray, *dest = GFC_INTEGER_8_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_INTEGER_8_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c index 308f64b25b30..5a91dd23f4e1 100644 --- a/libgfortran/generated/minval_r10.c +++ b/libgfortran/generated/minval_r10.c @@ -51,10 +51,6 @@ minval_r10 (gfc_array_r10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_r10 (gfc_array_r10 * const restrict retarray, *dest = GFC_REAL_10_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_10_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_r10 (gfc_array_r10 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c index 948aee092cf4..3580e3098353 100644 --- a/libgfortran/generated/minval_r16.c +++ b/libgfortran/generated/minval_r16.c @@ -51,10 +51,6 @@ minval_r16 (gfc_array_r16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_r16 (gfc_array_r16 * const restrict retarray, *dest = GFC_REAL_16_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_16_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_r16 (gfc_array_r16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c index b52a3e80f4dc..d5c191e1b8cf 100644 --- a/libgfortran/generated/minval_r4.c +++ b/libgfortran/generated/minval_r4.c @@ -51,10 +51,6 @@ minval_r4 (gfc_array_r4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_r4 (gfc_array_r4 * const restrict retarray, *dest = GFC_REAL_4_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_4_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_r4 (gfc_array_r4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c index 34caf05fc0c6..b53093c53ec7 100644 --- a/libgfortran/generated/minval_r8.c +++ b/libgfortran/generated/minval_r8.c @@ -51,10 +51,6 @@ minval_r8 (gfc_array_r8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -158,8 +154,10 @@ minval_r8 (gfc_array_r8 * const restrict retarray, *dest = GFC_REAL_8_HUGE; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif #if defined (GFC_REAL_8_QUIET_NAN) if (*src <= result) @@ -236,9 +234,6 @@ mminval_r8 (gfc_array_r8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/norm2_r10.c b/libgfortran/generated/norm2_r10.c index b6e5a4a51d30..7e24f36acb9e 100644 --- a/libgfortran/generated/norm2_r10.c +++ b/libgfortran/generated/norm2_r10.c @@ -54,10 +54,6 @@ norm2_r10 (gfc_array_r10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -159,8 +155,10 @@ norm2_r10 (gfc_array_r10 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif if (*src != 0) { diff --git a/libgfortran/generated/norm2_r16.c b/libgfortran/generated/norm2_r16.c index 32237dbd6d8c..e796d642d97d 100644 --- a/libgfortran/generated/norm2_r16.c +++ b/libgfortran/generated/norm2_r16.c @@ -58,10 +58,6 @@ norm2_r16 (gfc_array_r16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -163,8 +159,10 @@ norm2_r16 (gfc_array_r16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif if (*src != 0) { diff --git a/libgfortran/generated/norm2_r4.c b/libgfortran/generated/norm2_r4.c index 504d31306e9b..313bda300fab 100644 --- a/libgfortran/generated/norm2_r4.c +++ b/libgfortran/generated/norm2_r4.c @@ -54,10 +54,6 @@ norm2_r4 (gfc_array_r4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -159,8 +155,10 @@ norm2_r4 (gfc_array_r4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif if (*src != 0) { diff --git a/libgfortran/generated/norm2_r8.c b/libgfortran/generated/norm2_r8.c index 60e707f92068..140e93a52707 100644 --- a/libgfortran/generated/norm2_r8.c +++ b/libgfortran/generated/norm2_r8.c @@ -54,10 +54,6 @@ norm2_r8 (gfc_array_r8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -159,8 +155,10 @@ norm2_r8 (gfc_array_r8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif if (*src != 0) { diff --git a/libgfortran/generated/parity_l1.c b/libgfortran/generated/parity_l1.c index 292079942503..7f62a936181f 100644 --- a/libgfortran/generated/parity_l1.c +++ b/libgfortran/generated/parity_l1.c @@ -51,10 +51,6 @@ parity_l1 (gfc_array_l1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ parity_l1 (gfc_array_l1 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result = result != *src; } diff --git a/libgfortran/generated/parity_l16.c b/libgfortran/generated/parity_l16.c index c1ac0b26f051..5b2cb386d31d 100644 --- a/libgfortran/generated/parity_l16.c +++ b/libgfortran/generated/parity_l16.c @@ -51,10 +51,6 @@ parity_l16 (gfc_array_l16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ parity_l16 (gfc_array_l16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result = result != *src; } diff --git a/libgfortran/generated/parity_l2.c b/libgfortran/generated/parity_l2.c index c588e721a6ea..daf56b14aa1e 100644 --- a/libgfortran/generated/parity_l2.c +++ b/libgfortran/generated/parity_l2.c @@ -51,10 +51,6 @@ parity_l2 (gfc_array_l2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ parity_l2 (gfc_array_l2 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result = result != *src; } diff --git a/libgfortran/generated/parity_l4.c b/libgfortran/generated/parity_l4.c index 0acb039c1af8..3ddb70e622f2 100644 --- a/libgfortran/generated/parity_l4.c +++ b/libgfortran/generated/parity_l4.c @@ -51,10 +51,6 @@ parity_l4 (gfc_array_l4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ parity_l4 (gfc_array_l4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result = result != *src; } diff --git a/libgfortran/generated/parity_l8.c b/libgfortran/generated/parity_l8.c index 84623dffe1b1..ac1ae43c8ae7 100644 --- a/libgfortran/generated/parity_l8.c +++ b/libgfortran/generated/parity_l8.c @@ -51,10 +51,6 @@ parity_l8 (gfc_array_l8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ parity_l8 (gfc_array_l8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result = result != *src; } diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c index 38e8251861e4..bd41da8beed2 100644 --- a/libgfortran/generated/product_c10.c +++ b/libgfortran/generated/product_c10.c @@ -51,10 +51,6 @@ product_c10 (gfc_array_c10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_c10 (gfc_array_c10 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c index d1c04ec9793e..47f6dc016f20 100644 --- a/libgfortran/generated/product_c16.c +++ b/libgfortran/generated/product_c16.c @@ -51,10 +51,6 @@ product_c16 (gfc_array_c16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_c16 (gfc_array_c16 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c index d19cfaf6d895..d3d705b36b9e 100644 --- a/libgfortran/generated/product_c4.c +++ b/libgfortran/generated/product_c4.c @@ -51,10 +51,6 @@ product_c4 (gfc_array_c4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_c4 (gfc_array_c4 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c index ed1e12afba75..2ff0e8ca9e9d 100644 --- a/libgfortran/generated/product_c8.c +++ b/libgfortran/generated/product_c8.c @@ -51,10 +51,6 @@ product_c8 (gfc_array_c8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_c8 (gfc_array_c8 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c index 2e86e99e569d..73cbbeb13064 100644 --- a/libgfortran/generated/product_i1.c +++ b/libgfortran/generated/product_i1.c @@ -51,10 +51,6 @@ product_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_i1 (gfc_array_i1 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c index f23890ef740d..cefa13f20278 100644 --- a/libgfortran/generated/product_i16.c +++ b/libgfortran/generated/product_i16.c @@ -51,10 +51,6 @@ product_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_i16 (gfc_array_i16 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c index 762e5486ac6b..b135023b2615 100644 --- a/libgfortran/generated/product_i2.c +++ b/libgfortran/generated/product_i2.c @@ -51,10 +51,6 @@ product_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_i2 (gfc_array_i2 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c index ecf047029d5c..78a513bfbc80 100644 --- a/libgfortran/generated/product_i4.c +++ b/libgfortran/generated/product_i4.c @@ -51,10 +51,6 @@ product_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_i4 (gfc_array_i4 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c index a9530ec69077..044c50663615 100644 --- a/libgfortran/generated/product_i8.c +++ b/libgfortran/generated/product_i8.c @@ -51,10 +51,6 @@ product_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_i8 (gfc_array_i8 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c index 613ed18e9e40..067890ebfa76 100644 --- a/libgfortran/generated/product_r10.c +++ b/libgfortran/generated/product_r10.c @@ -51,10 +51,6 @@ product_r10 (gfc_array_r10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_r10 (gfc_array_r10 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c index 9befd51edc4b..2641379f02f7 100644 --- a/libgfortran/generated/product_r16.c +++ b/libgfortran/generated/product_r16.c @@ -51,10 +51,6 @@ product_r16 (gfc_array_r16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_r16 (gfc_array_r16 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c index 5e356ee8bfca..6f104b2ebbaa 100644 --- a/libgfortran/generated/product_r4.c +++ b/libgfortran/generated/product_r4.c @@ -51,10 +51,6 @@ product_r4 (gfc_array_r4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_r4 (gfc_array_r4 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c index 4e98cfa113ba..d70f88c41e9c 100644 --- a/libgfortran/generated/product_r8.c +++ b/libgfortran/generated/product_r8.c @@ -51,10 +51,6 @@ product_r8 (gfc_array_r8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ product_r8 (gfc_array_r8 * const restrict retarray, *dest = 1; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result *= *src; } @@ -222,9 +220,6 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c index 6923594e01fc..31d804973766 100644 --- a/libgfortran/generated/sum_c10.c +++ b/libgfortran/generated/sum_c10.c @@ -51,10 +51,6 @@ sum_c10 (gfc_array_c10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_c10 (gfc_array_c10 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_c10 (gfc_array_c10 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c index 4ed50d04dd81..f9d5c1ec3fe0 100644 --- a/libgfortran/generated/sum_c16.c +++ b/libgfortran/generated/sum_c16.c @@ -51,10 +51,6 @@ sum_c16 (gfc_array_c16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_c16 (gfc_array_c16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_c16 (gfc_array_c16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c index 9d5516a3b4a8..66872ddbc04b 100644 --- a/libgfortran/generated/sum_c4.c +++ b/libgfortran/generated/sum_c4.c @@ -51,10 +51,6 @@ sum_c4 (gfc_array_c4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_c4 (gfc_array_c4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_c4 (gfc_array_c4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c index 84684cbcd2e2..9d0e57fdf27b 100644 --- a/libgfortran/generated/sum_c8.c +++ b/libgfortran/generated/sum_c8.c @@ -51,10 +51,6 @@ sum_c8 (gfc_array_c8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_c8 (gfc_array_c8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_c8 (gfc_array_c8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c index f4407028de57..7fe696bc1876 100644 --- a/libgfortran/generated/sum_i1.c +++ b/libgfortran/generated/sum_i1.c @@ -51,10 +51,6 @@ sum_i1 (gfc_array_i1 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_i1 (gfc_array_i1 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_i1 (gfc_array_i1 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c index 570f8f2c4410..f1840d996bce 100644 --- a/libgfortran/generated/sum_i16.c +++ b/libgfortran/generated/sum_i16.c @@ -51,10 +51,6 @@ sum_i16 (gfc_array_i16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_i16 (gfc_array_i16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_i16 (gfc_array_i16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c index ea70d5088867..f8e453b68fee 100644 --- a/libgfortran/generated/sum_i2.c +++ b/libgfortran/generated/sum_i2.c @@ -51,10 +51,6 @@ sum_i2 (gfc_array_i2 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_i2 (gfc_array_i2 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_i2 (gfc_array_i2 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c index 4915ec9feb44..e8dae17c81b6 100644 --- a/libgfortran/generated/sum_i4.c +++ b/libgfortran/generated/sum_i4.c @@ -51,10 +51,6 @@ sum_i4 (gfc_array_i4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_i4 (gfc_array_i4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_i4 (gfc_array_i4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c index 53f6ec24fd48..0abbaf826228 100644 --- a/libgfortran/generated/sum_i8.c +++ b/libgfortran/generated/sum_i8.c @@ -51,10 +51,6 @@ sum_i8 (gfc_array_i8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_i8 (gfc_array_i8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_i8 (gfc_array_i8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c index 9552ed84cc88..012909bcaba5 100644 --- a/libgfortran/generated/sum_r10.c +++ b/libgfortran/generated/sum_r10.c @@ -51,10 +51,6 @@ sum_r10 (gfc_array_r10 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_r10 (gfc_array_r10 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_r10 (gfc_array_r10 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c index 6c8320691bfe..23420b887373 100644 --- a/libgfortran/generated/sum_r16.c +++ b/libgfortran/generated/sum_r16.c @@ -51,10 +51,6 @@ sum_r16 (gfc_array_r16 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_r16 (gfc_array_r16 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_r16 (gfc_array_r16 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c index 1595336bf309..09d8f05bf748 100644 --- a/libgfortran/generated/sum_r4.c +++ b/libgfortran/generated/sum_r4.c @@ -51,10 +51,6 @@ sum_r4 (gfc_array_r4 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_r4 (gfc_array_r4 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_r4 (gfc_array_r4 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c index 7c8a186ce761..0f45648b9a83 100644 --- a/libgfortran/generated/sum_r8.c +++ b/libgfortran/generated/sum_r8.c @@ -51,10 +51,6 @@ sum_r8 (gfc_array_r8 * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -154,8 +150,10 @@ sum_r8 (gfc_array_r8 * const restrict retarray, *dest = 0; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif result += *src; } @@ -222,9 +220,6 @@ msum_r8 (gfc_array_r8 * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/m4/iforeach-s.m4 b/libgfortran/m4/iforeach-s.m4 index 9711925ed994..494d0626aac1 100644 --- a/libgfortran/m4/iforeach-s.m4 +++ b/libgfortran/m4/iforeach-s.m4 @@ -30,10 +30,6 @@ name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, index_type rank; index_type n; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif - rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -139,9 +135,6 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, index_type n; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); diff --git a/libgfortran/m4/iforeach.m4 b/libgfortran/m4/iforeach.m4 index e6365ccc3ef4..db063bf655e1 100644 --- a/libgfortran/m4/iforeach.m4 +++ b/libgfortran/m4/iforeach.m4 @@ -21,7 +21,6 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, index_type rank; index_type n; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); @@ -66,8 +65,6 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, define(START_FOREACH_BLOCK, ` while (base) { - do - { /* Implementation start. */ ')dnl define(FINISH_FOREACH_FUNCTION, @@ -126,7 +123,6 @@ void index_type n; int mask_kind; - assert(back == 0); rank = GFC_DESCRIPTOR_RANK (array); if (rank <= 0) runtime_error ("Rank of array needs to be > 0"); diff --git a/libgfortran/m4/ifunction-s.m4 b/libgfortran/m4/ifunction-s.m4 index 9b4d96ab6224..a5767f58885f 100644 --- a/libgfortran/m4/ifunction-s.m4 +++ b/libgfortran/m4/ifunction-s.m4 @@ -54,10 +54,6 @@ void index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -226,9 +222,6 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4 index 8df072da033f..27bad4ece92d 100644 --- a/libgfortran/m4/ifunction.m4 +++ b/libgfortran/m4/ifunction.m4 @@ -41,10 +41,6 @@ name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, index_type dim; int continue_loop; -#ifdef HAVE_BACK_ARG - assert(back == 0); -#endif - /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; @@ -144,8 +140,10 @@ define(START_ARRAY_BLOCK, *dest = '$1`; else { +#if ! defined HAVE_BACK_ARG for (n = 0; n < len; n++, src += delta) { +#endif ')dnl define(FINISH_ARRAY_FUNCTION, ` } @@ -212,9 +210,6 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, index_type mdelta; int mask_kind; -#ifdef HAVE_BACK_ARG - assert (back == 0); -#endif dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; diff --git a/libgfortran/m4/maxloc0.m4 b/libgfortran/m4/maxloc0.m4 index 98d898f86a7e..ad19885ff908 100644 --- a/libgfortran/m4/maxloc0.m4 +++ b/libgfortran/m4/maxloc0.m4 @@ -43,8 +43,6 @@ FOREACH_FUNCTION( maxval = atype_min; #endif', `#if defined('atype_nan`) - } - while (0); if (unlikely (!fast)) { do @@ -63,16 +61,29 @@ FOREACH_FUNCTION( if (likely (fast)) continue; } - else do - { + else #endif - if (*base > maxval) - { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - }') - + if (back) + do + { + if (unlikely (*base >= maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base > maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + }') MASKED_FOREACH_FUNCTION( ` atype_name maxval; int fast = 0; @@ -82,9 +93,7 @@ MASKED_FOREACH_FUNCTION( #else maxval = atype_min; #endif', -` } - while (0); - if (unlikely (!fast)) +` if (unlikely (!fast)) { do { @@ -111,14 +120,28 @@ MASKED_FOREACH_FUNCTION( if (likely (fast)) continue; } - else do - { - if (*mbase && *base > maxval) + else + if (back) + do { - maxval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - }') + if (*mbase && *base >= maxval) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (*mbase && unlikely (*base > maxval)) + { + maxval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + }') SCALAR_FOREACH_FUNCTION(`0') #endif diff --git a/libgfortran/m4/maxloc0s.m4 b/libgfortran/m4/maxloc0s.m4 index 3c30a666feb3..b20233534f8f 100644 --- a/libgfortran/m4/maxloc0s.m4 +++ b/libgfortran/m4/maxloc0s.m4 @@ -38,9 +38,10 @@ include(iforeach-s.m4)dnl FOREACH_FUNCTION( ` const atype_name *maxval; - maxval = base;' + maxval = NULL;' , -` if (compare_fcn (base, maxval, len) > 0) +` if (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0 : + compare_fcn (base, maxval, len) > 0)) { maxval = base; for (n = 0; n < rank; n++) @@ -52,7 +53,9 @@ MASKED_FOREACH_FUNCTION( maxval = NULL;' , -` if (*mbase && (maxval == NULL || compare_fcn (base, maxval, len) > 0)) +` if (*mbase && + (maxval == NULL || (back ? compare_fcn (base, maxval, len) >= 0: + compare_fcn (base, maxval, len) > 0))) { maxval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/m4/maxloc1.m4 b/libgfortran/m4/maxloc1.m4 index 324a699c0bb9..811f7fdb80d9 100644 --- a/libgfortran/m4/maxloc1.m4 +++ b/libgfortran/m4/maxloc1.m4 @@ -42,6 +42,8 @@ ARRAY_FUNCTION(0, #endif result = 1;', `#if defined ('atype_nan`) + for (n = 0; n < len; n++, src += delta) + { if (*src >= maxval) { maxval = *src; @@ -49,10 +51,12 @@ ARRAY_FUNCTION(0, break; } } +#else + n = 0; +#endif for (; n < len; n++, src += delta) { -#endif - if (*src > maxval) + if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (rtype_name)n + 1; @@ -88,13 +92,23 @@ MASKED_ARRAY_FUNCTION(0, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src > maxval) - { - maxval = *src; - result = (rtype_name)n + 1; - }') + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src >= maxval)) + { + maxval = *src; + result = (rtype_name)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src > maxval)) + { + maxval = *src; + result = (rtype_name)n + 1; + }') SCALAR_ARRAY_FUNCTION(0) diff --git a/libgfortran/m4/maxloc1s.m4 b/libgfortran/m4/maxloc1s.m4 index 23da4abf0689..8b9333983705 100644 --- a/libgfortran/m4/maxloc1s.m4 +++ b/libgfortran/m4/maxloc1s.m4 @@ -34,9 +34,10 @@ include(ifunction-s.m4)dnl ARRAY_FUNCTION(0, ` const atype_name *maxval; - maxval = base; - result = 1;', -` if (compare_fcn (src, maxval, string_len) > 0) + maxval = NULL; + result = 0;', +` if (maxval == NULL || (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (rtype_name)n + 1; @@ -55,7 +56,8 @@ MASKED_ARRAY_FUNCTION(0, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, maxval, string_len) > 0) + if (*msrc && (back ? compare_fcn (src, maxval, string_len) >= 0 : + compare_fcn (src, maxval, string_len) > 0)) { maxval = src; result = (rtype_name)n + 1; diff --git a/libgfortran/m4/maxloc2s.m4 b/libgfortran/m4/maxloc2s.m4 index 5138f696ec37..b30e257bfc34 100644 --- a/libgfortran/m4/maxloc2s.m4 +++ b/libgfortran/m4/maxloc2s.m4 @@ -54,7 +54,6 @@ export_proto('name`'rtype_qual`_'atype_code`); const 'atype_name` *maxval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -63,15 +62,16 @@ export_proto('name`'rtype_qual`_'atype_code`); ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + maxval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) > 0) + if (maxval == NULL || (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; } + src += sstride; } return ret; } @@ -96,7 +96,6 @@ m'name`'rtype_qual`_'atype_code` ('atype` * const restrict array, int mask_kind; index_type mstride; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -134,7 +133,8 @@ m'name`'rtype_qual`_'atype_code` ('atype` * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) > 0) + if (*mbase && (back ? compare_fcn (src, maxval, len) >= 0 : + compare_fcn (src, maxval, len) > 0)) { ret = i; maxval = src; diff --git a/libgfortran/m4/minloc0.m4 b/libgfortran/m4/minloc0.m4 index 78c60d979eea..44174cf03fda 100644 --- a/libgfortran/m4/minloc0.m4 +++ b/libgfortran/m4/minloc0.m4 @@ -43,8 +43,6 @@ FOREACH_FUNCTION( minval = atype_max; #endif', `#if defined('atype_nan`) - } - while (0); if (unlikely (!fast)) { do @@ -63,16 +61,29 @@ FOREACH_FUNCTION( if (likely (fast)) continue; } - else do - { + else #endif - if (*base < minval) + if (back) + do + { + if (unlikely (*base <= minval)) { minval = *base; for (n = 0; n < rank; n++) dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*base < minval)) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; }') - MASKED_FOREACH_FUNCTION( ` atype_name minval; int fast = 0; @@ -82,9 +93,7 @@ MASKED_FOREACH_FUNCTION( #else minval = atype_max; #endif', -` } - while (0); - if (unlikely (!fast)) +` if (unlikely (!fast)) { do { @@ -111,14 +120,27 @@ MASKED_FOREACH_FUNCTION( if (likely (fast)) continue; } - else do - { - if (*mbase && *base < minval) + else + if (back) + do { - minval = *base; - for (n = 0; n < rank; n++) - dest[n * dstride] = count[n] + 1; - }') - + if (unlikely (*mbase && (*base <= minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + } + base += sstride[0]; + } + while (++count[0] != extent[0]); + else + do + { + if (unlikely (*mbase && (*base < minval))) + { + minval = *base; + for (n = 0; n < rank; n++) + dest[n * dstride] = count[n] + 1; + }') SCALAR_FOREACH_FUNCTION(`0') #endif diff --git a/libgfortran/m4/minloc0s.m4 b/libgfortran/m4/minloc0s.m4 index c4b9f461ac88..65d11ef62a1e 100644 --- a/libgfortran/m4/minloc0s.m4 +++ b/libgfortran/m4/minloc0s.m4 @@ -38,9 +38,10 @@ include(iforeach-s.m4)dnl FOREACH_FUNCTION( ` const atype_name *minval; - minval = base;' + minval = NULL;' , -` if (compare_fcn (base, minval, len) < 0) +` if (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0)) { minval = base; for (n = 0; n < rank; n++) @@ -52,7 +53,9 @@ MASKED_FOREACH_FUNCTION( minval = NULL;' , -` if (*mbase && (minval == NULL || compare_fcn (base, minval, len) < 0)) +` if (*mbase && + (minval == NULL || (back ? compare_fcn (base, minval, len) <= 0 : + compare_fcn (base, minval, len) < 0))) { minval = base; for (n = 0; n < rank; n++) diff --git a/libgfortran/m4/minloc1.m4 b/libgfortran/m4/minloc1.m4 index ebf52f09d5f9..a83156eaa538 100644 --- a/libgfortran/m4/minloc1.m4 +++ b/libgfortran/m4/minloc1.m4 @@ -42,6 +42,8 @@ ARRAY_FUNCTION(0, #endif result = 1;', `#if defined ('atype_nan`) + for (n = 0; n < len; n++, src += delta) + { if (*src <= minval) { minval = *src; @@ -49,14 +51,26 @@ ARRAY_FUNCTION(0, break; } } - for (; n < len; n++, src += delta) - { +#else + n = 0; #endif - if (*src < minval) - { - minval = *src; - result = (rtype_name)n + 1; - }') + if (back) + for (; n < len; n++, src += delta) + { + if (unlikely (*src <= minval)) + { + minval = *src; + result = (rtype_name)n + 1; + } + } + else + for (; n < len; n++, src += delta) + { + if (unlikely (*src < minval)) + { + minval = *src; + result = (rtype_name) n + 1; + }') MASKED_ARRAY_FUNCTION(0, ` atype_name minval; @@ -88,13 +102,23 @@ MASKED_ARRAY_FUNCTION(0, result = result2; else #endif - for (; n < len; n++, src += delta, msrc += mdelta) - { - if (*msrc && *src < minval) + if (back) + for (; n < len; n++, src += delta, msrc += mdelta) + { + if (*msrc && unlikely (*src <= minval)) + { + minval = *src; + result = (rtype_name)n + 1; + } + } + else + for (; n < len; n++, src += delta, msrc += mdelta) { - minval = *src; - result = (rtype_name)n + 1; - }', `') + if (*msrc && unlikely (*src < minval)) + { + minval = *src; + result = (rtype_name) n + 1; + }') SCALAR_ARRAY_FUNCTION(0) diff --git a/libgfortran/m4/minloc1s.m4 b/libgfortran/m4/minloc1s.m4 index 6e46631ab8b1..e74e2781a500 100644 --- a/libgfortran/m4/minloc1s.m4 +++ b/libgfortran/m4/minloc1s.m4 @@ -34,9 +34,10 @@ include(ifunction-s.m4)dnl ARRAY_FUNCTION(0, ` const atype_name *minval; - minval = base; - result = 1;', -` if (compare_fcn (src, minval, string_len) < 0) + minval = NULL; + result = 0;', +` if (minval == NULL || (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (rtype_name)n + 1; @@ -55,7 +56,8 @@ MASKED_ARRAY_FUNCTION(0, } for (; n < len; n++, src += delta, msrc += mdelta) { - if (*msrc && compare_fcn (src, minval, string_len) < 0) + if (*msrc && (back ? compare_fcn (src, minval, string_len) <= 0 : + compare_fcn (src, minval, string_len) < 0)) { minval = src; result = (rtype_name)n + 1; diff --git a/libgfortran/m4/minloc2s.m4 b/libgfortran/m4/minloc2s.m4 index 2df71bb34b94..0cdb2a550890 100644 --- a/libgfortran/m4/minloc2s.m4 +++ b/libgfortran/m4/minloc2s.m4 @@ -52,10 +52,9 @@ export_proto('name`'rtype_qual`_'atype_code`); index_type sstride; index_type extent; const 'atype_name` *src; - const 'atype_name` *maxval; + const 'atype_name` *minval; index_type i; - assert(back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -64,15 +63,16 @@ export_proto('name`'rtype_qual`_'atype_code`); ret = 1; src = array->base_addr; - maxval = src; - for (i=2; i<=extent; i++) + minval = NULL; + for (i=1; i<=extent; i++) { - src += sstride; - if (compare_fcn (src, maxval, len) < 0) + if (minval == NULL || (back ? compare_fcn (src, minval, len) <= 0 : + compare_fcn (src, minval, len) < 0)) { ret = i; - maxval = src; + minval = src; } + src += sstride; } return ret; } @@ -97,7 +97,6 @@ m'name`'rtype_qual`_'atype_code` ('atype` * const restrict array, int mask_kind; index_type mstride; - assert (back == 0); extent = GFC_DESCRIPTOR_EXTENT(array,0); if (extent <= 0) return 0; @@ -135,7 +134,9 @@ m'name`'rtype_qual`_'atype_code` ('atype` * const restrict array, for (i=j+1; i<=extent; i++) { - if (*mbase && compare_fcn (src, maxval, len) < 0) + + if (*mbase && (back ? compare_fcn (src, maxval, len) <= 0 : + compare_fcn (src, maxval, len) < 0)) { ret = i; maxval = src;