home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / fortran / 3083 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  2.0 KB

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