From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16660 invoked by alias); 7 Jul 2010 12:39:38 -0000 Received: (qmail 16241 invoked by uid 48); 7 Jul 2010 12:39:21 -0000 Date: Wed, 07 Jul 2010 12:39:00 -0000 Subject: [Bug fortran/44856] New: Usage of array PARAMETERs: Literal copy vs. global variable X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg00721.txt.bz2 Currently, gfortran saves scalar constants (PARAMETER) only in the .mod file while array parameters are saved as global, static variable in the .o file and additionally as expression in the .mod file. This has all kind of funny consequences. For instance: print *, array_par, (array_par), shape(array_par) Here, the first item is accessed via the global variable, for the second one a static variable is produced in place, which is then accessed, and for the third one, the front end simplifies the expression and generates an variable containing the shape. Similarly for: a = array_par(1) a = array_par(1) + 0 In the first case, one accesses the global variable while in the second case, one generates a temporary local variable, initialized by the literal. There are a couple of issues: a) For intrinsic modules, it does not work (cf. PR 40571) as there is no .o file. b) Accessing the global variable in case of taking a scalar does not make sense: a = parameter_array(1) should always use (a local variable with) the literal. c) Also in other cases, it can make sense to generate a local copy of the literal - as done in case of "(parameter_array)" - though, one probably wants to limit the inline size. Comments? Suggestions? -- Summary: Usage of array PARAMETERs: Literal copy vs. global variable Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org OtherBugsDependingO 40571 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44856