home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!burley
- From: burley@geech.gnu.ai.mit.edu (Craig Burley)
- Newsgroups: comp.lang.fortran
- Subject: Re: subroutine calls with loop index parameters
- Message-ID: <BURLEY.92Aug18124835@geech.gnu.ai.mit.edu>
- Date: 18 Aug 92 16:48:35 GMT
- Article-I.D.: geech.BURLEY.92Aug18124835
- References: <1992Aug18.064927.1990@ccu1.aukuni.ac.nz>
- Sender: news@ai.mit.edu
- Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139
- Lines: 31
- In-reply-to: ecmtwhk@ccu1.aukuni.ac.nz's message of 18 Aug 92 06:49:27 GMT
-
- In article <1992Aug18.064927.1990@ccu1.aukuni.ac.nz> ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes:
-
- Unless I am quite mistaken, the FORTRAN standard specifies that it is
- illegal to modify the value of an index variable inside the loop, so
- any change which FUNC made to it would have been illegal; the compiler
- could therefore safely assume it would not be made, and produce optimum
- code the first time.
-
- You are not mistaken.
-
- How widespread is this kind of behaviour? Should I always introduce
- additional variables to get around situations like that?
-
- I don't know. You might try enclosing all "questionable" references to
- loop index variables in parentheses just to see what it would do, as in:
-
- A(I,J) = FUNC((I),(J))
-
- It might accomplish nothing, but it's a little more readable than throwing
- in a couple more temporaries. You could also try "(I+0)" etc.
-
- The front end for GNU Fortran automatically marks all such references in the
- IL as "loop-index" references so the back end, if it wants, can realize that
- the variable won't be modified no matter what. Offhand, I don't remember if
- I've made use of this in the initial implementation of GNU Fortran with the
- GNU compiler back end, but when building the front end, I thought it important
- to provide to whatever back ends people wanted to attach to it.
- --
-
- James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
- Member of the League for Programming Freedom (LPF)
-