🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2037

Re: Whether cc after f2c can optimize arrays as well as f77 can

#2037
From: Jim Giles
Date: Tue, 13 Nov 1990 20:10
56 lines
2395 bytes
From article <6787:Nov1008:04:0290@kramden.acf.nyu.edu>, by brnstnd@kramden.acf.nyu.edu (Dan Bernstein):
> [...]
>   [ supposed counterexample ]
>> That's just the thing!  I mean, it shouldn't, should it?  You stated
>> above: "The fast version will always, in practice, be selected."
>> What happened to that?  Certainly, Fortran would select the _fast_
>> version.
> 
> As I said before, your example has NOTHING to do with Fortran, since
> there is no real (visibility) equivalent to static.

Actually, Fortran _does_ have the capability.  The exact analog to the
C example I gave before is:

      Function main(what, ever)
      integer a
      ...
      call sub(a)
      ...
      return
      entry fcn(x)
C     ... is a aliased to x here? ...
      return
      end

And, as I pointed out, Fortran will pick the FAST version of the
code.  What you propose will pick the SLOW version.  What I propose
will pick the _appropriate_ version.

Further, as I also pointed out, this was just the _FIRST_ counter
example that occurred to me.  The fact that your proposal doesn't
track constraints through the call chain suggests others.

      int a;            sub1(x){        int a;
      main(){           ...             sub2(y){
      ...               sub2(x);        ...
      sub1(&a);         sub3(x);        /* is a aliased to y? */
      }                 }               }


      int b;
      sub3(z){
      ...
      /* is b aliased to z? */
      }

If these routines are in four separate files, the method you
propose will not be able to answer the questions.  A Fortran
version will always optimize as if no aliasing occurred: most
implementations will not (unfortunately) catch the error.  No
matter which decision your method guesses, it will be wrong on
one of the two questions - you can only get the answers right
by propagating the information about the parameters through the
call chain.

J. Giles
Technical Details
Message-ID: <5805@lanl.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!cmcl2!lanl!jlg
References: <6787:Nov1008:04:0290@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!cmcl2!lanl!jlg
From: jlg@lanl.gov (Jim Giles)
Newsgroups: comp.lang.misc
Subject: Re: Whether cc after f2c can optimize arrays as well as f77 can
Message-ID: <5805@lanl.gov>
Date: 13 Nov 90 20:10:06 GMT
References: <6787:Nov1008:04:0290@kramden.acf.nyu.edu>
Organization: Los Alamos Natl Lab, Los Alamos, N.M.
Lines: 56