public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jv244 at cam dot ac dot uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/40194] fortran rules for optimizing
Date: Tue, 19 May 2009 11:55:00 -0000	[thread overview]
Message-ID: <20090519115455.5002.qmail@sourceware.org> (raw)
In-Reply-To: <bug-40194-6642@http.gcc.gnu.org/bugzilla/>



------- Comment #5 from jv244 at cam dot ac dot uk  2009-05-19 11:54 -------
(In reply to comment #3)
> Does
> 
>     SUBROUTINE S(I1,IP)
>       INTEGER,INTENT(IN) :: I1
>       INTEGER, POINTER :: IP
>     END SUBROUTINE S
> 
> allow that S stores the pointer to I1 to global memory?

this is not a very Fortran-ish way to express this, and I'm not very C-ish, but
the answer is no (I don't think you can obtain the address of I1 in S1 using
standard conforming Fortran, and certainly there is no guarantee at all that
you get the address of I1 in F1). Even if you get the address of I1, no way
you're allowed to change the value of I1, either in S1, or in any subroutine
called subsequently.

The important thing is not so much that (I believe), but the fact that Fortran
guarantees that in the caller where I1 is defined (i.e. F1), nothing else can
alias that variable.

> I think that the easiest way to improve Fortran code generation is to _not_
> pass INTENT(IN) arguments by reference but by value (at least for scalar
> types).

I believe that his is some kind of misunderstanding. It is not because the FE
generates some code that is call by reference that his is actually what the
rules are. AFAICT, it would be equally valid for a Fortran implementation to
copy in and copy out the data (i.e. the address of the variable in the caller
is of no importance in the callee).

I think it would be worthwhile to discuss this once with the group of
gcc-people that know both Fortran and the middle-end really well (I hope this
is a non-zero subset :-)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40194


  parent reply	other threads:[~2009-05-19 11:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-19  9:59 [Bug middle-end/40194] New: " jv244 at cam dot ac dot uk
2009-05-19 10:01 ` [Bug middle-end/40194] " jv244 at cam dot ac dot uk
2009-05-19 10:14 ` jv244 at cam dot ac dot uk
2009-05-19 10:20 ` rguenth at gcc dot gnu dot org
2009-05-19 10:40 ` rguenth at gcc dot gnu dot org
2009-05-19 11:55 ` jv244 at cam dot ac dot uk [this message]
2009-05-19 12:04 ` rguenth at gcc dot gnu dot org
2009-05-19 12:11 ` rguenth at gcc dot gnu dot org
2009-08-13  7:23 ` jv244 at cam dot ac dot uk
2009-08-13 12:16 ` matz at gcc dot gnu dot org
     [not found] <bug-40194-4@http.gcc.gnu.org/bugzilla/>
2012-06-29 14:14 ` Joost.VandeVondele at mat dot ethz.ch
2013-03-29  9:07 ` Joost.VandeVondele at mat dot ethz.ch

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=20090519115455.5002.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).