From 1633cb7cb6b292ca0cfaa0311b2784927efe7990 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Fri, 5 May 2006 13:08:23 +0200 Subject: [PATCH] re PR libfortran/26985 (incorrect matmul result) PR libfortran/26985 * m4/matmul.m4: Correct the condition for the memset call, and remove the unneeded call to size0. * generated/matmul_r4.c: Regenerate. * generated/matmul_r8.c: Regenerate. * generated/matmul_r10.c: Regenerate. * generated/matmul_r16.c: Regenerate. * generated/matmul_c4.c: Regenerate. * generated/matmul_c8.c: Regenerate. * generated/matmul_c10.c: Regenerate. * generated/matmul_c16.c: Regenerate. * generated/matmul_i4.c: Regenerate. * generated/matmul_i8.c: Regenerate. * generated/matmul_i16.c: Regenerate. * gfortran.dg/matmul_2.f90: New test. From-SVN: r113552 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/matmul_2.f90 | 21 +++++++++++++++++++++ libgfortran/ChangeLog | 18 +++++++++++++++++- libgfortran/generated/matmul_c10.c | 4 ++-- libgfortran/generated/matmul_c16.c | 4 ++-- libgfortran/generated/matmul_c4.c | 4 ++-- libgfortran/generated/matmul_c8.c | 4 ++-- libgfortran/generated/matmul_i16.c | 4 ++-- libgfortran/generated/matmul_i4.c | 4 ++-- libgfortran/generated/matmul_i8.c | 4 ++-- libgfortran/generated/matmul_r10.c | 4 ++-- libgfortran/generated/matmul_r16.c | 4 ++-- libgfortran/generated/matmul_r4.c | 4 ++-- libgfortran/generated/matmul_r8.c | 4 ++-- libgfortran/m4/matmul.m4 | 4 ++-- 15 files changed, 67 insertions(+), 25 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/matmul_2.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c3cccc5e596f..277f767a38a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-05-05 Francois-Xavier Coudert + + PR libfortran/26985 + * gfortran.dg/matmul_2.f90: New test. + 2005-05-05 Laurent GUERBY * ada/acats/run_all.sh: Use sync when main not found. diff --git a/gcc/testsuite/gfortran.dg/matmul_2.f90 b/gcc/testsuite/gfortran.dg/matmul_2.f90 new file mode 100644 index 000000000000..fb678afb896f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/matmul_2.f90 @@ -0,0 +1,21 @@ +!{ dg-do run } +! PR libfortran/26985 +program matmul_2 + implicit none + integer :: a(2,9), b(9,7), c(2,7) + integer :: i, j + + a = 1 + b = 2 + c = 1789789 + c(:,1:7:2) = matmul(a,b(:,1:7:2)) + + if (c(1,1) /= 18 .or. c(2,1) /= 18 .or. & + c(1,2) /= 1789789 .or. c(2,2) /= 1789789 .or. & + c(1,3) /= 18 .or. c(2,3) /= 18 .or. & + c(1,4) /= 1789789 .or. c(2,4) /= 1789789 .or. & + c(1,5) /= 18 .or. c(2,5) /= 18 .or. & + c(1,6) /= 1789789 .or. c(2,6) /= 1789789 .or. & + c(1,7) /= 18 .or. c(2,7) /= 18) call abort + +end program matmul_2 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 905371567036..cb8c0fd1c282 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,7 +1,23 @@ +2006-05-05 Francois-Xavier Coudert + + PR libfortran/26985 + * m4/matmul.m4: Correct the condition for the memset call, + and remove the unneeded call to size0. + * generated/matmul_r4.c: Regenerate. + * generated/matmul_r8.c: Regenerate. + * generated/matmul_r10.c: Regenerate. + * generated/matmul_r16.c: Regenerate. + * generated/matmul_c4.c: Regenerate. + * generated/matmul_c8.c: Regenerate. + * generated/matmul_c10.c: Regenerate. + * generated/matmul_c16.c: Regenerate. + * generated/matmul_i4.c: Regenerate. + * generated/matmul_i8.c: Regenerate. + * generated/matmul_i16.c: Regenerate. + 2006-04-29 Jerry DeLisle PR libgfortran/27360 - * io/list_read.c (read_logical): Free line_buffer and free saved. 2006-04-28 Jerry DeLisle diff --git a/libgfortran/generated/matmul_c10.c b/libgfortran/generated/matmul_c10.c index edbd1e6becce..93032f814047 100644 --- a/libgfortran/generated/matmul_c10.c +++ b/libgfortran/generated/matmul_c10.c @@ -193,8 +193,8 @@ matmul_c10 (gfc_array_c10 * const restrict retarray, const GFC_COMPLEX_10 * restrict abase_n; GFC_COMPLEX_10 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_COMPLEX_10) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_COMPLEX_10) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_c16.c b/libgfortran/generated/matmul_c16.c index c04146be8219..03ad0f7df27d 100644 --- a/libgfortran/generated/matmul_c16.c +++ b/libgfortran/generated/matmul_c16.c @@ -193,8 +193,8 @@ matmul_c16 (gfc_array_c16 * const restrict retarray, const GFC_COMPLEX_16 * restrict abase_n; GFC_COMPLEX_16 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_COMPLEX_16) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_COMPLEX_16) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_c4.c b/libgfortran/generated/matmul_c4.c index a01de37bc74a..84c94cd586fd 100644 --- a/libgfortran/generated/matmul_c4.c +++ b/libgfortran/generated/matmul_c4.c @@ -193,8 +193,8 @@ matmul_c4 (gfc_array_c4 * const restrict retarray, const GFC_COMPLEX_4 * restrict abase_n; GFC_COMPLEX_4 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_COMPLEX_4) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_COMPLEX_4) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_c8.c b/libgfortran/generated/matmul_c8.c index 75ec4fc101c1..f491ea058d7d 100644 --- a/libgfortran/generated/matmul_c8.c +++ b/libgfortran/generated/matmul_c8.c @@ -193,8 +193,8 @@ matmul_c8 (gfc_array_c8 * const restrict retarray, const GFC_COMPLEX_8 * restrict abase_n; GFC_COMPLEX_8 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_COMPLEX_8) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_COMPLEX_8) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_i16.c b/libgfortran/generated/matmul_i16.c index eacc47ff8cd1..50d87bb8b0fc 100644 --- a/libgfortran/generated/matmul_i16.c +++ b/libgfortran/generated/matmul_i16.c @@ -193,8 +193,8 @@ matmul_i16 (gfc_array_i16 * const restrict retarray, const GFC_INTEGER_16 * restrict abase_n; GFC_INTEGER_16 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_INTEGER_16) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_INTEGER_16) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_i4.c b/libgfortran/generated/matmul_i4.c index 6166bf18c291..12ac630a5491 100644 --- a/libgfortran/generated/matmul_i4.c +++ b/libgfortran/generated/matmul_i4.c @@ -193,8 +193,8 @@ matmul_i4 (gfc_array_i4 * const restrict retarray, const GFC_INTEGER_4 * restrict abase_n; GFC_INTEGER_4 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_INTEGER_4) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_INTEGER_4) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_i8.c b/libgfortran/generated/matmul_i8.c index b83ded04ebf0..82b22292632e 100644 --- a/libgfortran/generated/matmul_i8.c +++ b/libgfortran/generated/matmul_i8.c @@ -193,8 +193,8 @@ matmul_i8 (gfc_array_i8 * const restrict retarray, const GFC_INTEGER_8 * restrict abase_n; GFC_INTEGER_8 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_INTEGER_8) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_INTEGER_8) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_r10.c b/libgfortran/generated/matmul_r10.c index 6702209bd228..73e1e3276308 100644 --- a/libgfortran/generated/matmul_r10.c +++ b/libgfortran/generated/matmul_r10.c @@ -193,8 +193,8 @@ matmul_r10 (gfc_array_r10 * const restrict retarray, const GFC_REAL_10 * restrict abase_n; GFC_REAL_10 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_REAL_10) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_REAL_10) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_r16.c b/libgfortran/generated/matmul_r16.c index c095cbdb747a..099c6bf855ed 100644 --- a/libgfortran/generated/matmul_r16.c +++ b/libgfortran/generated/matmul_r16.c @@ -193,8 +193,8 @@ matmul_r16 (gfc_array_r16 * const restrict retarray, const GFC_REAL_16 * restrict abase_n; GFC_REAL_16 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_REAL_16) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_REAL_16) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_r4.c b/libgfortran/generated/matmul_r4.c index dedc5a349616..ca6a4a4360ca 100644 --- a/libgfortran/generated/matmul_r4.c +++ b/libgfortran/generated/matmul_r4.c @@ -193,8 +193,8 @@ matmul_r4 (gfc_array_r4 * const restrict retarray, const GFC_REAL_4 * restrict abase_n; GFC_REAL_4 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_REAL_4) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_REAL_4) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/generated/matmul_r8.c b/libgfortran/generated/matmul_r8.c index 926a860e386e..1844cdc3da8a 100644 --- a/libgfortran/generated/matmul_r8.c +++ b/libgfortran/generated/matmul_r8.c @@ -193,8 +193,8 @@ matmul_r8 (gfc_array_r8 * const restrict retarray, const GFC_REAL_8 * restrict abase_n; GFC_REAL_8 bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (GFC_REAL_8) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (GFC_REAL_8) * xcount * ycount)); else { for (y = 0; y < ycount; y++) diff --git a/libgfortran/m4/matmul.m4 b/libgfortran/m4/matmul.m4 index f488f5ed38eb..526303c9f394 100644 --- a/libgfortran/m4/matmul.m4 +++ b/libgfortran/m4/matmul.m4 @@ -195,8 +195,8 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl const rtype_name * restrict abase_n; rtype_name bbase_yn; - if (rystride == ycount) - memset (dest, 0, (sizeof (rtype_name) * size0((array_t *) retarray))); + if (rystride == xcount) + memset (dest, 0, (sizeof (rtype_name) * xcount * ycount)); else { for (y = 0; y < ycount; y++)