]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/minloc0_4_r4.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / generated / minloc0_4_r4.c
index 1b85544a292f07530dc63134f42a4650f07c1c0a..ab6b772e1af1ade3b2058e90157ca52773cd6e35 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the MINLOC intrinsic
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2024 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -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");
@@ -55,7 +54,7 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
-      GFC_DTYPE_COPY_SETRANK(retarray,retarray,1);
+      retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
     }
@@ -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)
-           {
-             minval = *base;
-             for (n = 0; n < rank; n++)
-               dest[n * dstride] = count[n] + 1;
-           }
+      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,13 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   index_type n;
   int mask_kind;
 
-  assert(back == 0);
+
+  if (mask == NULL)
+    {
+      minloc0_4_r4 (retarray, array, back);
+      return;
+    }
+
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
     runtime_error ("Rank of array needs to be > 0");
@@ -198,7 +212,7 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET(retarray->dim[0], 0, rank - 1, 1);
-      GFC_DTYPE_COPY_SETRANK(retarray,retarray,1);
+      retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
     }
@@ -261,12 +275,8 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 #endif
   while (base)
     {
-      do
-       {
          /* Implementation start.  */
 
-       }
-      while (0);
       if (unlikely (!fast))
        {
          do
@@ -294,14 +304,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 +361,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);
@@ -352,7 +375,7 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   index_type n;
   GFC_INTEGER_4 *dest;
 
-  if (*mask)
+  if (mask == NULL || *mask)
     {
       minloc0_4_r4 (retarray, array, back);
       return;
@@ -366,7 +389,7 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
-      GFC_DTYPE_COPY_SETRANK(retarray,retarray,1);
+      retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
     }