public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/44856]  New: Usage of array PARAMETERs:  Literal copy vs. global variable
@ 2010-07-07 12:39 burnus at gcc dot gnu dot org
  2010-07-07 14:47 ` [Bug fortran/44856] " burnus at gcc dot gnu dot org
  2010-07-07 15:23 ` burnus at gcc dot gnu dot org
  0 siblings, 2 replies; 4+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-07 12:39 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <bug-44856-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2010-12-08 16:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07 12:39 [Bug fortran/44856] New: Usage of array PARAMETERs: Literal copy vs. global variable burnus at gcc dot gnu dot org
2010-07-07 14:47 ` [Bug fortran/44856] " burnus at gcc dot gnu dot org
2010-07-07 15:23 ` burnus at gcc dot gnu dot org
     [not found] <bug-44856-4@http.gcc.gnu.org/bugzilla/>
2010-12-08 16:28 ` burnus at gcc dot gnu.org

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).