summaryrefslogtreecommitdiff
path: root/libgfortran/generated/maxloc1_8_i1.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/generated/maxloc1_8_i1.c')
-rw-r--r--libgfortran/generated/maxloc1_8_i1.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c
index fa5bc4aadfd..1ff5cd3c90c 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;
}