Re: HLL design

Hans-Peter Diettrich <DrDiettrich1@aol.com>
21 Oct 2006 22:05:01 -0400

          From comp.compilers

Related articles
HLL design free4trample@yahoo.com (fermineutron) (2006-10-21)
Re: HLL design gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-10-21)
Re: HLL design pjb@informatimago.com (Pascal Bourguignon) (2006-10-21)
Re: HLL design DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-10-21)
Re: HLL design mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-10-21)
Re: HLL design int2k@gmx.net (Wolfram Fenske) (2006-10-21)
Re: HLL design DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-10-21)
Re: HLL design free4trample@yahoo.com (fermineutron) (2006-10-21)
Re: HLL design danwang74@gmail.com (Daniel C. Wang) (2006-10-24)
Re: HLL design idknow@gmail.com (idknow@gmail.com) (2006-10-24)
Re: HLL design bjarke.walling@gmail.com (Bjarke Walling) (2006-10-24)
Re: HLL design amedlock@gmail.com (DavidM) (2006-10-24)
Re: HLL design DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-10-26)
[1 later articles]
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: 21 Oct 2006 22:05:01 -0400
Organization: Compilers Central
References: 06-10-080 06-10-083
Keywords: design, performance
Posted-Date: 21 Oct 2006 22:05:01 EDT

glen herrmannsfeldt wrote:


> If a compiler can determine at compile time that, for example, a loop
> variable can't go outside the array, or can test the loop conditions
> once instead of each time, it could be faster. I believe some
> compilers do that, but I don't know that any language includes it in
> the language definition.


Delphi example:


for i := low(ar) to high(ar) do
      do_something_with(ar[i]);


Here the compiler knows that i will always be within the array bounds.
low() and high() are compiler magics, which determine the bounds of
either static or dynamic arrays, or of other enumeratable or ordinal
types. The loop index must be a local variable (no aliasing), and cannot
be changed programmatically inside the loop. The implementation can use
an loop down-counter, instead of an index, and an pointer to the
elements. So the resulting code can be as fast as the same (but unsafe)
implementation in C.


DoDi
[The IBM PL.8 project also did a lot of work on optimizing away bounds
checks when the compiler could tell they weren't needed. Don't know
what became of that work. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.