[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Régénération des fichiers générés

Mikael Morin mikael@gcc.gnu.org
Wed Sep 17 20:02:42 GMT 2025


https://gcc.gnu.org/g:510548b4e090fb6eb28ab97c6f1275fea136839a

commit 510548b4e090fb6eb28ab97c6f1275fea136839a
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Sun Sep 14 19:14:26 2025 +0200

    Régénération des fichiers générés

Diff:
---
 libgfortran/generated/cshift0_c10.c      |  14 +--
 libgfortran/generated/cshift0_c16.c      |  14 +--
 libgfortran/generated/cshift0_c17.c      |  14 +--
 libgfortran/generated/cshift0_c4.c       |  14 +--
 libgfortran/generated/cshift0_c8.c       |  14 +--
 libgfortran/generated/cshift0_i1.c       |  14 +--
 libgfortran/generated/cshift0_i16.c      |  14 +--
 libgfortran/generated/cshift0_i2.c       |  14 +--
 libgfortran/generated/cshift0_i4.c       |  14 +--
 libgfortran/generated/cshift0_i8.c       |  14 +--
 libgfortran/generated/cshift0_r10.c      |  14 +--
 libgfortran/generated/cshift0_r16.c      |  14 +--
 libgfortran/generated/cshift0_r17.c      |  14 +--
 libgfortran/generated/cshift0_r4.c       |  14 +--
 libgfortran/generated/cshift0_r8.c       |  14 +--
 libgfortran/generated/matmul_c10.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_c16.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_c17.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_c4.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_c8.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_i1.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_i16.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_i2.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_i4.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_i8.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_r10.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_r16.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_r17.c       | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_r4.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmul_r8.c        | 165 +++++++++++++++++++------------
 libgfortran/generated/matmulavx128_c10.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_c16.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_c17.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_c4.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_c8.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_i1.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_i16.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_i2.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_i4.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_i8.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_r10.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_r16.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_r17.c |  66 ++++++++-----
 libgfortran/generated/matmulavx128_r4.c  |  66 ++++++++-----
 libgfortran/generated/matmulavx128_r8.c  |  66 ++++++++-----
 libgfortran/generated/spread_c10.c       |   3 +-
 libgfortran/generated/spread_c16.c       |   3 +-
 libgfortran/generated/spread_c17.c       |   3 +-
 libgfortran/generated/spread_c4.c        |   3 +-
 libgfortran/generated/spread_c8.c        |   3 +-
 libgfortran/generated/spread_i1.c        |   3 +-
 libgfortran/generated/spread_i16.c       |   3 +-
 libgfortran/generated/spread_i2.c        |   3 +-
 libgfortran/generated/spread_i4.c        |   3 +-
 libgfortran/generated/spread_i8.c        |   3 +-
 libgfortran/generated/spread_r10.c       |   3 +-
 libgfortran/generated/spread_r16.c       |   3 +-
 libgfortran/generated/spread_r17.c       |   3 +-
 libgfortran/generated/spread_r4.c        |   3 +-
 libgfortran/generated/spread_r8.c        |   3 +-
 60 files changed, 2220 insertions(+), 1500 deletions(-)

diff --git a/libgfortran/generated/cshift0_c10.c b/libgfortran/generated/cshift0_c10.c
index 3908c5b693f3..28e5f01e86ba 100644
--- a/libgfortran/generated/cshift0_c10.c
+++ b/libgfortran/generated/cshift0_c10.c
@@ -66,8 +66,8 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_10);
+  a_ex = sizeof (GFC_COMPLEX_10);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_COMPLEX_10);
       roffset = sizeof (GFC_COMPLEX_10);
       soffset = sizeof (GFC_COMPLEX_10);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_c16.c b/libgfortran/generated/cshift0_c16.c
index 962c009f3568..cbcd45d9c34b 100644
--- a/libgfortran/generated/cshift0_c16.c
+++ b/libgfortran/generated/cshift0_c16.c
@@ -66,8 +66,8 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_16);
+  a_ex = sizeof (GFC_COMPLEX_16);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_COMPLEX_16);
       roffset = sizeof (GFC_COMPLEX_16);
       soffset = sizeof (GFC_COMPLEX_16);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_c17.c b/libgfortran/generated/cshift0_c17.c
index ebe965efcb5d..a5fbfda368dd 100644
--- a/libgfortran/generated/cshift0_c17.c
+++ b/libgfortran/generated/cshift0_c17.c
@@ -66,8 +66,8 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_17);
+  a_ex = sizeof (GFC_COMPLEX_17);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_COMPLEX_17);
       roffset = sizeof (GFC_COMPLEX_17);
       soffset = sizeof (GFC_COMPLEX_17);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_c4.c b/libgfortran/generated/cshift0_c4.c
index 71758c0aed18..4b82a71c048b 100644
--- a/libgfortran/generated/cshift0_c4.c
+++ b/libgfortran/generated/cshift0_c4.c
@@ -66,8 +66,8 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_4);
+  a_ex = sizeof (GFC_COMPLEX_4);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_COMPLEX_4);
       roffset = sizeof (GFC_COMPLEX_4);
       soffset = sizeof (GFC_COMPLEX_4);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_c8.c b/libgfortran/generated/cshift0_c8.c
index 1b9bff6e7627..cfd2a97aaf03 100644
--- a/libgfortran/generated/cshift0_c8.c
+++ b/libgfortran/generated/cshift0_c8.c
@@ -66,8 +66,8 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_8);
+  a_ex = sizeof (GFC_COMPLEX_8);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_COMPLEX_8);
       roffset = sizeof (GFC_COMPLEX_8);
       soffset = sizeof (GFC_COMPLEX_8);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_i1.c b/libgfortran/generated/cshift0_i1.c
index c34a72e8612f..a51dd428b4e3 100644
--- a/libgfortran/generated/cshift0_i1.c
+++ b/libgfortran/generated/cshift0_i1.c
@@ -66,8 +66,8 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_1);
+  a_ex = sizeof (GFC_INTEGER_1);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_INTEGER_1);
       roffset = sizeof (GFC_INTEGER_1);
       soffset = sizeof (GFC_INTEGER_1);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_i16.c b/libgfortran/generated/cshift0_i16.c
index 01b502f5c538..fc617f8b5cc9 100644
--- a/libgfortran/generated/cshift0_i16.c
+++ b/libgfortran/generated/cshift0_i16.c
@@ -66,8 +66,8 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_16);
+  a_ex = sizeof (GFC_INTEGER_16);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_INTEGER_16);
       roffset = sizeof (GFC_INTEGER_16);
       soffset = sizeof (GFC_INTEGER_16);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_i2.c b/libgfortran/generated/cshift0_i2.c
index 743cb6ececda..6d0318b78ab0 100644
--- a/libgfortran/generated/cshift0_i2.c
+++ b/libgfortran/generated/cshift0_i2.c
@@ -66,8 +66,8 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_2);
+  a_ex = sizeof (GFC_INTEGER_2);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_INTEGER_2);
       roffset = sizeof (GFC_INTEGER_2);
       soffset = sizeof (GFC_INTEGER_2);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_i4.c b/libgfortran/generated/cshift0_i4.c
index ccd1d2424a25..651a204d3ff3 100644
--- a/libgfortran/generated/cshift0_i4.c
+++ b/libgfortran/generated/cshift0_i4.c
@@ -66,8 +66,8 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_4);
+  a_ex = sizeof (GFC_INTEGER_4);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_INTEGER_4);
       roffset = sizeof (GFC_INTEGER_4);
       soffset = sizeof (GFC_INTEGER_4);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_i8.c b/libgfortran/generated/cshift0_i8.c
index defbb1149c08..46228c2e26e5 100644
--- a/libgfortran/generated/cshift0_i8.c
+++ b/libgfortran/generated/cshift0_i8.c
@@ -66,8 +66,8 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_8);
+  a_ex = sizeof (GFC_INTEGER_8);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_INTEGER_8);
       roffset = sizeof (GFC_INTEGER_8);
       soffset = sizeof (GFC_INTEGER_8);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_r10.c b/libgfortran/generated/cshift0_r10.c
index f40e42627e9e..20d959ed3877 100644
--- a/libgfortran/generated/cshift0_r10.c
+++ b/libgfortran/generated/cshift0_r10.c
@@ -66,8 +66,8 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_10);
+  a_ex = sizeof (GFC_REAL_10);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_REAL_10);
       roffset = sizeof (GFC_REAL_10);
       soffset = sizeof (GFC_REAL_10);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_r16.c b/libgfortran/generated/cshift0_r16.c
index cbd98f3e44fd..899ebe7dbdd0 100644
--- a/libgfortran/generated/cshift0_r16.c
+++ b/libgfortran/generated/cshift0_r16.c
@@ -66,8 +66,8 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_16);
+  a_ex = sizeof (GFC_REAL_16);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_REAL_16);
       roffset = sizeof (GFC_REAL_16);
       soffset = sizeof (GFC_REAL_16);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_r17.c b/libgfortran/generated/cshift0_r17.c
index a854dffc68c7..af2b5abfcd20 100644
--- a/libgfortran/generated/cshift0_r17.c
+++ b/libgfortran/generated/cshift0_r17.c
@@ -66,8 +66,8 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_17);
+  a_ex = sizeof (GFC_REAL_17);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_REAL_17);
       roffset = sizeof (GFC_REAL_17);
       soffset = sizeof (GFC_REAL_17);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_r4.c b/libgfortran/generated/cshift0_r4.c
index cb4b93062dad..b1de8af97d17 100644
--- a/libgfortran/generated/cshift0_r4.c
+++ b/libgfortran/generated/cshift0_r4.c
@@ -66,8 +66,8 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_4);
+  a_ex = sizeof (GFC_REAL_4);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_REAL_4);
       roffset = sizeof (GFC_REAL_4);
       soffset = sizeof (GFC_REAL_4);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/cshift0_r8.c b/libgfortran/generated/cshift0_r8.c
index 8f5a67bffcc6..51accae7cecc 100644
--- a/libgfortran/generated/cshift0_r8.c
+++ b/libgfortran/generated/cshift0_r8.c
@@ -66,8 +66,8 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_8);
+  a_ex = sizeof (GFC_REAL_8);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -115,9 +115,9 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
       rstride[0] = sizeof (GFC_REAL_8);
       roffset = sizeof (GFC_REAL_8);
       soffset = sizeof (GFC_REAL_8);
-      len = GFC_DESCRIPTOR_STRIDE(array, which)
-	* GFC_DESCRIPTOR_EXTENT(array, which);      
-      shift *= GFC_DESCRIPTOR_STRIDE(array, which);
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
 	{
 	  count[n] = 0;
diff --git a/libgfortran/generated/matmul_c10.c b/libgfortran/generated/matmul_c10.c
index f5c298aa0c4f..a5b9493b3f61 100644
--- a/libgfortran/generated/matmul_c10.c
+++ b/libgfortran/generated/matmul_c10.c
@@ -92,7 +92,7 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_c10_avx (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_c10_avx2 (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_c10_avx512f (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_c10_vanilla (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_c10 (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_c16.c b/libgfortran/generated/matmul_c16.c
index 8d592540b553..bbe80e3ba462 100644
--- a/libgfortran/generated/matmul_c16.c
+++ b/libgfortran/generated/matmul_c16.c
@@ -92,7 +92,7 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_c16_avx (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_c16_avx2 (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_c16_avx512f (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_c16_vanilla (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_c16 (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_c17.c b/libgfortran/generated/matmul_c17.c
index 47b76385fb67..dd83147774f4 100644
--- a/libgfortran/generated/matmul_c17.c
+++ b/libgfortran/generated/matmul_c17.c
@@ -92,7 +92,7 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_c17_avx (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_c17_avx2 (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_c17_avx512f (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_c17_vanilla (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_c17 (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_c4.c b/libgfortran/generated/matmul_c4.c
index afb9f4f1473d..eecad1f8e0af 100644
--- a/libgfortran/generated/matmul_c4.c
+++ b/libgfortran/generated/matmul_c4.c
@@ -92,7 +92,7 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_c4_avx (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_c4_avx2 (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_c4_avx512f (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_c4_vanilla (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_c4 (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_c8.c b/libgfortran/generated/matmul_c8.c
index bc37144bfbbd..71ced811798c 100644
--- a/libgfortran/generated/matmul_c8.c
+++ b/libgfortran/generated/matmul_c8.c
@@ -92,7 +92,7 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_c8_avx (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_c8_avx2 (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_c8_avx512f (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_c8_vanilla (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_i1.c b/libgfortran/generated/matmul_i1.c
index 2b45d14eeb19..ea47cda8257e 100644
--- a/libgfortran/generated/matmul_i1.c
+++ b/libgfortran/generated/matmul_i1.c
@@ -92,7 +92,7 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
   const GFC_UINTEGER_1 * restrict bbase;
   GFC_UINTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && axstride_bytes == sizeof (GFC_UINTEGER_1)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_i1_avx (gfc_array_m1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
   const GFC_UINTEGER_1 * restrict bbase;
   GFC_UINTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && axstride_bytes == sizeof (GFC_UINTEGER_1)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_i1_avx2 (gfc_array_m1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
   const GFC_UINTEGER_1 * restrict bbase;
   GFC_UINTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && axstride_bytes == sizeof (GFC_UINTEGER_1)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_i1_avx512f (gfc_array_m1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
   const GFC_UINTEGER_1 * restrict bbase;
   GFC_UINTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && axstride_bytes == sizeof (GFC_UINTEGER_1)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_i1_vanilla (gfc_array_m1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
   const GFC_UINTEGER_1 * restrict bbase;
   GFC_UINTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_1)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+      && axstride_bytes == sizeof (GFC_UINTEGER_1)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_1)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_i1 (gfc_array_m1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_i16.c b/libgfortran/generated/matmul_i16.c
index aedf424f933f..7518a890ea17 100644
--- a/libgfortran/generated/matmul_i16.c
+++ b/libgfortran/generated/matmul_i16.c
@@ -92,7 +92,7 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
   const GFC_UINTEGER_16 * restrict bbase;
   GFC_UINTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && axstride_bytes == sizeof (GFC_UINTEGER_16)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_i16_avx (gfc_array_m16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
   const GFC_UINTEGER_16 * restrict bbase;
   GFC_UINTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && axstride_bytes == sizeof (GFC_UINTEGER_16)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_i16_avx2 (gfc_array_m16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
   const GFC_UINTEGER_16 * restrict bbase;
   GFC_UINTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && axstride_bytes == sizeof (GFC_UINTEGER_16)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_i16_avx512f (gfc_array_m16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
   const GFC_UINTEGER_16 * restrict bbase;
   GFC_UINTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && axstride_bytes == sizeof (GFC_UINTEGER_16)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_i16_vanilla (gfc_array_m16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
   const GFC_UINTEGER_16 * restrict bbase;
   GFC_UINTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_16)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+      && axstride_bytes == sizeof (GFC_UINTEGER_16)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_16)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_i16 (gfc_array_m16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_i2.c b/libgfortran/generated/matmul_i2.c
index 2dc463c6ff67..81cbd11362d3 100644
--- a/libgfortran/generated/matmul_i2.c
+++ b/libgfortran/generated/matmul_i2.c
@@ -92,7 +92,7 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
   const GFC_UINTEGER_2 * restrict bbase;
   GFC_UINTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && axstride_bytes == sizeof (GFC_UINTEGER_2)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_i2_avx (gfc_array_m2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
   const GFC_UINTEGER_2 * restrict bbase;
   GFC_UINTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && axstride_bytes == sizeof (GFC_UINTEGER_2)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_i2_avx2 (gfc_array_m2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
   const GFC_UINTEGER_2 * restrict bbase;
   GFC_UINTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && axstride_bytes == sizeof (GFC_UINTEGER_2)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_i2_avx512f (gfc_array_m2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
   const GFC_UINTEGER_2 * restrict bbase;
   GFC_UINTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && axstride_bytes == sizeof (GFC_UINTEGER_2)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_i2_vanilla (gfc_array_m2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
   const GFC_UINTEGER_2 * restrict bbase;
   GFC_UINTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_2)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+      && axstride_bytes == sizeof (GFC_UINTEGER_2)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_2)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_i2 (gfc_array_m2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_i4.c b/libgfortran/generated/matmul_i4.c
index ca9b2dc41d7d..cc6ab5fe326c 100644
--- a/libgfortran/generated/matmul_i4.c
+++ b/libgfortran/generated/matmul_i4.c
@@ -92,7 +92,7 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
   const GFC_UINTEGER_4 * restrict bbase;
   GFC_UINTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && axstride_bytes == sizeof (GFC_UINTEGER_4)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_i4_avx (gfc_array_m4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
   const GFC_UINTEGER_4 * restrict bbase;
   GFC_UINTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && axstride_bytes == sizeof (GFC_UINTEGER_4)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_i4_avx2 (gfc_array_m4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
   const GFC_UINTEGER_4 * restrict bbase;
   GFC_UINTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && axstride_bytes == sizeof (GFC_UINTEGER_4)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_i4_avx512f (gfc_array_m4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
   const GFC_UINTEGER_4 * restrict bbase;
   GFC_UINTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && axstride_bytes == sizeof (GFC_UINTEGER_4)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_i4_vanilla (gfc_array_m4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
   const GFC_UINTEGER_4 * restrict bbase;
   GFC_UINTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_4)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+      && axstride_bytes == sizeof (GFC_UINTEGER_4)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_4)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_i4 (gfc_array_m4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_i8.c b/libgfortran/generated/matmul_i8.c
index a8da3826b658..a5e8f39b8327 100644
--- a/libgfortran/generated/matmul_i8.c
+++ b/libgfortran/generated/matmul_i8.c
@@ -92,7 +92,7 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
   const GFC_UINTEGER_8 * restrict bbase;
   GFC_UINTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && axstride_bytes == sizeof (GFC_UINTEGER_8)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_i8_avx (gfc_array_m8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
   const GFC_UINTEGER_8 * restrict bbase;
   GFC_UINTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && axstride_bytes == sizeof (GFC_UINTEGER_8)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_i8_avx2 (gfc_array_m8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
   const GFC_UINTEGER_8 * restrict bbase;
   GFC_UINTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && axstride_bytes == sizeof (GFC_UINTEGER_8)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_i8_avx512f (gfc_array_m8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
   const GFC_UINTEGER_8 * restrict bbase;
   GFC_UINTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && axstride_bytes == sizeof (GFC_UINTEGER_8)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_i8_vanilla (gfc_array_m8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
   const GFC_UINTEGER_8 * restrict bbase;
   GFC_UINTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && (axstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || aystride_bytes == sizeof (GFC_UINTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_UINTEGER_8)
+	  || bystride_bytes == sizeof (GFC_UINTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_UINTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_UINTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_UINTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_UINTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+      && axstride_bytes == sizeof (GFC_UINTEGER_8)
+      && bxstride_bytes == sizeof (GFC_UINTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_UINTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_UINTEGER_8)
+	   && aystride_bytes == sizeof (GFC_UINTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_UINTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_i8 (gfc_array_m8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_r10.c b/libgfortran/generated/matmul_r10.c
index 5f3cc97cbf21..b16c0a9aa16e 100644
--- a/libgfortran/generated/matmul_r10.c
+++ b/libgfortran/generated/matmul_r10.c
@@ -92,7 +92,7 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_r10_avx (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_r10_avx2 (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_r10_avx512f (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_r10_vanilla (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_r10 (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_r16.c b/libgfortran/generated/matmul_r16.c
index 43d7cf4d5140..b58d4d6f28c7 100644
--- a/libgfortran/generated/matmul_r16.c
+++ b/libgfortran/generated/matmul_r16.c
@@ -92,7 +92,7 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_r16_avx (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_r16_avx2 (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_r16_avx512f (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_r16_vanilla (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_r16 (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_r17.c b/libgfortran/generated/matmul_r17.c
index dc08ed149ef4..3012bd00664e 100644
--- a/libgfortran/generated/matmul_r17.c
+++ b/libgfortran/generated/matmul_r17.c
@@ -92,7 +92,7 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_r17_avx (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_r17_avx2 (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_r17_avx512f (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_r17_vanilla (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_r17 (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_r4.c b/libgfortran/generated/matmul_r4.c
index ee36b1ec6d0d..8fcdbe835f6c 100644
--- a/libgfortran/generated/matmul_r4.c
+++ b/libgfortran/generated/matmul_r4.c
@@ -92,7 +92,7 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_r4_avx (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_r4_avx2 (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_r4_avx512f (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_r4_vanilla (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_r4 (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmul_r8.c b/libgfortran/generated/matmul_r8.c
index c67dcc9b7617..8a380faab732 100644
--- a/libgfortran/generated/matmul_r8.c
+++ b/libgfortran/generated/matmul_r8.c
@@ -92,7 +92,7 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -183,12 +183,11 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -257,15 +256,19 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -274,12 +277,12 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -288,7 +291,9 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -341,7 +346,7 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -567,7 +572,9 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -620,7 +627,7 @@ matmul_r8_avx (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -677,7 +684,7 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -768,12 +775,11 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -842,15 +848,19 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -859,12 +869,12 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -873,7 +883,9 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -926,7 +938,7 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1152,7 +1164,9 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1205,7 +1219,7 @@ matmul_r8_avx2 (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1262,7 +1276,7 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1353,12 +1367,11 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -1427,15 +1440,19 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -1444,12 +1461,12 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -1458,7 +1475,9 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -1511,7 +1530,7 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1737,7 +1756,9 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1790,7 +1811,7 @@ matmul_r8_avx512f (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -1861,7 +1882,7 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -1952,12 +1973,11 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2026,15 +2046,19 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2043,12 +2067,12 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2057,7 +2081,9 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2110,7 +2136,7 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2336,7 +2362,9 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -2389,7 +2417,7 @@ matmul_r8_vanilla (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -2519,7 +2547,7 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -2610,12 +2638,11 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -2684,15 +2711,19 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -2701,12 +2732,12 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -2715,7 +2746,9 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -2768,7 +2801,7 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -2994,7 +3027,9 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -3047,7 +3082,7 @@ matmul_r8 (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_c10.c b/libgfortran/generated/matmulavx128_c10.c
index 3df3a43a59bb..5b4b5a47ceea 100644
--- a/libgfortran/generated/matmulavx128_c10.c
+++ b/libgfortran/generated/matmulavx128_c10.c
@@ -57,7 +57,7 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_c10_avx128_fma3 (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
   const GFC_COMPLEX_10 * restrict bbase;
   GFC_COMPLEX_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_10))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_10)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+      && axstride_bytes == sizeof (GFC_COMPLEX_10)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_10)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_10)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_c10_avx128_fma4 (gfc_array_c10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_c16.c b/libgfortran/generated/matmulavx128_c16.c
index 11263fa2d3d3..31804fad9f43 100644
--- a/libgfortran/generated/matmulavx128_c16.c
+++ b/libgfortran/generated/matmulavx128_c16.c
@@ -57,7 +57,7 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_c16_avx128_fma3 (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
   const GFC_COMPLEX_16 * restrict bbase;
   GFC_COMPLEX_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_16))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_16)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+      && axstride_bytes == sizeof (GFC_COMPLEX_16)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_16)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_16)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_c16_avx128_fma4 (gfc_array_c16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_c17.c b/libgfortran/generated/matmulavx128_c17.c
index 8a6957200827..bee088707672 100644
--- a/libgfortran/generated/matmulavx128_c17.c
+++ b/libgfortran/generated/matmulavx128_c17.c
@@ -57,7 +57,7 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_c17_avx128_fma3 (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
   const GFC_COMPLEX_17 * restrict bbase;
   GFC_COMPLEX_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_17))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_17)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+      && axstride_bytes == sizeof (GFC_COMPLEX_17)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_17)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_17)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_c17_avx128_fma4 (gfc_array_c17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_c4.c b/libgfortran/generated/matmulavx128_c4.c
index 2d47cc7f6041..c27a4e976db6 100644
--- a/libgfortran/generated/matmulavx128_c4.c
+++ b/libgfortran/generated/matmulavx128_c4.c
@@ -57,7 +57,7 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_c4_avx128_fma3 (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
   const GFC_COMPLEX_4 * restrict bbase;
   GFC_COMPLEX_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_4))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_4)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+      && axstride_bytes == sizeof (GFC_COMPLEX_4)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_4)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_4)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_c4_avx128_fma4 (gfc_array_c4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_c8.c b/libgfortran/generated/matmulavx128_c8.c
index 61c19042e8b5..fe7194e28946 100644
--- a/libgfortran/generated/matmulavx128_c8.c
+++ b/libgfortran/generated/matmulavx128_c8.c
@@ -57,7 +57,7 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_c8_avx128_fma3 (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
   const GFC_COMPLEX_8 * restrict bbase;
   GFC_COMPLEX_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && (axstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || aystride_bytes == sizeof (GFC_COMPLEX_8))
+      && (bxstride_bytes == sizeof (GFC_COMPLEX_8)
+	  || bystride_bytes == sizeof (GFC_COMPLEX_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_COMPLEX_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_COMPLEX_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_COMPLEX_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_COMPLEX_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+      && axstride_bytes == sizeof (GFC_COMPLEX_8)
+      && bxstride_bytes == sizeof (GFC_COMPLEX_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_COMPLEX_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_COMPLEX_8)
+	   && aystride_bytes == sizeof (GFC_COMPLEX_8)
+	   && bxstride_bytes == sizeof (GFC_COMPLEX_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_c8_avx128_fma4 (gfc_array_c8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_i1.c b/libgfortran/generated/matmulavx128_i1.c
index 5714c7135741..2d56cdbe38f8 100644
--- a/libgfortran/generated/matmulavx128_i1.c
+++ b/libgfortran/generated/matmulavx128_i1.c
@@ -57,7 +57,7 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
   const GFC_INTEGER_1 * restrict bbase;
   GFC_INTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_1)
+      && (axstride_bytes == sizeof (GFC_INTEGER_1)
+	  || aystride_bytes == sizeof (GFC_INTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_1)
+	  || bystride_bytes == sizeof (GFC_INTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_1)
+      && axstride_bytes == sizeof (GFC_INTEGER_1)
+      && bxstride_bytes == sizeof (GFC_INTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_1)
+	   && aystride_bytes == sizeof (GFC_INTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_i1_avx128_fma3 (gfc_array_i1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
   const GFC_INTEGER_1 * restrict bbase;
   GFC_INTEGER_1 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_1)
+      && (axstride_bytes == sizeof (GFC_INTEGER_1)
+	  || aystride_bytes == sizeof (GFC_INTEGER_1))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_1)
+	  || bystride_bytes == sizeof (GFC_INTEGER_1))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_1 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_1)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_1)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_1) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_1) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_1)
+      && axstride_bytes == sizeof (GFC_INTEGER_1)
+      && bxstride_bytes == sizeof (GFC_INTEGER_1)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_1))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_1)
+	   && aystride_bytes == sizeof (GFC_INTEGER_1)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_1))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_i1_avx128_fma4 (gfc_array_i1 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_i16.c b/libgfortran/generated/matmulavx128_i16.c
index 5284b8dc473b..f6d19d2bafd3 100644
--- a/libgfortran/generated/matmulavx128_i16.c
+++ b/libgfortran/generated/matmulavx128_i16.c
@@ -57,7 +57,7 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
   const GFC_INTEGER_16 * restrict bbase;
   GFC_INTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_16)
+      && (axstride_bytes == sizeof (GFC_INTEGER_16)
+	  || aystride_bytes == sizeof (GFC_INTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_16)
+	  || bystride_bytes == sizeof (GFC_INTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_16)
+      && axstride_bytes == sizeof (GFC_INTEGER_16)
+      && bxstride_bytes == sizeof (GFC_INTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_16)
+	   && aystride_bytes == sizeof (GFC_INTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_i16_avx128_fma3 (gfc_array_i16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
   const GFC_INTEGER_16 * restrict bbase;
   GFC_INTEGER_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_16)
+      && (axstride_bytes == sizeof (GFC_INTEGER_16)
+	  || aystride_bytes == sizeof (GFC_INTEGER_16))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_16)
+	  || bystride_bytes == sizeof (GFC_INTEGER_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_16)
+      && axstride_bytes == sizeof (GFC_INTEGER_16)
+      && bxstride_bytes == sizeof (GFC_INTEGER_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_16)
+	   && aystride_bytes == sizeof (GFC_INTEGER_16)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_i16_avx128_fma4 (gfc_array_i16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_i2.c b/libgfortran/generated/matmulavx128_i2.c
index 89b20f113488..9b227d3f9d03 100644
--- a/libgfortran/generated/matmulavx128_i2.c
+++ b/libgfortran/generated/matmulavx128_i2.c
@@ -57,7 +57,7 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
   const GFC_INTEGER_2 * restrict bbase;
   GFC_INTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_2)
+      && (axstride_bytes == sizeof (GFC_INTEGER_2)
+	  || aystride_bytes == sizeof (GFC_INTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_2)
+	  || bystride_bytes == sizeof (GFC_INTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_2)
+      && axstride_bytes == sizeof (GFC_INTEGER_2)
+      && bxstride_bytes == sizeof (GFC_INTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_2)
+	   && aystride_bytes == sizeof (GFC_INTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_i2_avx128_fma3 (gfc_array_i2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
   const GFC_INTEGER_2 * restrict bbase;
   GFC_INTEGER_2 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_2)
+      && (axstride_bytes == sizeof (GFC_INTEGER_2)
+	  || aystride_bytes == sizeof (GFC_INTEGER_2))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_2)
+	  || bystride_bytes == sizeof (GFC_INTEGER_2))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_2 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_2)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_2)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_2) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_2) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_2)
+      && axstride_bytes == sizeof (GFC_INTEGER_2)
+      && bxstride_bytes == sizeof (GFC_INTEGER_2)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_2))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_2)
+	   && aystride_bytes == sizeof (GFC_INTEGER_2)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_2))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_i2_avx128_fma4 (gfc_array_i2 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_i4.c b/libgfortran/generated/matmulavx128_i4.c
index c0cca1c99763..fec48e870ac3 100644
--- a/libgfortran/generated/matmulavx128_i4.c
+++ b/libgfortran/generated/matmulavx128_i4.c
@@ -57,7 +57,7 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
   const GFC_INTEGER_4 * restrict bbase;
   GFC_INTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_4)
+      && (axstride_bytes == sizeof (GFC_INTEGER_4)
+	  || aystride_bytes == sizeof (GFC_INTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_4)
+	  || bystride_bytes == sizeof (GFC_INTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_4)
+      && axstride_bytes == sizeof (GFC_INTEGER_4)
+      && bxstride_bytes == sizeof (GFC_INTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_4)
+	   && aystride_bytes == sizeof (GFC_INTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_i4_avx128_fma3 (gfc_array_i4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
   const GFC_INTEGER_4 * restrict bbase;
   GFC_INTEGER_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_4)
+      && (axstride_bytes == sizeof (GFC_INTEGER_4)
+	  || aystride_bytes == sizeof (GFC_INTEGER_4))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_4)
+	  || bystride_bytes == sizeof (GFC_INTEGER_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_4)
+      && axstride_bytes == sizeof (GFC_INTEGER_4)
+      && bxstride_bytes == sizeof (GFC_INTEGER_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_4)
+	   && aystride_bytes == sizeof (GFC_INTEGER_4)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_i4_avx128_fma4 (gfc_array_i4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_i8.c b/libgfortran/generated/matmulavx128_i8.c
index 42804639645f..74f7b5c96aa8 100644
--- a/libgfortran/generated/matmulavx128_i8.c
+++ b/libgfortran/generated/matmulavx128_i8.c
@@ -57,7 +57,7 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
   const GFC_INTEGER_8 * restrict bbase;
   GFC_INTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_8)
+      && (axstride_bytes == sizeof (GFC_INTEGER_8)
+	  || aystride_bytes == sizeof (GFC_INTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_8)
+	  || bystride_bytes == sizeof (GFC_INTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_8)
+      && axstride_bytes == sizeof (GFC_INTEGER_8)
+      && bxstride_bytes == sizeof (GFC_INTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_8)
+	   && aystride_bytes == sizeof (GFC_INTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_i8_avx128_fma3 (gfc_array_i8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
   const GFC_INTEGER_8 * restrict bbase;
   GFC_INTEGER_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_INTEGER_8)
+      && (axstride_bytes == sizeof (GFC_INTEGER_8)
+	  || aystride_bytes == sizeof (GFC_INTEGER_8))
+      && (bxstride_bytes == sizeof (GFC_INTEGER_8)
+	  || bystride_bytes == sizeof (GFC_INTEGER_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_INTEGER_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_INTEGER_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_INTEGER_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_INTEGER_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_INTEGER_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_INTEGER_8)
+      && axstride_bytes == sizeof (GFC_INTEGER_8)
+      && bxstride_bytes == sizeof (GFC_INTEGER_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_INTEGER_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_INTEGER_8)
+	   && aystride_bytes == sizeof (GFC_INTEGER_8)
+	   && bxstride_bytes == sizeof (GFC_INTEGER_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_i8_avx128_fma4 (gfc_array_i8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_r10.c b/libgfortran/generated/matmulavx128_r10.c
index 5ff63cdb3073..67f6d40c1aab 100644
--- a/libgfortran/generated/matmulavx128_r10.c
+++ b/libgfortran/generated/matmulavx128_r10.c
@@ -57,7 +57,7 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_r10_avx128_fma3 (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
   const GFC_REAL_10 * restrict bbase;
   GFC_REAL_10 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_10)
+      && (axstride_bytes == sizeof (GFC_REAL_10)
+	  || aystride_bytes == sizeof (GFC_REAL_10))
+      && (bxstride_bytes == sizeof (GFC_REAL_10)
+	  || bystride_bytes == sizeof (GFC_REAL_10))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_10 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_10)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_10)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_10) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_10)
+      && axstride_bytes == sizeof (GFC_REAL_10)
+      && bxstride_bytes == sizeof (GFC_REAL_10)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_10))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_10)
+	   && aystride_bytes == sizeof (GFC_REAL_10)
+	   && bxstride_bytes == sizeof (GFC_REAL_10))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_r10_avx128_fma4 (gfc_array_r10 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_r16.c b/libgfortran/generated/matmulavx128_r16.c
index ff70ee9e5f54..e3e4332013e3 100644
--- a/libgfortran/generated/matmulavx128_r16.c
+++ b/libgfortran/generated/matmulavx128_r16.c
@@ -57,7 +57,7 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_r16_avx128_fma3 (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
   const GFC_REAL_16 * restrict bbase;
   GFC_REAL_16 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_16)
+      && (axstride_bytes == sizeof (GFC_REAL_16)
+	  || aystride_bytes == sizeof (GFC_REAL_16))
+      && (bxstride_bytes == sizeof (GFC_REAL_16)
+	  || bystride_bytes == sizeof (GFC_REAL_16))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_16 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_16)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_16)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_16) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_16)
+      && axstride_bytes == sizeof (GFC_REAL_16)
+      && bxstride_bytes == sizeof (GFC_REAL_16)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_16))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_16)
+	   && aystride_bytes == sizeof (GFC_REAL_16)
+	   && bxstride_bytes == sizeof (GFC_REAL_16))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_r16_avx128_fma4 (gfc_array_r16 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_r17.c b/libgfortran/generated/matmulavx128_r17.c
index cd2f65c6f29f..ee71b6220b7b 100644
--- a/libgfortran/generated/matmulavx128_r17.c
+++ b/libgfortran/generated/matmulavx128_r17.c
@@ -57,7 +57,7 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_r17_avx128_fma3 (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
   const GFC_REAL_17 * restrict bbase;
   GFC_REAL_17 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_17)
+      && (axstride_bytes == sizeof (GFC_REAL_17)
+	  || aystride_bytes == sizeof (GFC_REAL_17))
+      && (bxstride_bytes == sizeof (GFC_REAL_17)
+	  || bystride_bytes == sizeof (GFC_REAL_17))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_17 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_17)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_17)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_17) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_17)
+      && axstride_bytes == sizeof (GFC_REAL_17)
+      && bxstride_bytes == sizeof (GFC_REAL_17)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_17))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_17)
+	   && aystride_bytes == sizeof (GFC_REAL_17)
+	   && bxstride_bytes == sizeof (GFC_REAL_17))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_r17_avx128_fma4 (gfc_array_r17 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_r4.c b/libgfortran/generated/matmulavx128_r4.c
index 69e134393422..7ad51ca099b7 100644
--- a/libgfortran/generated/matmulavx128_r4.c
+++ b/libgfortran/generated/matmulavx128_r4.c
@@ -57,7 +57,7 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_r4_avx128_fma3 (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
   const GFC_REAL_4 * restrict bbase;
   GFC_REAL_4 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_4)
+      && (axstride_bytes == sizeof (GFC_REAL_4)
+	  || aystride_bytes == sizeof (GFC_REAL_4))
+      && (bxstride_bytes == sizeof (GFC_REAL_4)
+	  || bystride_bytes == sizeof (GFC_REAL_4))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_4 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_4)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_4)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_4) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_4)
+      && axstride_bytes == sizeof (GFC_REAL_4)
+      && bxstride_bytes == sizeof (GFC_REAL_4)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_4))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_4)
+	   && aystride_bytes == sizeof (GFC_REAL_4)
+	   && bxstride_bytes == sizeof (GFC_REAL_4))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_r4_avx128_fma4 (gfc_array_r4 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/matmulavx128_r8.c b/libgfortran/generated/matmulavx128_r8.c
index bf998c4ae459..659d271d8531 100644
--- a/libgfortran/generated/matmulavx128_r8.c
+++ b/libgfortran/generated/matmulavx128_r8.c
@@ -57,7 +57,7 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -148,12 +148,11 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -222,15 +221,19 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -239,12 +242,12 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -253,7 +256,9 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -306,7 +311,7 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -532,7 +537,9 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -585,7 +592,7 @@ matmul_r8_avx128_fma3 (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
@@ -643,7 +650,7 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
   const GFC_REAL_8 * restrict bbase;
   GFC_REAL_8 * restrict dest;
 
-  index_type rxstride, rystride, axstride, aystride, bxstride, bystride;
+  index_type rystride, axstride, aystride, bxstride, bystride;
   index_type x, y, n, count, xcount, ycount;
   index_type axstride_bytes, aystride_bytes, bxstride_bytes, bystride_bytes,
 	     rxstride_bytes, rystride_bytes;
@@ -734,12 +741,11 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rxstride_bytes = rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
     }
   else
     {
-      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
       rxstride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,0);
       rystride_bytes = GFC_DESCRIPTOR_STRIDE_BYTES(retarray,1);
@@ -808,15 +814,19 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 #define max(a,b) ((a) >= (b) ? (a) : (b))
 
-  if (try_blas && rxstride == 1 && (axstride == 1 || aystride == 1)
-      && (bxstride == 1 || bystride == 1)
+  if (try_blas
+      && rxstride_bytes == sizeof (GFC_REAL_8)
+      && (axstride_bytes == sizeof (GFC_REAL_8)
+	  || aystride_bytes == sizeof (GFC_REAL_8))
+      && (bxstride_bytes == sizeof (GFC_REAL_8)
+	  || bystride_bytes == sizeof (GFC_REAL_8))
       && (((float) xcount) * ((float) ycount) * ((float) count)
           > POW3(blas_limit)))
     {
       const int m = xcount, n = ycount, k = count, ldc = rystride;
       const GFC_REAL_8 one = 1, zero = 0;
-      const int lda = (axstride == 1) ? aystride : axstride,
-		ldb = (bxstride == 1) ? bystride : bxstride;
+      const int lda = (axstride_bytes == sizeof (GFC_REAL_8)) ? aystride : axstride,
+		ldb = (bxstride_bytes == sizeof (GFC_REAL_8)) ? bystride : bxstride;
 
       if (lda > 0 && ldb > 0 && ldc > 0 && m > 1 && n > 1 && k > 1)
 	{
@@ -825,12 +835,12 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
 	  if (try_blas & 2)
 	    transa = "C";
 	  else
-	    transa = axstride == 1 ? "N" : "T";
+	    transa = axstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  if (try_blas & 4)
 	    transb = "C";
 	  else
-	    transb = bxstride == 1 ? "N" : "T";
+	    transb = bxstride_bytes == sizeof (GFC_REAL_8) ? "N" : "T";
 
 	  gemm (transa, transb , &m,
 		&n, &k,	&one, abase, &lda, bbase, &ldb, &zero, dest,
@@ -839,7 +849,9 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
 	}
     }
 
-  if (rxstride == 1 && axstride == 1 && bxstride == 1
+  if (rxstride_bytes == sizeof (GFC_REAL_8)
+      && axstride_bytes == sizeof (GFC_REAL_8)
+      && bxstride_bytes == sizeof (GFC_REAL_8)
       && GFC_DESCRIPTOR_RANK (b) != 1)
     {
       /* This block of code implements a tuned matmul, derived from
@@ -892,7 +904,7 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
 
       /* Adjust size of t1 to what is needed.  */
       index_type t1_dim, a_sz;
-      if (aystride == 1)
+      if (aystride_bytes == sizeof (GFC_REAL_8))
         a_sz = rystride;
       else
         a_sz = a_dim1;
@@ -1118,7 +1130,9 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
 #undef B_ARRAY_ELEM
 #undef C_ARRAY_ELEM
     }
-  else if (rxstride == 1 && aystride == 1 && bxstride == 1)
+  else if (rxstride_bytes == sizeof (GFC_REAL_8)
+	   && aystride_bytes == sizeof (GFC_REAL_8)
+	   && bxstride_bytes == sizeof (GFC_REAL_8))
     {
       if (GFC_DESCRIPTOR_RANK (a) != 1)
 	{
@@ -1171,7 +1185,7 @@ matmul_r8_avx128_fma4 (gfc_array_r8 * const restrict retarray,
 	  GFC_DESCRIPTOR1_ELEM (retarray, y) = s;
 	}
     }
-  else if (axstride < aystride)
+  else if (axstride_bytes < aystride_bytes)
     {
       for (y = 0; y < ycount; y++)
 	for (x = 0; x < xcount; x++)
diff --git a/libgfortran/generated/spread_c10.c b/libgfortran/generated/spread_c10.c
index 7a777048bbc7..01d465b4db73 100644
--- a/libgfortran/generated/spread_c10.c
+++ b/libgfortran/generated/spread_c10.c
@@ -249,8 +249,7 @@ spread_scalar_c10 (gfc_array_c10 *ret, const GFC_COMPLEX_10 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_c16.c b/libgfortran/generated/spread_c16.c
index ab450da2ed13..502611000bb0 100644
--- a/libgfortran/generated/spread_c16.c
+++ b/libgfortran/generated/spread_c16.c
@@ -249,8 +249,7 @@ spread_scalar_c16 (gfc_array_c16 *ret, const GFC_COMPLEX_16 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_c17.c b/libgfortran/generated/spread_c17.c
index 1d540c0f6051..786aef884b8e 100644
--- a/libgfortran/generated/spread_c17.c
+++ b/libgfortran/generated/spread_c17.c
@@ -249,8 +249,7 @@ spread_scalar_c17 (gfc_array_c17 *ret, const GFC_COMPLEX_17 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_c4.c b/libgfortran/generated/spread_c4.c
index 9a333df04a76..e262bcadc6fb 100644
--- a/libgfortran/generated/spread_c4.c
+++ b/libgfortran/generated/spread_c4.c
@@ -249,8 +249,7 @@ spread_scalar_c4 (gfc_array_c4 *ret, const GFC_COMPLEX_4 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_c8.c b/libgfortran/generated/spread_c8.c
index d9822252cfa7..184d08a67982 100644
--- a/libgfortran/generated/spread_c8.c
+++ b/libgfortran/generated/spread_c8.c
@@ -249,8 +249,7 @@ spread_scalar_c8 (gfc_array_c8 *ret, const GFC_COMPLEX_8 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_i1.c b/libgfortran/generated/spread_i1.c
index 529dbef46cee..9ce6ad71fdcc 100644
--- a/libgfortran/generated/spread_i1.c
+++ b/libgfortran/generated/spread_i1.c
@@ -249,8 +249,7 @@ spread_scalar_i1 (gfc_array_i1 *ret, const GFC_INTEGER_1 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_i16.c b/libgfortran/generated/spread_i16.c
index e3b34ccdd6c1..f9085d3f8311 100644
--- a/libgfortran/generated/spread_i16.c
+++ b/libgfortran/generated/spread_i16.c
@@ -249,8 +249,7 @@ spread_scalar_i16 (gfc_array_i16 *ret, const GFC_INTEGER_16 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_i2.c b/libgfortran/generated/spread_i2.c
index 1315d5e9b643..7964b2a6b54e 100644
--- a/libgfortran/generated/spread_i2.c
+++ b/libgfortran/generated/spread_i2.c
@@ -249,8 +249,7 @@ spread_scalar_i2 (gfc_array_i2 *ret, const GFC_INTEGER_2 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_i4.c b/libgfortran/generated/spread_i4.c
index fd85417a54c9..2df5fb8dc36a 100644
--- a/libgfortran/generated/spread_i4.c
+++ b/libgfortran/generated/spread_i4.c
@@ -249,8 +249,7 @@ spread_scalar_i4 (gfc_array_i4 *ret, const GFC_INTEGER_4 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_i8.c b/libgfortran/generated/spread_i8.c
index 711e91d10338..b3980ba0b2bf 100644
--- a/libgfortran/generated/spread_i8.c
+++ b/libgfortran/generated/spread_i8.c
@@ -249,8 +249,7 @@ spread_scalar_i8 (gfc_array_i8 *ret, const GFC_INTEGER_8 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_r10.c b/libgfortran/generated/spread_r10.c
index 33b577aff1ce..b28653243270 100644
--- a/libgfortran/generated/spread_r10.c
+++ b/libgfortran/generated/spread_r10.c
@@ -249,8 +249,7 @@ spread_scalar_r10 (gfc_array_r10 *ret, const GFC_REAL_10 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_r16.c b/libgfortran/generated/spread_r16.c
index 9412e647ed5f..a8505b9f065d 100644
--- a/libgfortran/generated/spread_r16.c
+++ b/libgfortran/generated/spread_r16.c
@@ -249,8 +249,7 @@ spread_scalar_r16 (gfc_array_r16 *ret, const GFC_REAL_16 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_r17.c b/libgfortran/generated/spread_r17.c
index fecc6e735337..c6d546dd01eb 100644
--- a/libgfortran/generated/spread_r17.c
+++ b/libgfortran/generated/spread_r17.c
@@ -249,8 +249,7 @@ spread_scalar_r17 (gfc_array_r17 *ret, const GFC_REAL_17 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_r4.c b/libgfortran/generated/spread_r4.c
index dfe519e59c83..450de41db0c2 100644
--- a/libgfortran/generated/spread_r4.c
+++ b/libgfortran/generated/spread_r4.c
@@ -249,8 +249,7 @@ spread_scalar_r4 (gfc_array_r4 *ret, const GFC_REAL_4 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
diff --git a/libgfortran/generated/spread_r8.c b/libgfortran/generated/spread_r8.c
index ce3274f47c1f..3bf3505ed966 100644
--- a/libgfortran/generated/spread_r8.c
+++ b/libgfortran/generated/spread_r8.c
@@ -249,8 +249,7 @@ spread_scalar_r8 (gfc_array_r8 *ret, const GFC_REAL_8 *source,
     }
   else
     {
-      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
-			   / GFC_DESCRIPTOR_STRIDE(ret,0))
+      if (ncopies > GFC_DESCRIPTOR_EXTENT(ret,0))
 	runtime_error ("dim too large in spread()");
     }


More information about the Gcc-cvs mailing list