aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2017-05-01 17:45:52 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2017-05-01 17:45:52 +0000
commitc6b9e849c04bfb994b72910346cbe24cf8feabd5 (patch)
tree642cc25f3e7ddd62f61cfd6dc2c874f7380178af /gcc
parent706eb1a70d6f1222cf14e84ab77c8b5404641182 (diff)
downloadgcc-c6b9e849c04bfb994b72910346cbe24cf8feabd5.zip
gcc-c6b9e849c04bfb994b72910346cbe24cf8feabd5.tar.gz
gcc-c6b9e849c04bfb994b72910346cbe24cf8feabd5.tar.bz2
re PR fortran/37131 (inline matmul for small matrix sizes)
2017-05-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/37131 * frontend-passes.c (inline_matmul_assign): Also check bounds for allocatable lhs and matrix-vector-multiplication. 2017-05-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/37131 * gfortran.dg/matmul_bounds_11.f90: New test. From-SVN: r247441
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/frontend-passes.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/matmul_bounds_11.f9015
4 files changed, 29 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c5ed507..1cc78c9 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-01 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/37131
+ * frontend-passes.c (inline_matmul_assign): Also check bounds
+ for allocatable lhs and matrix-vector-multiplication.
+
2017-04-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/80484
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 459967d..069ec28 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -3066,9 +3066,10 @@ inline_matmul_assign (gfc_code **c, int *walk_subtrees,
gfc_code *lhs_alloc;
/* Only need to check a single dimension for the A2B2 case for
- bounds checking, the rest will be allocated. */
+ bounds checking, the rest will be allocated. Also check this
+ for A2B1. */
- if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS && m_case == A2B2)
+ if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) && (m_case == A2B2 || m_case == A2B1))
{
gfc_code *test;
gfc_expr *a2, *b1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e0e04f3..584eae5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-01 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/37131
+ * gfortran.dg/matmul_bounds_11.f90: New test.
+
2017-05-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/79715
diff --git a/gcc/testsuite/gfortran.dg/matmul_bounds_11.f90 b/gcc/testsuite/gfortran.dg/matmul_bounds_11.f90
new file mode 100644
index 0000000..9209760
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/matmul_bounds_11.f90
@@ -0,0 +1,15 @@
+! { dg-do run }
+! { dg-options "-O -finline-matmul-limit=30 -fcheck=all" }
+! { dg-shouldfail "Dimension of array B incorrect in MATMUL intrinsic" }
+program main
+ real, dimension(:,:), allocatable :: a
+ real, dimension(:), allocatable :: b
+ real, dimension(:), allocatable :: res
+ allocate (a(2,2), b(3))
+ call random_number(a)
+ call random_number(b)
+ res = matmul(a,b)
+ print *,res
+end program main
+! { dg-output "Fortran runtime error: Dimension of array B incorrect in MATMUL intrinsic.*" }
+