diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-10-18 20:15:26 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-10-18 20:15:26 +0200 |
commit | cd6cd6aed195b4ec7d652e8b41d60b60e174304e (patch) | |
tree | 6762feeca0b107bbe4d1a82ac9938a66416214ed /libgfortran/m4 | |
parent | 019e1c85fe968281ce591322b94e828a4ee668c9 (diff) | |
download | gcc-cd6cd6aed195b4ec7d652e8b41d60b60e174304e.zip gcc-cd6cd6aed195b4ec7d652e8b41d60b60e174304e.tar.gz gcc-cd6cd6aed195b4ec7d652e8b41d60b60e174304e.tar.bz2 |
PR libfortran/97063 - Wrong result for vector (step size is negative) * matrix
The MATMUL intrinsic provided a wrong result for rank-1 times rank-2 array
when a negative stride was used for addressing the elements of the rank-1
array, because a check on strides was erroneously placed before the check
on the rank. Interchange order of checks.
libgfortran/ChangeLog:
* m4/matmul_internal.m4: Move check for rank-1 times rank-2 before
checks on strides for rank-2 times rank-2.
* generated/matmul_c10.c: Regenerated.
* generated/matmul_c16.c: Likewise.
* generated/matmul_c4.c: Likewise.
* generated/matmul_c8.c: Likewise.
* generated/matmul_i1.c: Likewise.
* generated/matmul_i16.c: Likewise.
* generated/matmul_i2.c: Likewise.
* generated/matmul_i4.c: Likewise.
* generated/matmul_i8.c: Likewise.
* generated/matmul_r10.c: Likewise.
* generated/matmul_r16.c: Likewise.
* generated/matmul_r4.c: Likewise.
* generated/matmul_r8.c: Likewise.
* generated/matmulavx128_c10.c: Likewise.
* generated/matmulavx128_c16.c: Likewise.
* generated/matmulavx128_c4.c: Likewise.
* generated/matmulavx128_c8.c: Likewise.
* generated/matmulavx128_i1.c: Likewise.
* generated/matmulavx128_i16.c: Likewise.
* generated/matmulavx128_i2.c: Likewise.
* generated/matmulavx128_i4.c: Likewise.
* generated/matmulavx128_i8.c: Likewise.
* generated/matmulavx128_r10.c: Likewise.
* generated/matmulavx128_r16.c: Likewise.
* generated/matmulavx128_r4.c: Likewise.
* generated/matmulavx128_r8.c: Likewise.
gcc/testsuite/ChangeLog:
* gfortran.dg/matmul_20.f90: New test.
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/matmul_internal.m4 | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libgfortran/m4/matmul_internal.m4 b/libgfortran/m4/matmul_internal.m4 index 32a1e01..13fd769 100644 --- a/libgfortran/m4/matmul_internal.m4 +++ b/libgfortran/m4/matmul_internal.m4 @@ -506,20 +506,6 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl } } } - else if (axstride < aystride) - { - for (y = 0; y < ycount; y++) - for (x = 0; x < xcount; x++) - dest[x*rxstride + y*rystride] = ('rtype_name`)0; - - for (y = 0; y < ycount; y++) - for (n = 0; n < count; n++) - for (x = 0; x < xcount; x++) - /* dest[x,y] += a[x,n] * b[n,y] */ - dest[x*rxstride + y*rystride] += - abase[x*axstride + n*aystride] * - bbase[n*bxstride + y*bystride]; - } else if (GFC_DESCRIPTOR_RANK (a) == 1) { const 'rtype_name` *restrict bbase_y; @@ -534,6 +520,20 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl dest[y*rxstride] = s; } } + else if (axstride < aystride) + { + for (y = 0; y < ycount; y++) + for (x = 0; x < xcount; x++) + dest[x*rxstride + y*rystride] = ('rtype_name`)0; + + for (y = 0; y < ycount; y++) + for (n = 0; n < count; n++) + for (x = 0; x < xcount; x++) + /* dest[x,y] += a[x,n] * b[n,y] */ + dest[x*rxstride + y*rystride] += + abase[x*axstride + n*aystride] * + bbase[n*bxstride + y*bystride]; + } else { const 'rtype_name` *restrict abase_x; |