https://gcc.gnu.org/g:55e9adf64466dc55fd6ab9cfacf8fd163b402f98
commit 55e9adf64466dc55fd6ab9cfacf8fd163b402f98 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Fri Jun 13 16:46:27 2025 +0200 Régénération fichiers libgfortran Diff: --- libgfortran/generated/maxloc1_16_i8.c | 132 ++++++++++++++++++--------------- libgfortran/generated/maxloc1_16_m16.c | 132 ++++++++++++++++++--------------- libgfortran/generated/maxloc1_4_i16.c | 132 ++++++++++++++++++--------------- libgfortran/generated/maxloc1_4_i8.c | 132 ++++++++++++++++++--------------- libgfortran/generated/maxloc1_8_i16.c | 132 ++++++++++++++++++--------------- libgfortran/generated/maxloc1_8_i8.c | 132 ++++++++++++++++++--------------- 6 files changed, 444 insertions(+), 348 deletions(-) diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c index ee97c1ac552d..c56709f21795 100644 --- a/libgfortran/generated/maxloc1_16_i8.c +++ b/libgfortran/generated/maxloc1_16_i8.c @@ -43,8 +43,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; const GFC_INTEGER_8 * restrict base; GFC_INTEGER_16 * restrict dest; index_type rank; @@ -68,11 +68,11 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; - delta = GFC_DESCRIPTOR_STRIDE(array,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -80,7 +80,7 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -94,20 +94,22 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_16); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_16); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_16); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -127,7 +129,7 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -155,12 +157,12 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, else { #if ! defined HAVE_BACK_ARG - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { #endif #if defined (GFC_INTEGER_8_QUIET_NAN) - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { if (*src >= maxval) { @@ -168,17 +170,21 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, result = (GFC_INTEGER_16)n + 1; break; } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } #else n = 0; #endif - for (; n < len; n++, src += delta) + for (; n < len; n++) { if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; } + + src = (const GFC_INTEGER_8 * restrict) (((char*) src) + delta); } *dest = result; @@ -186,8 +192,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[0]); + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -196,8 +202,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_8*) (((char*)base) - sspacing[n] * extent[n]); + dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -208,8 +214,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, else { count[n]++; - base += sstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[n]); + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]); } } } @@ -229,9 +235,9 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; - index_type mstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; + index_type mspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; @@ -281,13 +287,13 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, else runtime_error ("Funny sized logical array"); - delta = GFC_DESCRIPTOR_STRIDE(array,dim); - mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); + mdelta = GFC_DESCRIPTOR_SPACING(mask,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -296,8 +302,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -311,20 +317,22 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_16); else - str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_16); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_16); - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -345,7 +353,7 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -372,7 +380,7 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 result2 = 0; #endif result = 0; - for (n = 0; n < len; n++, src += delta, msrc += mdelta) + for (n = 0; n < len; n++, msrc += mdelta) { if (*msrc) @@ -388,6 +396,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, break; } } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } #if defined (GFC_INTEGER_8_QUIET_NAN) if (unlikely (n >= len)) @@ -395,30 +405,34 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, else #endif if (back) - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src >= maxval)) { maxval = *src; result = (GFC_INTEGER_16)n + 1; } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } else - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src > maxval)) { maxval = *src; result = (GFC_INTEGER_16)n + 1; } - } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); + } *dest = result; } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - mbase += mstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[0]); + mbase += mspacing[0]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -427,9 +441,9 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_8*) (((char*)base) - sspacing[n] * extent[n]); + mbase -= mspacing[n] * extent[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -440,9 +454,9 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, else { count[n]++; - base += sstride[n]; - mbase += mstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[n]); + mbase += mspacing[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]); } } } @@ -462,7 +476,7 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; @@ -513,20 +527,22 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_16); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_16); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_16); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -557,7 +573,7 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); } dest = retarray->base_addr; @@ -566,7 +582,7 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, { *dest = 0; count[0]++; - dest += dstride[0]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -575,14 +591,14 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, count[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ - dest -= dstride[n] * extent[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) return; else { count[n]++; - dest += dstride[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]); } } } diff --git a/libgfortran/generated/maxloc1_16_m16.c b/libgfortran/generated/maxloc1_16_m16.c index e6f1ae3607b6..dba58b0318a4 100644 --- a/libgfortran/generated/maxloc1_16_m16.c +++ b/libgfortran/generated/maxloc1_16_m16.c @@ -43,8 +43,8 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; const GFC_UINTEGER_16 * restrict base; GFC_INTEGER_16 * restrict dest; index_type rank; @@ -68,11 +68,11 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; - delta = GFC_DESCRIPTOR_STRIDE(array,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -80,7 +80,7 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -94,20 +94,22 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_16); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_16); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_16); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -127,7 +129,7 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -155,12 +157,12 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, else { #if ! defined HAVE_BACK_ARG - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { #endif #if defined (GFC_UINTEGER_16_QUIET_NAN) - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { if (*src >= maxval) { @@ -168,17 +170,21 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, result = (GFC_INTEGER_16)n + 1; break; } + + src = (const GFC_UINTEGER_16 * restrict) (((char*)src) + delta); } #else n = 0; #endif - for (; n < len; n++, src += delta) + for (; n < len; n++) { if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_16)n + 1; } + + src = (const GFC_UINTEGER_16 * restrict) (((char*) src) + delta); } *dest = result; @@ -186,8 +192,8 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - dest += dstride[0]; + base = (GFC_UINTEGER_16*) (((char*)base) + sspacing[0]); + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -196,8 +202,8 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_UINTEGER_16*) (((char*)base) - sspacing[n] * extent[n]); + dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -208,8 +214,8 @@ maxloc1_16_m16 (gfc_array_i16 * const restrict retarray, else { count[n]++; - base += sstride[n]; - dest += dstride[n]; + base = (GFC_UINTEGER_16*) (((char*)base) + sspacing[n]); + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]); } } } @@ -229,9 +235,9 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; - index_type mstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; + index_type mspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_16 * restrict dest; const GFC_UINTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; @@ -281,13 +287,13 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, else runtime_error ("Funny sized logical array"); - delta = GFC_DESCRIPTOR_STRIDE(array,dim); - mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); + mdelta = GFC_DESCRIPTOR_SPACING(mask,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -296,8 +302,8 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -311,20 +317,22 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_16); else - str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_16); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_16); - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -345,7 +353,7 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -372,7 +380,7 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 result2 = 0; #endif result = 0; - for (n = 0; n < len; n++, src += delta, msrc += mdelta) + for (n = 0; n < len; n++, msrc += mdelta) { if (*msrc) @@ -388,6 +396,8 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, break; } } + + src = (const GFC_UINTEGER_16 * restrict) (((char*)src) + delta); } #if defined (GFC_UINTEGER_16_QUIET_NAN) if (unlikely (n >= len)) @@ -395,30 +405,34 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, else #endif if (back) - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src >= maxval)) { maxval = *src; result = (GFC_INTEGER_16)n + 1; } + + src = (const GFC_UINTEGER_16 * restrict) (((char*)src) + delta); } else - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src > maxval)) { maxval = *src; result = (GFC_INTEGER_16)n + 1; } - } + + src = (const GFC_UINTEGER_16 * restrict) (((char*)src) + delta); + } *dest = result; } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - mbase += mstride[0]; - dest += dstride[0]; + base = (GFC_UINTEGER_16*) (((char*)base) + sspacing[0]); + mbase += mspacing[0]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -427,9 +441,9 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_UINTEGER_16*) (((char*)base) - sspacing[n] * extent[n]); + mbase -= mspacing[n] * extent[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -440,9 +454,9 @@ mmaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, else { count[n]++; - base += sstride[n]; - mbase += mstride[n]; - dest += dstride[n]; + base = (GFC_UINTEGER_16*) (((char*)base) + sspacing[n]); + mbase += mspacing[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]); } } } @@ -462,7 +476,7 @@ smaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; @@ -513,20 +527,22 @@ smaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_16); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_16); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_16); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -557,7 +573,7 @@ smaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); } dest = retarray->base_addr; @@ -566,7 +582,7 @@ smaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, { *dest = 0; count[0]++; - dest += dstride[0]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -575,14 +591,14 @@ smaxloc1_16_m16 (gfc_array_i16 * const restrict retarray, count[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ - dest -= dstride[n] * extent[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) return; else { count[n]++; - dest += dstride[n]; + dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]); } } } diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c index cb866c0c4298..d163afb3bfc5 100644 --- a/libgfortran/generated/maxloc1_4_i16.c +++ b/libgfortran/generated/maxloc1_4_i16.c @@ -43,8 +43,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; const GFC_INTEGER_16 * restrict base; GFC_INTEGER_4 * restrict dest; index_type rank; @@ -68,11 +68,11 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; - delta = GFC_DESCRIPTOR_STRIDE(array,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -80,7 +80,7 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -94,20 +94,22 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_4); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_4); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_4); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -127,7 +129,7 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -155,12 +157,12 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, else { #if ! defined HAVE_BACK_ARG - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { #endif #if defined (GFC_INTEGER_16_QUIET_NAN) - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { if (*src >= maxval) { @@ -168,17 +170,21 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, result = (GFC_INTEGER_4)n + 1; break; } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); } #else n = 0; #endif - for (; n < len; n++, src += delta) + for (; n < len; n++) { if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; } + + src = (const GFC_INTEGER_16 * restrict) (((char*) src) + delta); } *dest = result; @@ -186,8 +192,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[0]); + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -196,8 +202,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_16*) (((char*)base) - sspacing[n] * extent[n]); + dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -208,8 +214,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, else { count[n]++; - base += sstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[n]); + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]); } } } @@ -229,9 +235,9 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; - index_type mstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; + index_type mspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; @@ -281,13 +287,13 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, else runtime_error ("Funny sized logical array"); - delta = GFC_DESCRIPTOR_STRIDE(array,dim); - mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); + mdelta = GFC_DESCRIPTOR_SPACING(mask,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -296,8 +302,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -311,20 +317,22 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_4); else - str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_4); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_4); - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -345,7 +353,7 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -372,7 +380,7 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 result2 = 0; #endif result = 0; - for (n = 0; n < len; n++, src += delta, msrc += mdelta) + for (n = 0; n < len; n++, msrc += mdelta) { if (*msrc) @@ -388,6 +396,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, break; } } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); } #if defined (GFC_INTEGER_16_QUIET_NAN) if (unlikely (n >= len)) @@ -395,30 +405,34 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, else #endif if (back) - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src >= maxval)) { maxval = *src; result = (GFC_INTEGER_4)n + 1; } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); } else - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src > maxval)) { maxval = *src; result = (GFC_INTEGER_4)n + 1; } - } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); + } *dest = result; } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - mbase += mstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[0]); + mbase += mspacing[0]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -427,9 +441,9 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_16*) (((char*)base) - sspacing[n] * extent[n]); + mbase -= mspacing[n] * extent[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -440,9 +454,9 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, else { count[n]++; - base += sstride[n]; - mbase += mstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[n]); + mbase += mspacing[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]); } } } @@ -462,7 +476,7 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; @@ -513,20 +527,22 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_4); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_4); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_4); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -557,7 +573,7 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); } dest = retarray->base_addr; @@ -566,7 +582,7 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, { *dest = 0; count[0]++; - dest += dstride[0]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -575,14 +591,14 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, count[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ - dest -= dstride[n] * extent[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) return; else { count[n]++; - dest += dstride[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]); } } } diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c index 31bff23b6200..6cd9afbdbaab 100644 --- a/libgfortran/generated/maxloc1_4_i8.c +++ b/libgfortran/generated/maxloc1_4_i8.c @@ -43,8 +43,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; const GFC_INTEGER_8 * restrict base; GFC_INTEGER_4 * restrict dest; index_type rank; @@ -68,11 +68,11 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; - delta = GFC_DESCRIPTOR_STRIDE(array,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -80,7 +80,7 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -94,20 +94,22 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_4); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_4); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_4); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -127,7 +129,7 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -155,12 +157,12 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, else { #if ! defined HAVE_BACK_ARG - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { #endif #if defined (GFC_INTEGER_8_QUIET_NAN) - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { if (*src >= maxval) { @@ -168,17 +170,21 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, result = (GFC_INTEGER_4)n + 1; break; } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } #else n = 0; #endif - for (; n < len; n++, src += delta) + for (; n < len; n++) { if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_4)n + 1; } + + src = (const GFC_INTEGER_8 * restrict) (((char*) src) + delta); } *dest = result; @@ -186,8 +192,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[0]); + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -196,8 +202,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_8*) (((char*)base) - sspacing[n] * extent[n]); + dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -208,8 +214,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, else { count[n]++; - base += sstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[n]); + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]); } } } @@ -229,9 +235,9 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; - index_type mstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; + index_type mspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; @@ -281,13 +287,13 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, else runtime_error ("Funny sized logical array"); - delta = GFC_DESCRIPTOR_STRIDE(array,dim); - mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); + mdelta = GFC_DESCRIPTOR_SPACING(mask,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -296,8 +302,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -311,20 +317,22 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_4); else - str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_4); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_4); - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -345,7 +353,7 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -372,7 +380,7 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 result2 = 0; #endif result = 0; - for (n = 0; n < len; n++, src += delta, msrc += mdelta) + for (n = 0; n < len; n++, msrc += mdelta) { if (*msrc) @@ -388,6 +396,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, break; } } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } #if defined (GFC_INTEGER_8_QUIET_NAN) if (unlikely (n >= len)) @@ -395,30 +405,34 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, else #endif if (back) - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src >= maxval)) { maxval = *src; result = (GFC_INTEGER_4)n + 1; } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } else - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src > maxval)) { maxval = *src; result = (GFC_INTEGER_4)n + 1; } - } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); + } *dest = result; } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - mbase += mstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[0]); + mbase += mspacing[0]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -427,9 +441,9 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_8*) (((char*)base) - sspacing[n] * extent[n]); + mbase -= mspacing[n] * extent[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -440,9 +454,9 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, else { count[n]++; - base += sstride[n]; - mbase += mstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[n]); + mbase += mspacing[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]); } } } @@ -462,7 +476,7 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; @@ -513,20 +527,22 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_4); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_4); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_4); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -557,7 +573,7 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); } dest = retarray->base_addr; @@ -566,7 +582,7 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, { *dest = 0; count[0]++; - dest += dstride[0]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -575,14 +591,14 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, count[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ - dest -= dstride[n] * extent[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) return; else { count[n]++; - dest += dstride[n]; + dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]); } } } diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c index 6e8061a18bf6..83c0ddf85935 100644 --- a/libgfortran/generated/maxloc1_8_i16.c +++ b/libgfortran/generated/maxloc1_8_i16.c @@ -43,8 +43,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; const GFC_INTEGER_16 * restrict base; GFC_INTEGER_8 * restrict dest; index_type rank; @@ -68,11 +68,11 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; - delta = GFC_DESCRIPTOR_STRIDE(array,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -80,7 +80,7 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -94,20 +94,22 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_8); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_8); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_8); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -127,7 +129,7 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -155,12 +157,12 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, else { #if ! defined HAVE_BACK_ARG - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { #endif #if defined (GFC_INTEGER_16_QUIET_NAN) - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { if (*src >= maxval) { @@ -168,17 +170,21 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, result = (GFC_INTEGER_8)n + 1; break; } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); } #else n = 0; #endif - for (; n < len; n++, src += delta) + for (; n < len; n++) { if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; } + + src = (const GFC_INTEGER_16 * restrict) (((char*) src) + delta); } *dest = result; @@ -186,8 +192,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[0]); + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -196,8 +202,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_16*) (((char*)base) - sspacing[n] * extent[n]); + dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -208,8 +214,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, else { count[n]++; - base += sstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[n]); + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]); } } } @@ -229,9 +235,9 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; - index_type mstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; + index_type mspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; @@ -281,13 +287,13 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, else runtime_error ("Funny sized logical array"); - delta = GFC_DESCRIPTOR_STRIDE(array,dim); - mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); + mdelta = GFC_DESCRIPTOR_SPACING(mask,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -296,8 +302,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -311,20 +317,22 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_8); else - str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_8); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_8); - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -345,7 +353,7 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -372,7 +380,7 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 result2 = 0; #endif result = 0; - for (n = 0; n < len; n++, src += delta, msrc += mdelta) + for (n = 0; n < len; n++, msrc += mdelta) { if (*msrc) @@ -388,6 +396,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, break; } } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); } #if defined (GFC_INTEGER_16_QUIET_NAN) if (unlikely (n >= len)) @@ -395,30 +405,34 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, else #endif if (back) - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src >= maxval)) { maxval = *src; result = (GFC_INTEGER_8)n + 1; } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); } else - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src > maxval)) { maxval = *src; result = (GFC_INTEGER_8)n + 1; } - } + + src = (const GFC_INTEGER_16 * restrict) (((char*)src) + delta); + } *dest = result; } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - mbase += mstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[0]); + mbase += mspacing[0]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -427,9 +441,9 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_16*) (((char*)base) - sspacing[n] * extent[n]); + mbase -= mspacing[n] * extent[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -440,9 +454,9 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, else { count[n]++; - base += sstride[n]; - mbase += mstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_16*) (((char*)base) + sspacing[n]); + mbase += mspacing[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]); } } } @@ -462,7 +476,7 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; @@ -513,20 +527,22 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_8); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_8); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_8); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -557,7 +573,7 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); } dest = retarray->base_addr; @@ -566,7 +582,7 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, { *dest = 0; count[0]++; - dest += dstride[0]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -575,14 +591,14 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, count[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ - dest -= dstride[n] * extent[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) return; else { count[n]++; - dest += dstride[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]); } } } diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c index d0c34950fff4..79b788ed7582 100644 --- a/libgfortran/generated/maxloc1_8_i8.c +++ b/libgfortran/generated/maxloc1_8_i8.c @@ -43,8 +43,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; const GFC_INTEGER_8 * restrict base; GFC_INTEGER_8 * restrict dest; index_type rank; @@ -68,11 +68,11 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; - delta = GFC_DESCRIPTOR_STRIDE(array,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -80,7 +80,7 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -94,20 +94,22 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_8); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_8); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_8); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -127,7 +129,7 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -155,12 +157,12 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, else { #if ! defined HAVE_BACK_ARG - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { #endif #if defined (GFC_INTEGER_8_QUIET_NAN) - for (n = 0; n < len; n++, src += delta) + for (n = 0; n < len; n++) { if (*src >= maxval) { @@ -168,17 +170,21 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, result = (GFC_INTEGER_8)n + 1; break; } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } #else n = 0; #endif - for (; n < len; n++, src += delta) + for (; n < len; n++) { if (back ? *src >= maxval : *src > maxval) { maxval = *src; result = (GFC_INTEGER_8)n + 1; } + + src = (const GFC_INTEGER_8 * restrict) (((char*) src) + delta); } *dest = result; @@ -186,8 +192,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[0]); + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -196,8 +202,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_8*) (((char*)base) - sspacing[n] * extent[n]); + dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -208,8 +214,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, else { count[n]++; - base += sstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[n]); + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]); } } } @@ -229,9 +235,9 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type sstride[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; - index_type mstride[GFC_MAX_DIMENSIONS]; + index_type sspacing[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; + index_type mspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; @@ -281,13 +287,13 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, else runtime_error ("Funny sized logical array"); - delta = GFC_DESCRIPTOR_STRIDE(array,dim); - mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim); + delta = GFC_DESCRIPTOR_SPACING(array,dim); + mdelta = GFC_DESCRIPTOR_SPACING(mask,dim); for (n = 0; n < dim; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n); extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); if (extent[n] < 0) @@ -296,8 +302,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, } for (n = dim; n < rank; n++) { - sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1); - mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1); + sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1); + mspacing[n] = GFC_DESCRIPTOR_SPACING(mask, n + 1); extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1); if (extent[n] < 0) @@ -311,20 +317,22 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_8); else - str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_8); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_8); - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -345,7 +353,7 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); if (extent[n] <= 0) return; } @@ -372,7 +380,7 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 result2 = 0; #endif result = 0; - for (n = 0; n < len; n++, src += delta, msrc += mdelta) + for (n = 0; n < len; n++, msrc += mdelta) { if (*msrc) @@ -388,6 +396,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, break; } } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } #if defined (GFC_INTEGER_8_QUIET_NAN) if (unlikely (n >= len)) @@ -395,30 +405,34 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, else #endif if (back) - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src >= maxval)) { maxval = *src; result = (GFC_INTEGER_8)n + 1; } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); } else - for (; n < len; n++, src += delta, msrc += mdelta) + for (; n < len; n++, msrc += mdelta) { if (*msrc && unlikely (*src > maxval)) { maxval = *src; result = (GFC_INTEGER_8)n + 1; } - } + + src = (const GFC_INTEGER_8 * restrict) (((char*)src) + delta); + } *dest = result; } /* Advance to the next element. */ count[0]++; - base += sstride[0]; - mbase += mstride[0]; - dest += dstride[0]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[0]); + mbase += mspacing[0]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -427,9 +441,9 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, 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]; - dest -= dstride[n] * extent[n]; + base = (GFC_INTEGER_8*) (((char*)base) - sspacing[n] * extent[n]); + mbase -= mspacing[n] * extent[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) { @@ -440,9 +454,9 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, else { count[n]++; - base += sstride[n]; - mbase += mstride[n]; - dest += dstride[n]; + base = (GFC_INTEGER_8*) (((char*)base) + sspacing[n]); + mbase += mspacing[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]); } } } @@ -462,7 +476,7 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, { index_type count[GFC_MAX_DIMENSIONS]; index_type extent[GFC_MAX_DIMENSIONS]; - index_type dstride[GFC_MAX_DIMENSIONS]; + index_type dspacing[GFC_MAX_DIMENSIONS]; GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; @@ -513,20 +527,22 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { if (n == 0) - str = 1; + str = sizeof (GFC_INTEGER_8); else - str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1]; + str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1]; - GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str); + GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str); } retarray->offset = 0; retarray->dtype.rank = rank; + GFC_DESCRIPTOR_SIZE (retarray) = sizeof (GFC_INTEGER_8); + GFC_DESCRIPTOR_SPAN (retarray) = sizeof (GFC_INTEGER_8); - alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1]; + alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1]; - retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8)); + retarray->base_addr = xmalloc (alloc_size); if (alloc_size == 0) return; } @@ -557,7 +573,7 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n); } dest = retarray->base_addr; @@ -566,7 +582,7 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, { *dest = 0; count[0]++; - dest += dstride[0]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]); n = 0; while (count[n] == extent[n]) { @@ -575,14 +591,14 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, count[n] = 0; /* We could precalculate these products, but this is a less frequently used path so probably not worth it. */ - dest -= dstride[n] * extent[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]); n++; if (n >= rank) return; else { count[n]++; - dest += dstride[n]; + dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]); } } }