public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r10-9890] Fortran - ICE in inline_matmul_assign
Date: Fri,  4 Jun 2021 17:54:42 +0000 (GMT)	[thread overview]
Message-ID: <20210604175442.E1E783851C27@sourceware.org> (raw)

https://gcc.gnu.org/g:df45c5b83447a06e6b15c729807a17409c39ddff

commit r10-9890-gdf45c5b83447a06e6b15c729807a17409c39ddff
Author: Harald Anlauf <anlauf@gmx.de>
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 5e768b12854..14c23dc3033 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -3919,6 +3919,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


                 reply	other threads:[~2021-06-04 17:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210604175442.E1E783851C27@sourceware.org \
    --to=anlauf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).