sse4_1-roundps-1.c: Remove ASM_SUFFIX define.
[gcc.git] / libgfortran / generated / minloc0_4_r4.c
index 6d8f74e29914026e25327a9d4a7b39fc4f857cdd..c6eedf16e741b52dd2754b1e5d0a8fa5b5b9060b 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2002-2015 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -53,22 +53,22 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (rank <= 0)
     runtime_error ("Rank of array needs to be > 0");
 
-  if (retarray->data == NULL)
+  if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
       retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
       retarray->offset = 0;
-      retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+      retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
     }
   else
     {
       if (unlikely (compile_options.bounds_check))
-        bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
-                               "MINLOC");
+       bounds_iforeach_return ((array_t *) retarray, (array_t *) array,
+                               "MINLOC");
     }
 
   dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->data;
+  dest = retarray->base_addr;
   for (n = 0; n < rank; n++)
     {
       sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
@@ -83,55 +83,87 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray,
        }
     }
 
-  base = array->data;
+  base = array->base_addr;
 
   /* Initialize the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    dest[n * dstride] = 1;
   {
 
-  GFC_REAL_4 minval;
-
-  minval = GFC_REAL_4_HUGE;
+    GFC_REAL_4 minval;
+#if defined(GFC_REAL_4_QUIET_NAN)
+    int fast = 0;
+#endif
 
+#if defined(GFC_REAL_4_INFINITY)
+    minval = GFC_REAL_4_INFINITY;
+#else
+    minval = GFC_REAL_4_HUGE;
+#endif
   while (base)
     {
-      {
-        /* Implementation start.  */
+      do
+       {
+         /* Implementation start.  */
 
-  if (*base < minval || !dest[0])
-    {
-      minval = *base;
-      for (n = 0; n < rank; n++)
-        dest[n * dstride] = count[n] + 1;
-    }
-        /* Implementation end.  */
-      }
-      /* Advance to the next element.  */
-      count[0]++;
-      base += sstride[0];
+#if defined(GFC_REAL_4_QUIET_NAN)
+       }
+      while (0);
+      if (unlikely (!fast))
+       {
+         do
+           {
+             if (*base <= minval)
+               {
+                 fast = 1;
+                 minval = *base;
+                 for (n = 0; n < rank; n++)
+                   dest[n * dstride] = count[n] + 1;
+                 break;
+               }
+             base += sstride[0];
+           }
+         while (++count[0] != extent[0]);
+         if (likely (fast))
+           continue;
+       }
+      else do
+       {
+#endif
+         if (*base < 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];
+       }
+      while (++count[0] != extent[0]);
       n = 0;
-      while (count[n] == extent[n])
-        {
-          /* When we get to the end of a dimension, reset it and increment
-             the next dimension.  */
-          count[n] = 0;
-          /* We could precalculate these products, but this is a less
-             frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          n++;
-          if (n == rank)
-            {
-              /* Break out of the loop.  */
-              base = NULL;
-              break;
-            }
-          else
-            {
-              count[n]++;
-              base += sstride[n];
-            }
-        }
+      do
+       {
+         /* When we get to the end of a dimension, reset it and increment
+            the next dimension.  */
+         count[n] = 0;
+         /* We could precalculate these products, but this is a less
+            frequently used path so probably not worth it.  */
+         base -= sstride[n] * extent[n];
+         n++;
+         if (n == rank)
+           {
+             /* Break out of the loop.  */
+             base = NULL;
+             break;
+           }
+         else
+           {
+             count[n]++;
+             base += sstride[n];
+           }
+       }
+      while (count[n] == extent[n]);
     }
   }
 }
@@ -162,12 +194,12 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (rank <= 0)
     runtime_error ("Rank of array needs to be > 0");
 
-  if (retarray->data == NULL)
+  if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET(retarray->dim[0], 0, rank - 1, 1);
       retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
       retarray->offset = 0;
-      retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+      retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
     }
   else
     {
@@ -183,7 +215,7 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 
   mask_kind = GFC_DESCRIPTOR_SIZE (mask);
 
-  mbase = mask->data;
+  mbase = mask->base_addr;
 
   if (mask_kind == 1 || mask_kind == 2 || mask_kind == 4 || mask_kind == 8
 #ifdef HAVE_GFC_LOGICAL_16
@@ -195,7 +227,7 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
     runtime_error ("Funny sized logical array");
 
   dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->data;
+  dest = retarray->base_addr;
   for (n = 0; n < rank; n++)
     {
       sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
@@ -211,7 +243,7 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
        }
     }
 
-  base = array->data;
+  base = array->base_addr;
 
   /* Initialize the return value.  */
   for (n = 0; n < rank; n++)
@@ -219,50 +251,87 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   {
 
   GFC_REAL_4 minval;
+   int fast = 0;
 
-  minval = GFC_REAL_4_HUGE;
-
+#if defined(GFC_REAL_4_INFINITY)
+    minval = GFC_REAL_4_INFINITY;
+#else
+    minval = GFC_REAL_4_HUGE;
+#endif
   while (base)
     {
-      {
-        /* Implementation start.  */
+      do
+       {
+         /* Implementation start.  */
 
-  if (*mbase && (*base < minval || !dest[0]))
-    {
-      minval = *base;
-      for (n = 0; n < rank; n++)
-        dest[n * dstride] = count[n] + 1;
-    }
-        /* Implementation end.  */
-      }
-      /* Advance to the next element.  */
-      count[0]++;
-      base += sstride[0];
-      mbase += mstride[0];
+       }
+      while (0);
+      if (unlikely (!fast))
+       {
+         do
+           {
+             if (*mbase)
+               {
+#if defined(GFC_REAL_4_QUIET_NAN)
+                 if (unlikely (dest[0] == 0))
+                   for (n = 0; n < rank; n++)
+                     dest[n * dstride] = count[n] + 1;
+                 if (*base <= minval)
+#endif
+                   {
+                     fast = 1;
+                     minval = *base;
+                     for (n = 0; n < rank; n++)
+                       dest[n * dstride] = count[n] + 1;
+                     break;
+                   }
+               }
+             base += sstride[0];
+             mbase += mstride[0];
+           }
+         while (++count[0] != extent[0]);
+         if (likely (fast))
+           continue;
+       }
+      else do
+       {
+         if (*mbase && *base < 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];
+         mbase += mstride[0];
+       }
+      while (++count[0] != extent[0]);
       n = 0;
-      while (count[n] == extent[n])
-        {
-          /* When we get to the end of a dimension, reset it and increment
-             the next dimension.  */
-          count[n] = 0;
-          /* We could precalculate these products, but this is a less
-             frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          mbase -= mstride[n] * extent[n];
-          n++;
-          if (n == rank)
-            {
-              /* Break out of the loop.  */
-              base = NULL;
-              break;
-            }
-          else
-            {
-              count[n]++;
-              base += sstride[n];
-              mbase += mstride[n];
-            }
-        }
+      do
+       {
+         /* When we get to the end of a dimension, reset it and increment
+            the next dimension.  */
+         count[n] = 0;
+         /* We could precalculate these products, but this is a less
+            frequently used path so probably not worth it.  */
+         base -= sstride[n] * extent[n];
+         mbase -= mstride[n] * extent[n];
+         n++;
+         if (n == rank)
+           {
+             /* Break out of the loop.  */
+             base = NULL;
+             break;
+           }
+         else
+           {
+             count[n]++;
+             base += sstride[n];
+             mbase += mstride[n];
+           }
+       }
+      while (count[n] == extent[n]);
     }
   }
 }
@@ -293,12 +362,12 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (rank <= 0)
     runtime_error ("Rank of array needs to be > 0");
 
-  if (retarray->data == NULL)
+  if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
       retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
       retarray->offset = 0;
-      retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+      retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
     }
   else if (unlikely (compile_options.bounds_check))
     {
@@ -307,7 +376,7 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
     }
 
   dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->data;
+  dest = retarray->base_addr;
   for (n = 0; n<rank; n++)
     dest[n * dstride] = 0 ;
 }