This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/44856] New: Usage of array PARAMETERs: Literal copy vs. global variable


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]