Bug 84270 - [7/8 Regression] optimization bug with assumed size array argument
Summary: [7/8 Regression] optimization bug with assumed size array argument
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.3.1
: P4 normal
Target Milestone: 7.4
Assignee: Thomas Koenig
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-02-07 19:05 UTC by Michael Weinert
Modified: 2018-02-17 16:02 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-08 00:00:00


Attachments
simple test case (649 bytes, text/plain)
2018-02-07 19:05 UTC, Michael Weinert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weinert 2018-02-07 19:05:15 UTC
Created attachment 43359 [details]
simple test case

Optimization bug at -O2, -O3 with message

    vr = matmul( orth(:,:,n), v )
                1
Error: The upper bound in the last dimension must appear in the reference to the assumed size array ‘orth’ at (1) lhcal.f90:33:25:

Attached test case is taken from larger program, and only appears to be a problem if orth is an assumed size arrays with the * in the last dimension. (If assumed shape, also fine.) Obviously easy to work around, so minor.
Comment 1 Harald Anlauf 2018-02-07 21:15:47 UTC
The bug disappears with -fno-frontend-optimize.
Comment 2 Thomas Koenig 2018-02-08 08:14:14 UTC
Looks like a matmul inlining bug, I'll take a look.
Comment 3 Thomas Koenig 2018-02-17 15:53:39 UTC
Author: tkoenig
Date: Sat Feb 17 15:53:07 2018
New Revision: 257783

URL: https://gcc.gnu.org/viewcvs?rev=257783&root=gcc&view=rev
Log:
2018-02-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/84270
	* frontend-passes (scalarized_expr):  If the expression
	is an assumed size array, leave in the last reference
	and pass AR_SECTION instead of AR_FULL to gfc_resolve
	in order to avoid an error.

2018-02-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/84270
	* gfortran.dg/inline_matmul_22.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/inline_matmul_22.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Thomas Koenig 2018-02-17 16:02:22 UTC
Author: tkoenig
Date: Sat Feb 17 16:01:50 2018
New Revision: 257784

URL: https://gcc.gnu.org/viewcvs?rev=257784&root=gcc&view=rev
Log:
2018-02-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	Backport from trunk
	PR fortran/84270
	* frontend-passes (scalarized_expr):  If the expression
	is an assumed size array, leave in the last reference
	and pass AR_SECTION instead of AR_FULL to gfc_resolve
	in order to avoid an error.

2018-02-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	Backport from trunk
	PR fortran/84270
	* gfortran.dg/inline_matmul_22.f90: New test.


Added:
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/inline_matmul_22.f90
Modified:
    branches/gcc-7-branch/gcc/fortran/ChangeLog
    branches/gcc-7-branch/gcc/fortran/frontend-passes.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 5 Thomas Koenig 2018-02-17 16:02:52 UTC
Fixed on all affected branches, closing.