From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id 0955C399E046; Fri, 4 Jun 2021 18:19:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0955C399E046 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9568] Fortran - ICE in inline_matmul_assign X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 92f1b62a1862e40350b2aee7cbe260cebcfd6b63 X-Git-Newrev: e912880888f9529eb44e3456c4753fc556c63812 Message-Id: <20210604181926.0955C399E046@sourceware.org> Date: Fri, 4 Jun 2021 18:19:26 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jun 2021 18:19:26 -0000 https://gcc.gnu.org/g:e912880888f9529eb44e3456c4753fc556c63812 commit r9-9568-ge912880888f9529eb44e3456c4753fc556c63812 Author: Harald Anlauf Date: Fri Jun 4 19:23:48 2021 +0200 Fortran - ICE in inline_matmul_assign Restrict inlining of matmul to those cases where assignment to the result array does not need special treatment. gcc/fortran/ChangeLog: PR fortran/99839 * frontend-passes.c (inline_matmul_assign): Do not inline matmul if the assignment to the resulting array if it is not of canonical type (real/integer/complex/logical). gcc/testsuite/ChangeLog: PR fortran/99839 * gfortran.dg/inline_matmul_25.f90: New test. (cherry picked from commit bee8619ad0ac3bd27b7c8dc5819b83a5e8e147a0) Diff: --- gcc/fortran/frontend-passes.c | 13 +++++++++++++ gcc/testsuite/gfortran.dg/inline_matmul_25.f90 | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index ff71b44b409..7a733cc016c 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -3921,6 +3921,19 @@ inline_matmul_assign (gfc_code **c, int *walk_subtrees, if (m_case == none) return 0; + /* We only handle assignment to numeric or logical variables. */ + switch(expr1->ts.type) + { + case BT_INTEGER: + case BT_LOGICAL: + case BT_REAL: + case BT_COMPLEX: + break; + + default: + return 0; + } + ns = insert_block (); /* Assign the type of the zero expression for initializing the resulting diff --git a/gcc/testsuite/gfortran.dg/inline_matmul_25.f90 b/gcc/testsuite/gfortran.dg/inline_matmul_25.f90 new file mode 100644 index 00000000000..df8ad06c123 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/inline_matmul_25.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-options "-ffrontend-optimize" } +! PR fortran/99839 - ICE in inline_matmul_assign + +program p + real :: x(3, 3) = 1.0 + class(*), allocatable :: z(:, :) + z = matmul(x, x) +end