https://gcc.gnu.org/g:7d31a818c4c956a47617d253d9c87880fdc61e2c

commit 7d31a818c4c956a47617d253d9c87880fdc61e2c
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Mon Sep 8 21:51:03 2025 +0200

    Introduction macro PTR_DECREMENT_BYTES
    
    Correction ; manquant ifindloc1.m4
    
    Correction matmul
    
    Correction matmul

Diff:
---
 libgfortran/intrinsics/random.c     | 18 +++++++++---------
 libgfortran/io/transfer.c           | 12 ++++++------
 libgfortran/libgfortran.h           |  3 ++-
 libgfortran/m4/cshift0.m4           |  4 ++--
 libgfortran/m4/cshift1.m4           |  2 +-
 libgfortran/m4/cshift1a.m4          |  6 +++---
 libgfortran/m4/eoshift1.m4          |  2 +-
 libgfortran/m4/eoshift3.m4          |  2 +-
 libgfortran/m4/ifindloc0.m4         | 12 ++++++------
 libgfortran/m4/ifindloc1.m4         | 17 ++++++++++-------
 libgfortran/m4/ifindloc2.m4         |  4 ++--
 libgfortran/m4/iforeach-s.m4        |  4 ++--
 libgfortran/m4/iforeach-s2.m4       |  4 ++--
 libgfortran/m4/iforeach.m4          |  4 ++--
 libgfortran/m4/ifunction-s.m4       | 10 +++++-----
 libgfortran/m4/ifunction-s2.m4      | 10 +++++-----
 libgfortran/m4/ifunction.m4         | 10 +++++-----
 libgfortran/m4/ifunction_logical.m4 |  2 +-
 libgfortran/m4/in_pack.m4           |  2 +-
 libgfortran/m4/in_unpack.m4         |  2 +-
 libgfortran/m4/matmul_internal.m4   | 15 ++++++++-------
 libgfortran/m4/pack.m4              |  2 +-
 libgfortran/m4/reshape.m4           |  4 ++--
 libgfortran/m4/spread.m4            |  4 ++--
 libgfortran/m4/unpack.m4            |  6 +++---
 25 files changed, 83 insertions(+), 78 deletions(-)

diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c
index 251eb4f61c2b..b0b08638f8b4 100644
--- a/libgfortran/intrinsics/random.c
+++ b/libgfortran/intrinsics/random.c
@@ -661,7 +661,7 @@ arandom_r4 (gfc_array_r4 *x)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
@@ -727,7 +727,7 @@ arandom_r8 (gfc_array_r8 *x)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
@@ -795,7 +795,7 @@ arandom_r10 (gfc_array_r10 *x)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
@@ -866,7 +866,7 @@ arandom_r16 (gfc_array_r16 *x)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
@@ -937,7 +937,7 @@ arandom_r17 (gfc_array_r17 *x)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
@@ -1069,7 +1069,7 @@ arandom_m2 (gfc_array_m2 *x)
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
          n++;
          if (n == dim)
            {
@@ -1134,7 +1134,7 @@ arandom_m4 (gfc_array_m4 *x)
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
          n++;
          if (n == dim)
            {
@@ -1199,7 +1199,7 @@ arandom_m8 (gfc_array_m8 *x)
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
          n++;
          if (n == dim)
            {
@@ -1266,7 +1266,7 @@ arandom_m16 (gfc_array_m16 *x)
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         dest -= stride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
          n++;
          if (n == dim)
            {
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 7f4941271836..a3573d0dad88 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -2843,13 +2843,13 @@ transfer_array_inner (st_parameter_dt *dtp, 
gfc_array_char *desc, int kind,
            return;
 
          dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize);
-         data += stride0 * tsize;
+         PTR_INCREMENT_BYTES (data, stride0 * tsize);
          count[0] += tsize;
          n = 0;
          while (count[n] == extent[n])
            {
              count[n] = 0;
-             data -= stride[n] * extent[n];
+             PTR_DECREMENT_BYTES (data, stride[n] * extent[n]);
              n++;
              if (n == rank)
                {
@@ -2859,7 +2859,7 @@ transfer_array_inner (st_parameter_dt *dtp, 
gfc_array_char *desc, int kind,
              else
                {
                  count[n]++;
-                 data += stride[n];
+                 PTR_INCREMENT_BYTES (data, stride[n]);
                }
            }
        }
@@ -2869,13 +2869,13 @@ transfer_array_inner (st_parameter_dt *dtp, 
gfc_array_char *desc, int kind,
       while (data)
        {
          dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize);
-         data += stride0 * tsize;
+         PTR_INCREMENT_BYTES (data, stride0 * tsize);
          count[0] += tsize;
          n = 0;
          while (count[n] == extent[n])
            {
              count[n] = 0;
-             data -= stride[n] * extent[n];
+             PTR_DECREMENT_BYTES (data, stride[n] * extent[n]);
              n++;
              if (n == rank)
                {
@@ -2885,7 +2885,7 @@ transfer_array_inner (st_parameter_dt *dtp, 
gfc_array_char *desc, int kind,
              else
                {
                  count[n]++;
-                 data += stride[n];
+                 PTR_INCREMENT_BYTES (data, stride[n]);
                }
            }
        }
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index 272639df9816..d7100fd5b7c4 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -586,7 +586,8 @@ typedef GFC_FULL_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, 
GFC_INTEGER_4) gfc_full_a
                             (__alignof__(GFC_COMPLEX_8) - 1))
 
 
-#define PTR_INCREMENT_BYTES(ptr,bytes) ptr = (typeof (ptr)) (((char*) ptr) + 
bytes)
+#define PTR_INCREMENT_BYTES(ptr,bytes) ptr = (typeof (ptr)) (((char*) ptr) + 
(bytes))
+#define PTR_DECREMENT_BYTES(ptr,bytes) ptr = (typeof (ptr)) (((char*) ptr) - 
(bytes))
 
 
 /* Generic vtab structure.  */
diff --git a/libgfortran/m4/cshift0.m4 b/libgfortran/m4/cshift0.m4
index 2c31f7611373..d5427a161dfa 100644
--- a/libgfortran/m4/cshift0.m4
+++ b/libgfortran/m4/cshift0.m4
@@ -219,8 +219,8 @@ cshift0_'rtype_code` ('rtype` *ret, const 'rtype` *array, 
ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          PTR_DECREMENT_BYTES (rptr, rstride[n] * extent[n]);
+          PTR_DECREMENT_BYTES (sptr, sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
diff --git a/libgfortran/m4/cshift1.m4 b/libgfortran/m4/cshift1.m4
index 29d5b675b598..ef629454e820 100644
--- a/libgfortran/m4/cshift1.m4
+++ b/libgfortran/m4/cshift1.m4
@@ -302,9 +302,9 @@ cshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
+         PTR_DECREMENT_BYTES (hptr, hstride[n] * extent[n]);
           rptr -= rstride[n] * extent[n];
           sptr -= sstride[n] * extent[n];
-         hptr -= hstride[n] * extent[n];
           n++;
           if (n >= dim - 1)
             {
diff --git a/libgfortran/m4/cshift1a.m4 b/libgfortran/m4/cshift1a.m4
index b1cbac585b32..336051bde4d2 100644
--- a/libgfortran/m4/cshift1a.m4
+++ b/libgfortran/m4/cshift1a.m4
@@ -170,9 +170,9 @@ cshift1'rtype_qual`_'atype_code` ('atype` * const restrict 
ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-         hptr -= hs_ex[n];
+          PTR_DECREMENT_BYTES (rptr, rs_ex[n]);
+          PTR_DECREMENT_BYTES (sptr, ss_ex[n]);
+         PTR_DECREMENT_BYTES (hptr, hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4
index 07ebe3883e04..7de92f2054e2 100644
--- a/libgfortran/m4/eoshift1.m4
+++ b/libgfortran/m4/eoshift1.m4
@@ -235,9 +235,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
+         PTR_DECREMENT_BYTES (hptr, hstride[n] * extent[n]);
           rptr -= rstride[n] * extent[n];
           sptr -= sstride[n] * extent[n];
-         hptr -= hstride[n] * extent[n];
           n++;
           if (n >= dim - 1)
             {
diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4
index 4fa8287500fa..28706a998194 100644
--- a/libgfortran/m4/eoshift3.m4
+++ b/libgfortran/m4/eoshift3.m4
@@ -252,9 +252,9 @@ eoshift3 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
+         PTR_DECREMENT_BYTES (hptr, hstride[n] * extent[n]);
           rptr -= rstride[n] * extent[n];
           sptr -= sstride[n] * extent[n];
-         hptr -= hstride[n] * extent[n];
           bptr -= bstride[n] * extent[n];
           n++;
           if (n >= dim - 1)
diff --git a/libgfortran/m4/ifindloc0.m4 b/libgfortran/m4/ifindloc0.m4
index 7d02b979e6b3..72ce3ab4f933 100644
--- a/libgfortran/m4/ifindloc0.m4
+++ b/libgfortran/m4/ifindloc0.m4
@@ -92,7 +92,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
                  return;
                }
-             base -= sstride[0] * 'base_mult`;
+             PTR_DECREMENT_BYTES (base, sstride[0] * 'base_mult`);
            } while(++count[0] != extent[0]);
 
          n = 0;
@@ -110,7 +110,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
              else
                {
                  count[n]++;
-                 base -= sstride[n] * 'base_mult`;
+                 PTR_DECREMENT_BYTES (base, sstride[n] * 'base_mult`);
                }
            } while (count[n] == extent[n]);      
        }
@@ -140,7 +140,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
              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] * 'base_mult`;
+             PTR_DECREMENT_BYTES (base, sstride[n] * extent[n] * 'base_mult`);
              n++;
              if (n >= rank)
                return;
@@ -241,7 +241,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
 
                  return;
                }
-             base -= sstride[0] * 'base_mult`;
+             PTR_DECREMENT_BYTES (base, sstride[0] * 'base_mult`);
              mbase -= mstride[0];
            } while(++count[0] != extent[0]);
 
@@ -261,7 +261,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
              else
                {
                  count[n]++;
-                 base -= sstride[n] * 'base_mult`;
+                 PTR_DECREMENT_BYTES (base, sstride[n] * 'base_mult`);
                  mbase += mstride[n];
                }
            } while (count[n] == extent[n]);      
@@ -293,7 +293,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
              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] * 'base_mult`;
+             PTR_DECREMENT_BYTES (base, sstride[n] * extent[n] * 'base_mult`);
              mbase -= mstride[n] * extent[n];
              n++;
              if (n >= rank)
diff --git a/libgfortran/m4/ifindloc1.m4 b/libgfortran/m4/ifindloc1.m4
index 3ee3709fc6af..285dfc5adf34 100644
--- a/libgfortran/m4/ifindloc1.m4
+++ b/libgfortran/m4/ifindloc1.m4
@@ -132,13 +132,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
       if (back)
        {
          src = base + (len - 1) * delta * 'base_mult`;
-         for (n = len; n > 0; n--, src -= delta * 'base_mult`)
+         for (n = len; n > 0; n--)
            {
              if ('comparison`)
                {
                  result = n;
                  break;
                }
+             PTR_DECREMENT_BYTES (src, delta * 'base_mult`);
            }
        }
       else
@@ -163,8 +164,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
       while (count[n] == extent[n])
        {
          count[n] = 0;
-         base -= sstride[n] * extent[n] * 'base_mult`;
-         dest -= dstride[n] * extent[n];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n] * 'base_mult`);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -308,13 +309,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
        {
          src = base + (len - 1) * delta * 'base_mult`;
          msrc = mbase + (len - 1) * mdelta; 
-         for (n = len; n > 0; n--, src -= delta * 'base_mult`, msrc -= mdelta)
+         for (n = len; n > 0; n--)
            {
              if (*msrc && 'comparison`)
                {
                  result = n;
                  break;
                }
+             PTR_DECREMENT_BYTES (src, delta * 'base_mult`);
+             msrc -= mdelta;
            }
        }
       else
@@ -342,9 +345,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
       while (count[n] == extent[n])
        {
          count[n] = 0;
-         base -= sstride[n] * extent[n] * 'base_mult`;
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n] * 'base_mult`);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
-         dest -= dstride[n] * extent[n];
          n++;
          if (n >= rank)
            {
@@ -466,7 +469,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
       while (count[n] == extent[n])
        {
          count[n] = 0;
-         dest -= dstride[n] * extent[n];
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
diff --git a/libgfortran/m4/ifindloc2.m4 b/libgfortran/m4/ifindloc2.m4
index 36a3a3728e66..15140119ff36 100644
--- a/libgfortran/m4/ifindloc2.m4
+++ b/libgfortran/m4/ifindloc2.m4
@@ -45,7 +45,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
        {
          if ('comparison`)
            return i;
-         src -= sstride;
+         PTR_DECREMENT_BYTES (src, sstride);
        }
     }
   else
@@ -98,7 +98,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
        {
          if (*mbase && ('comparison`))
            return i;
-         src -= sstride;
+         PTR_DECREMENT_BYTES (src, sstride);
          mbase -= mstride;
        }
     }
diff --git a/libgfortran/m4/iforeach-s.m4 b/libgfortran/m4/iforeach-s.m4
index 12c4baaaa447..2eb1acaa11f4 100644
--- a/libgfortran/m4/iforeach-s.m4
+++ b/libgfortran/m4/iforeach-s.m4
@@ -92,7 +92,7 @@ define(FINISH_FOREACH_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -221,7 +221,7 @@ define(FINISH_MASKED_FOREACH_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
          n++;
          if (n >= rank)
diff --git a/libgfortran/m4/iforeach-s2.m4 b/libgfortran/m4/iforeach-s2.m4
index 0a368582330a..7168552a5cdc 100644
--- a/libgfortran/m4/iforeach-s2.m4
+++ b/libgfortran/m4/iforeach-s2.m4
@@ -75,7 +75,7 @@ define(FINISH_FOREACH_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -173,7 +173,7 @@ define(FINISH_MASKED_FOREACH_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
          n++;
          if (n >= rank)
diff --git a/libgfortran/m4/iforeach.m4 b/libgfortran/m4/iforeach.m4
index dd9ae01093aa..ca5664e537cb 100644
--- a/libgfortran/m4/iforeach.m4
+++ b/libgfortran/m4/iforeach.m4
@@ -81,7 +81,7 @@ define(FINISH_FOREACH_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -206,7 +206,7 @@ define(FINISH_MASKED_FOREACH_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
          n++;
          if (n >= rank)
diff --git a/libgfortran/m4/ifunction-s.m4 b/libgfortran/m4/ifunction-s.m4
index f12b324dbf42..08fbf4485f8f 100644
--- a/libgfortran/m4/ifunction-s.m4
+++ b/libgfortran/m4/ifunction-s.m4
@@ -169,8 +169,8 @@ define(FINISH_ARRAY_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -358,9 +358,9 @@ define(FINISH_MASKED_ARRAY_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
-         dest -= dstride[n] * extent[n];
          n++;
          if (n >= rank)
            {
@@ -504,7 +504,7 @@ s'name`'rtype_qual`_'atype_code` ('rtype` * 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];
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            return;
diff --git a/libgfortran/m4/ifunction-s2.m4 b/libgfortran/m4/ifunction-s2.m4
index df0448636a90..c70cac4a154d 100644
--- a/libgfortran/m4/ifunction-s2.m4
+++ b/libgfortran/m4/ifunction-s2.m4
@@ -170,8 +170,8 @@ define(FINISH_ARRAY_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -359,9 +359,9 @@ define(FINISH_MASKED_ARRAY_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
-         dest -= dstride[n] * extent[n];
          n++;
          if (n >= rank)
            {
@@ -506,7 +506,7 @@ s'name`'rtype_qual`_'atype_code` ('rtype` * 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];
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            return;
diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
index 3bf9a05c9b46..b4fb5e763cc5 100644
--- a/libgfortran/m4/ifunction.m4
+++ b/libgfortran/m4/ifunction.m4
@@ -158,8 +158,8 @@ define(FINISH_ARRAY_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -346,9 +346,9 @@ define(FINISH_MASKED_ARRAY_FUNCTION,
          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];
+         PTR_DECREMENT_BYTES (base, sstride[n] * extent[n]);
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          mbase -= mstride[n] * extent[n];
-         dest -= dstride[n] * extent[n];
          n++;
          if (n >= rank)
            {
@@ -493,7 +493,7 @@ s'name`'rtype_qual`_'atype_code` ('rtype` * 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];
+         PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
          n++;
          if (n >= rank)
            return;
diff --git a/libgfortran/m4/ifunction_logical.m4 
b/libgfortran/m4/ifunction_logical.m4
index dcfd03bd920d..b6d7e616d546 100644
--- a/libgfortran/m4/ifunction_logical.m4
+++ b/libgfortran/m4/ifunction_logical.m4
@@ -176,8 +176,8 @@ define(FINISH_ARRAY_FUNCTION,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
+          PTR_DECREMENT_BYTES (dest, dstride[n] * extent[n]);
           base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
           n++;
           if (n >= rank)
             {
diff --git a/libgfortran/m4/in_pack.m4 b/libgfortran/m4/in_pack.m4
index bae7b9b4af69..49dc7572a759 100644
--- a/libgfortran/m4/in_pack.m4
+++ b/libgfortran/m4/in_pack.m4
@@ -98,7 +98,7 @@ internal_pack_'rtype_ccode` ('rtype` * source)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          src -= stride[n] * extent[n];
+          PTR_DECREMENT_BYTES (src, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
diff --git a/libgfortran/m4/in_unpack.m4 b/libgfortran/m4/in_unpack.m4
index 814e6c6552ef..843323cee6c3 100644
--- a/libgfortran/m4/in_unpack.m4
+++ b/libgfortran/m4/in_unpack.m4
@@ -87,7 +87,7 @@ internal_unpack_'rtype_ccode` ('rtype` * d, const 
'rtype_name` * src)
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          dest -= stride[n] * extent[n];
+          PTR_DECREMENT_BYTES (dest, stride[n] * extent[n]);
           n++;
           if (n == dim)
             {
diff --git a/libgfortran/m4/matmul_internal.m4 
b/libgfortran/m4/matmul_internal.m4
index d1ab0e06ce6c..2343cd6cc837 100644
--- a/libgfortran/m4/matmul_internal.m4
+++ b/libgfortran/m4/matmul_internal.m4
@@ -9,6 +9,7 @@
 
   index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
+  index_type aystride_bytes, bystride_bytes;
 
   assert (GFC_DESCRIPTOR_RANK (a) == 2
           || GFC_DESCRIPTOR_RANK (b) == 2);
@@ -192,6 +193,9 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl
        }
     }
 
+  aystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(a,1);
+  bystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(b,1);
+
   if (rxstride == 1 && axstride == 1 && bxstride == 1
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
@@ -210,7 +214,7 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl
       const index_type m = xcount, n = ycount, k = count;
 
       /* System generated locals */
-      index_type a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset,
+      index_type a_dim1, b_dim1, c_dim1,
                 i1, i2, i3, i4, i5, i6;
 
       /* Local variables */
@@ -226,14 +230,11 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl
 
       /* Parameter adjustments */
       c_dim1 = rystride;
-      c_offset = 1 + c_dim1;
-      c -= c_offset;
+      PTR_DECREMENT_BYTES (c, sizeof('rtype_name`) + 
GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1));
       a_dim1 = aystride;
-      a_offset = 1 + a_dim1;
-      a -= a_offset;
+      PTR_DECREMENT_BYTES (a, sizeof('rtype_name`) + aystride_bytes);
       b_dim1 = bystride;
-      b_offset = 1 + b_dim1;
-      b -= b_offset;
+      PTR_DECREMENT_BYTES (b, sizeof('rtype_name`) + bystride_bytes);
 
       /* Empty c first.  */
       for (j=1; j<=n; j++)
diff --git a/libgfortran/m4/pack.m4 b/libgfortran/m4/pack.m4
index 1529360bf9ec..bd1f83cd3be8 100644
--- a/libgfortran/m4/pack.m4
+++ b/libgfortran/m4/pack.m4
@@ -216,7 +216,7 @@ pack_'rtype_code` ('rtype` *ret, const 'rtype` *array,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          sptr -= sstride[n] * extent[n];
+          PTR_DECREMENT_BYTES (sptr, sstride[n] * extent[n]);
           mptr -= mstride[n] * extent[n];
           n++;
           if (n >= dim)
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index 49059fc5055e..9519fc4d2e80 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -312,7 +312,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           rcount[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * rextent[n];
+          PTR_DECREMENT_BYTES (rptr, rstride[n] * rextent[n]);
           n++;
           if (n == rdim)
             {
@@ -335,7 +335,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           scount[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          src -= sstride[n] * sextent[n];
+          PTR_DECREMENT_BYTES (src, sstride[n] * sextent[n]);
           n++;
           if (n == sdim)
             {
diff --git a/libgfortran/m4/spread.m4 b/libgfortran/m4/spread.m4
index a4411d6d9250..be5fd4a3f074 100644
--- a/libgfortran/m4/spread.m4
+++ b/libgfortran/m4/spread.m4
@@ -207,8 +207,8 @@ spread_'rtype_code` ('rtype` *ret, const 'rtype` *source,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          sptr -= sstride[n] * extent[n];
-          rptr -= rstride[n] * extent[n];
+          PTR_DECREMENT_BYTES (sptr, sstride[n] * extent[n]);
+          PTR_DECREMENT_BYTES (rptr, rstride[n] * extent[n]);
           n++;
           if (n >= srank)
             {
diff --git a/libgfortran/m4/unpack.m4 b/libgfortran/m4/unpack.m4
index 28033a1fb6d9..5aa923abadd7 100644
--- a/libgfortran/m4/unpack.m4
+++ b/libgfortran/m4/unpack.m4
@@ -156,7 +156,7 @@ unpack0_'rtype_code` ('rtype` *ret, const 'rtype` *vector,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
+          PTR_DECREMENT_BYTES (rptr, rstride[n] * extent[n]);
           mptr -= mstride[n] * extent[n];
           n++;
           if (n >= dim)
@@ -309,8 +309,8 @@ unpack1_'rtype_code` ('rtype` *ret, const 'rtype` *vector,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          fptr -= fstride[n] * extent[n];
+          PTR_DECREMENT_BYTES (rptr, rstride[n] * extent[n]);
+          PTR_DECREMENT_BYTES (fptr, fstride[n] * extent[n]);
           mptr -= mstride[n] * extent[n];
           n++;
           if (n >= dim)

Reply via email to