Commit f6c7d65b by Paul Thomas

Fix matmul PR18857 and supply testcase

From-SVN: r99041
parent 078885f2
2005-04-30 Paul Thomas <pault@gcc.gnu.org>
PR libfortran/18857
* gfortran.dg/matmul_1.f90: New test.
2005-04-28 Kazu Hirata <kazu@cs.umass.edu> 2005-04-28 Kazu Hirata <kazu@cs.umass.edu>
PR tree-optimization/21030 PR tree-optimization/21030
......
!{ dg-do run }
! Test MATMUL for various arguments and results
! (test values checked with GNU octave).
! PR18857 was due to an incorrect assertion that component base==0
! for both input arguments and the result.
! provided by Paul Thomas - pault@gcc.gnu.org
Program matmul_1
integer, parameter :: N = 5
integer, parameter :: T = 4
integer :: i
real(kind=T), dimension(:,:), allocatable :: a, b, c
real(kind=T), dimension(N,N) :: x, y, z
allocate (a(2*N, N), b(N, N), c(2*N, N))
do i = 1, 2*N
a(i, :) = real (i)
end do
b = 4.0_T
do i = 1, N
x(i, :) = real (i)
end do
y = 2.0_T
! whole array
z = 0.0_T
z = matmul (x, y)
if (sum (z) /= 750.0_T) call abort ()
! array sections
c = 0.0_T
c = matmul (a(7:9,3:N), b(3:N,3:4))
if (sum (c) /= 576.0_T) call abort ()
! uses a temp
c = 0.0_T
c = matmul (a, b + x)
if (sum (c) /= 9625.0_T) call abort ()
! returns to a temp
c = 0.0_T
c = a + matmul (a, b)
if (sum (c) /= 5775.0_T) call abort ()
deallocate (a, b, c)
end program matmul_1
2005-04-30 Paul Thomas <pault@gcc.gnu.org>
PR libfortran/18857
* generated/matmul_r8.c: Remove incorrect assertions.
* generated/matmul_c4.c: Regenerate
* generated/matmul_c8.c: Regenerate
* generated/matmul_i4.c: Regenerate
* generated/matmul_i8.c: Regenerate
* generated/matmul_r4.c: Regenerate
* generated/matmul_r8.c: Regenerate
2005-04-29 Francois-Xavier Coudert <coudert@clipper.ens.fr> 2005-04-29 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* configure.ac: Check for ftruncate and chsize. * configure.ac: Check for ftruncate and chsize.
...@@ -28,7 +39,6 @@ ...@@ -28,7 +39,6 @@
call for ext_name. These fix the bug reported by Jerry DeLisle to call for ext_name. These fix the bug reported by Jerry DeLisle to
the fortran list and are based on his suggested fix. the fortran list and are based on his suggested fix.
2005-04-22 Thomas Koenig <Thomas.Koenig@online.de> 2005-04-22 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/20074 PR libfortran/20074
...@@ -45,7 +55,7 @@ ...@@ -45,7 +55,7 @@
* generated/reshape_i4.c: Regenerated. * generated/reshape_i4.c: Regenerated.
* generated/reshape_i8.c: Regenerated. * generated/reshape_i8.c: Regenerated.
2005-04-18 Paul Thomas <pault@gcc.gnu.org> 2005-04-18 Paul Thomas <pault@gcc.gnu.org>
* io/list_read.c (nml_touch_nodes, nml_read_obj, * io/list_read.c (nml_touch_nodes, nml_read_obj,
nml_get_obj_data): Fix memory leaks in code for derived types. nml_get_obj_data): Fix memory leaks in code for derived types.
......
...@@ -55,6 +55,9 @@ all_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ all_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ all_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ all_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ any_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ any_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ any_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ any_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ count_4_l4 (gfc_array_i4 *retarray, gfc_array_l4 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ count_4_l4 (gfc_array_i4 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ count_4_l8 (gfc_array_i4 *retarray, gfc_array_l8 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ count_4_l8 (gfc_array_i4 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ count_8_l4 (gfc_array_i8 *retarray, gfc_array_l4 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ count_8_l4 (gfc_array_i8 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -55,6 +55,9 @@ count_8_l8 (gfc_array_i8 *retarray, gfc_array_l8 *array, index_type *pdim) ...@@ -55,6 +55,9 @@ count_8_l8 (gfc_array_i8 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
/* TODO: It should be a front end job to correctly set the strides. */
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
......
...@@ -167,10 +167,6 @@ matmul_c4 (gfc_array_c4 * retarray, gfc_array_c4 * a, gfc_array_c4 * b) ...@@ -167,10 +167,6 @@ matmul_c4 (gfc_array_c4 * retarray, gfc_array_c4 * a, gfc_array_c4 * b)
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
...@@ -167,10 +167,6 @@ matmul_c8 (gfc_array_c8 * retarray, gfc_array_c8 * a, gfc_array_c8 * b) ...@@ -167,10 +167,6 @@ matmul_c8 (gfc_array_c8 * retarray, gfc_array_c8 * a, gfc_array_c8 * b)
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
...@@ -167,10 +167,6 @@ matmul_i4 (gfc_array_i4 * retarray, gfc_array_i4 * a, gfc_array_i4 * b) ...@@ -167,10 +167,6 @@ matmul_i4 (gfc_array_i4 * retarray, gfc_array_i4 * a, gfc_array_i4 * b)
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
...@@ -167,10 +167,6 @@ matmul_i8 (gfc_array_i8 * retarray, gfc_array_i8 * a, gfc_array_i8 * b) ...@@ -167,10 +167,6 @@ matmul_i8 (gfc_array_i8 * retarray, gfc_array_i8 * a, gfc_array_i8 * b)
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
...@@ -167,10 +167,6 @@ matmul_r4 (gfc_array_r4 * retarray, gfc_array_r4 * a, gfc_array_r4 * b) ...@@ -167,10 +167,6 @@ matmul_r4 (gfc_array_r4 * retarray, gfc_array_r4 * a, gfc_array_r4 * b)
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
...@@ -167,10 +167,6 @@ matmul_r8 (gfc_array_r8 * retarray, gfc_array_r8 * a, gfc_array_r8 * b) ...@@ -167,10 +167,6 @@ matmul_r8 (gfc_array_r8 * retarray, gfc_array_r8 * a, gfc_array_r8 * b)
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
...@@ -169,10 +169,6 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl ...@@ -169,10 +169,6 @@ sinclude(`matmul_asm_'rtype_code`.m4')dnl
ycount = b->dim[1].ubound + 1 - b->dim[1].lbound; ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
} }
assert (a->base == 0);
assert (b->base == 0);
assert (retarray->base == 0);
abase = a->data; abase = a->data;
bbase = b->data; bbase = b->data;
dest = retarray->data; dest = retarray->data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment