Re: Compiler optimisation
From: Danny Thorpe (dthorpe_at_bozofilter.borland.com)
Date: 01/21/05
- Next message: Danny Thorpe: "Re: Compiler optimisation"
- Previous message: TJC Support: "Re: Developer license"
- In reply to: Dejan Stankovic: "Re: Compiler optimisation"
- Next in thread: John Wester [Group W]: "Re: Compiler optimisation"
- Reply: John Wester [Group W]: "Re: Compiler optimisation"
- Reply: Per Larsen: "Re: Compiler optimisation"
- Reply: Allen Bauer: "Re: Compiler optimisation"
- Reply: Wayne Niddery [TeamB]: "Re: Compiler optimisation"
- Reply: Dejan Stankovic: "Re: Compiler optimisation"
- Reply: Captain Jake: "Re: Compiler optimisation"
- Reply: Lord Crc: "Re: Compiler optimisation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Jan 2005 12:02:01 -0800
Dejan Stankovic wrote:
>
> Keep in mind that Delphi is one-pass compiler (apparently).
Incorrect. The Delphi compiler is a one-pass, top-down parser with
incremental code generation.
> This
> limits number of possible optimizations to ones that do not operate
> on intermediate code.
True, but not applicable to Delphi. The Delphi compiler does use
intermediate representations and multi-stage AST tree trimming
optimizations.
>
> For your reference, following is, as complete as I could make it,
> list of all optimizations that are used in todays compilers.
>
I've added notations for which of these the Delphi compiler implements.
> -Aggregation of global references
No, if this is referring to global constant folding (strings, primarily)
> -Algebraic simplifications, including reassociations
Yes, but to a limited degree. We don't replace division with multiply
by reciprocal, for example, because of concerns about loss of precision
at the edges.
> -Basic-block and branch scheduling
No.
> -Branch optimizations
Yes.
> and conditional moves
No.
> -Branch prediction
Static.
> -Code hoisting
No.
> -Constant folding
Yes.
> -Control-flow optimizations
Unclear.
> -Data prefetching
No.
> -Data-cache optimizations
No.
> -Dead-code elimination
Yes.
> -Global value numbering
No.
> -In-line expansion
Yes.
> -Induction-variable removal
Yes.
> -Induction-variable strength reduction
Yes.
> -Instruction prefetching
No.
> -Interprocedureal constant propagation
Unclear. A constant is constant everywhere, no?
> -Interprocedureal register allocation
No.
> -Intraprocedureal instruction cache optimization
No.
> -Leaf-routine optimization
No.
> -Linear-function test replacement
Unclear.
> -Local and global common-subexpression elimination
Yes.
> -Local and global copy propagation
No.
> -Loop-invariant code motion
Yes.
> -Machine idioms
No.
> -Partial-redundancy elimination
Yes. (for pointer derefs)
> -Procedure integration
Unclear.
> -Procedure specialization and clonning
No.
> -Scalar replacement of aggregates
> -Scalar replacement of array references
If this refers to constant expression evaluation, yes.
> -Shrink wrapping
??
> -Software pipelining, with loop unrolling, variable expansion,
> register -renaming and hierarchical reduction
Codegen templates are hand-tuned to favor instruction scheduling for
the U and V pipelines of the Pentium family of processors.
> -Sparse conditional constant propagation
No.
> -Tail call optimization, including tail recursion elimination
No.
> -Tail merging
No.
> -Unnecessary bounds checking elimination
Yes.
>
> Keep in mind that even very good compilers implement only a small
> number of those and that not all of those are speed optimizations.
>
Correct. The tail recursion optimizations in your list, for example,
are astronomically rare in the wild. Such optimizations typically only
kick in if you write you recursive routines "just so" which means only
the illuminati will benefit by it.
The mantra for Delphi optimizations is to make everyday code work
better. We don't the luxury of chasing after miraculous optimizations
that almost never work. I leave that to the grad students. ;>
> Now going back to Delphi. It has always been a solid compiler with
> two important features: it generates good code to begin with and it
> is one-pass (lightning fast). If you ever wandered why C++ takes ages
> to compile as compared to Delphi, this is the answer. A lot of that
> Delphi has to thank to the language itself.
>
True, except for the one-pass assertion. The codegen phase is
multi-pass intermediate node tree traversals and pruning. We just do
it many times faster than the more traditional compiler models that
were originally concieved for batch processing of punched cards.
>
> This brings me to another point. Delphi has never been designed to be
> high-end compiler. For the purpose that people use it, it is more
> than fast enough.
>
Correct. It could be said that Delphi is fast enough to lead some
folks to believe it should be the best at every computational scenario.
Delphi's objective is to be the most productive software development
tool for a very broad audience of developers. The compiler is one
small part of that.
> >
> > It is too bad Danny Thorpe is no longer posting here, as he would
> > be able to authoritatively set you straight on the issue of
> > optimizations in Delphi code.
> >
>
I wish you people would quit invoking my name. Popping in here with a
big puff of smoke and a few lightning bolts is fun and all, but it
takes days to get the smell of sulfur out of my hair.
-Danny
-- Delphi Compiler Core: http://blogs.borland.com/dcc
- Next message: Danny Thorpe: "Re: Compiler optimisation"
- Previous message: TJC Support: "Re: Developer license"
- In reply to: Dejan Stankovic: "Re: Compiler optimisation"
- Next in thread: John Wester [Group W]: "Re: Compiler optimisation"
- Reply: John Wester [Group W]: "Re: Compiler optimisation"
- Reply: Per Larsen: "Re: Compiler optimisation"
- Reply: Allen Bauer: "Re: Compiler optimisation"
- Reply: Wayne Niddery [TeamB]: "Re: Compiler optimisation"
- Reply: Dejan Stankovic: "Re: Compiler optimisation"
- Reply: Captain Jake: "Re: Compiler optimisation"
- Reply: Lord Crc: "Re: Compiler optimisation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|