Walt Brainerd wrote:
>
> James Giles wrote:
> >
> > Walt Brainerd <[log in to unmask]> wrote:
> >
> > >James Giles wrote:
>
> > >Where will it all end? This would prevent "inlining" of procedures
> > >because (unless some other strange things have been done to the
> > >standard), I don't think there is any place that allows it. In fact,
> > >there are explicit words to the effect that a CALL statement is executed
> > >by executing the subroutine.
> >
> > Yes, but it doesn't specify how the subroutine is to be executed.
> > Executing an inline copy is perfectly reasonable.
>
> Of course, I agree that inlining is very reasonable. However, if
> we believe that "Interp #1" is correct (I don't), then we must take
> the words from the standard (12.4.3):
>
> "When a subroutine is invoked, ... the subroutine is executed."
>
> It doesn't say that you can extract the executable code out of the
> subroutine and move it into the calling program--just as Interp #1
> says you cannot move code from one statement to another. It says
> you must execute THE SUBROUTINE, not some code extracted from it.
But, Interp #1 doesn't really say that. It says code moving
optimizations are OK. To quote the parts that agree with me ;-}
QUESTION: Given a fragment such as
10 SUM = A + B
20 D = SUM + C
does the standard allow the processor the freedom to replace this two
statement
fragment with any of the following single statements:
100 D = (A + B) + C
130 D = (B + A) + C
ANSWER
[snip]
A common optimization for this fragment is to replace it by statements
such as
100, 130, etc. where the calculation of A + B appears in parenthesis.
This
replacement corresponds to the calculation of A + B in a temporary
location
(i.e., a register) and then accessing that temporary location instead of
storing
the result in SUM and then accessing that stored value.
end of quote.
So the compiler can move things around and keep things in registers,
etc.
Dick Hendrickson
>
> Obviously, this is all silly and Interp #1 should be fixed to put
> things back to the way they have been for 40+ years.
>
> --
> Walt Brainerd [log in to unmask]
> Unicomp, Inc. +1-520-298-7212 298-7074 (fax)
> 7660 E. Broadway, Suite 308 888-330-6060
> Tucson, AZ 85710 USA http://www.uni-comp.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|