Board index » delphi » Re: Compiler optimisation
Andrew Rybenkov
![]() Delphi Developer |
Andrew Rybenkov
![]() Delphi Developer |
Captain Jake
![]() Delphi Developer |
2005-01-21 12:24:11 PM
Re: Compiler optimisation
Dejan Stankovic <XXXX@XXXXX.COM>writes
<XXXX@XXXXX.COM> QuoteIf I am not mistaken Delphi doesn't have many optimizations. wouldn't have that kind of speed if it had few optimizations, because I know that the VC++ compile had quite a few optimizations. The only one QuoteI know it has is peephole. Intel's compilers, on the other hand, are don't get to choose which optimizations apply, you have to choose all or nothing, but the optimizations are roughly the same as in a VC++ compile. By the way, IIRC there was a big speed difference in VC++ code between the Intel and AMD chips when you ran optimized code on them, with the AMD chips being much much slower. That leads me to believe that the VC++ optimizer was Intel-specific too, just like Intel's C++ compilers are. It would be interesting to compare code speed for Intel C++ versus Delphi on non-Intel chips, or on old Intel chips. Delphi produced code that was optimized for Cyrix, Intel and AMD. 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. -- ***Free Your Mind*** Posted with JSNewsreader-BETA 0.9.4.369 |
JED
![]() Delphi Developer |
2005-01-21 12:43:12 PM
Re: Compiler optimisation
Captain Jake writes:
QuoteIt is too bad Danny Thorpe is no longer posting here, as he would be Although he's probably knee deep in generics (pure speculation) -- QC Client: www.alphalink.com.au/~jed/QC/ Blog: jedqc.blogspot.com/ Configure Delphi the way you want it to be: www.alphalink.com.au/~jed/dcm.htm Checkout my code central submissions for D2005 cc.borland.com/ccweb.exe/author |
Captain Jake
![]() Delphi Developer |
2005-01-21 12:49:35 PM
Re: Compiler optimisation
JED <XXXX@XXXXX.COM>writes
<XXXX@XXXXX.COM> QuoteHopefully he's coding a few more (optimizations) into the compiler Quote
-- ***Free Your Mind*** Posted with JSNewsreader-BETA 0.9.4.369 |
Dejan Stankovic
![]() Delphi Developer |
2005-01-21 03:30:00 PM
Re: Compiler optimisation
Captain Jake writes:
QuoteDejan Stankovic <XXXX@XXXXX.COM>writes Keep in mind that Delphi is one-pass compiler (apparently). This limits number of possible optimizations to ones that do not operate on intermediate code. Furthermore, there are three different levels of intermediate languages upon which various optimizations are performed. For your reference, following is, as complete as I could make it, list of all optimizations that are used in todays compilers. -Aggregation of global references -Algebraic simplifications, including reassociations -Basic-block and branch scheduling -Branch optimizations and conditional moves -Branch prediction -Code hoisting -Constant folding -Control-flow optimizations -Data prefetching -Data-cache optimizations -Dead-code elimination -Global value numbering -In-line expansion -Induction-variable removal -Induction-variable strength reduction -Instruction prefetching -Interprocedureal constant propagation -Interprocedureal register allocation -Intraprocedureal instruction cache optimization -Leaf-routine optimization -Linear-function test replacement -Local and global common-subexpression elimination -Local and global copy propagation -Loop-invariant code motion -Machine idioms -Partial-redundancy elimination -Procedure integration -Procedure specialization and clonning -Scalar replacement of aggregates -Scalar replacement of array references -Shrink wrapping -Software pipelining, with loop unrolling, variable expansion, register -renaming and hierarchical reduction -Sparse conditional constant propagation -Tail call optimization, including tail recursion elimination -Tail merging -Unnecessary bounds checking elimination Keep in mind that even very good compilers implement only a small number of those and that not all of those are speed optimizations. 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. QuoteThe only one about pipeline. As for AMD vs. Intel you might be right. If MS compiler does pipeline optimization, this wouldn't work on AMD. I gues they go by the number of usres that have Intel as opposed to AMD. 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. QuoteIt would be interesting to compare code speed for Intel C++ versus Delphi on Dejan |
Per Larsen
![]() Delphi Developer |
2005-01-21 07:44:44 PM
Re: Compiler optimisationQuoteFor your reference, following is, as complete as I could make it, list improve the quality of the code considerably. You should have seen the code that TurboPascal 3 emitted. It was horrible. Unfortunately, the optimizer doesn't appear to have received much work, if at all (other than possibly necessary support for new language constructs), since Delphi 2. I don't know the precise meaning of all the optimizations you list, but I do know that Delphi does at least some of: Quote-Algebraic simplifications way better than TP3) - Unreachable code elimination (note that this is different from dead-code elimination, which it doesn't do) - Per |
Dejan Stankovic
![]() Delphi Developer |
2005-01-21 08:11:29 PM
Re: Compiler optimisation
Per Larsen writes:
QuoteQuite a list. I will admit that the optimizer in the Delphi compiler is not QuoteI don't know the precise meaning of all the optimizations you list, but I do every compiler does them. Quote
eliminates redundant cases. I didn't check Andrews statement (few posts before this one), but if it is correct than it doesn't do very well here. Quote- Unreachable code elimination (note that this is different from dead-code is correctly eliminated, this is not (D6): Exit;//Or Break or Continue Statement; I would like to say that I do like Delphi and I don't mind too much it's lackings, but we need to face reality. Delphi is a bit outdated compiler (by Delphi here I mean Win32 compiler, not .NET). Quote- Per |
Anders Isaksson
![]() Delphi Developer |
2005-01-21 09:06:54 PM
Re: Compiler optimisation
On Fri, 21 Jan 2005 18:30:00 +1100, Dejan Stankovic
<XXXX@XXXXX.COM>writes: QuoteKeep in mind that Delphi is one-pass compiler (apparently). (same as:) groups.google.com/groups&lr=&selm=3f2dd72a%241%40newsgroups.borland.com&rnum=1 -- Anders Isaksson, Sweden BlockCAD: w1.161.telia.com/~u16122508/proglego.htm Gallery: w1.161.telia.com/~u16122508/gallery/index.htm |
Per Larsen
![]() Delphi Developer |
2005-01-21 09:13:34 PM
Re: Compiler optimisation
"Dejan Stankovic" <XXXX@XXXXX.COM>writes
QuoteYou do realise that all except Inlining and Machine idioms are QuoteDelphi is a bit outdated compiler (by Delphi here I mean Win32 compiler, to see that change, but Borland's emphasis in the past has always been compile speed over final code speed/size, and granted some of the analysis required by the more advanced optimization algorithms does take significant time to do - even on today's hardware. However, saying that the compiler is outdated is missing the mark in this context, IMHO. After all, the theory behind nearly all of the optimizations listed has been known for 30+ years. - Per |
Dejan Stankovic
![]() Delphi Developer |
2005-01-21 11:29:54 PM
Re: Compiler optimisation
Anders Isaksson writes:
Quote>Keep in mind that Delphi is one-pass compiler (apparently). |
Paul Dolen
![]() Delphi Developer |
2005-01-21 11:37:23 PM
Re: Compiler optimisationQuoteIt is too bad Danny Thorpe is no longer posting here, as he would be able to |
Kostya
![]() Delphi Developer |
2005-01-21 11:49:26 PM
Re: Compiler optimisationQuoteHowever, saying that the compiler is outdated is missing the mark in this should certainly take care of floating point that sucks. Kostya |
John Jacobson
![]() Delphi Developer |
2005-01-22 02:33:40 AM
Re: Compiler optimisation
"Paul Dolen" <XXXX@XXXXX.COM>writes
Quote>It is too bad Danny Thorpe is no longer posting here, as he would be able |
Danny Thorpe
![]() Delphi Developer |
2005-01-22 04:02:01 AM
Re: Compiler optimisation
Dejan Stankovic writes:
Quote
QuoteThis optimizations. Quote
Quote-Aggregation of global references Quote-Algebraic simplifications, including reassociations at the edges. Quote-Basic-block and branch scheduling Quote-Branch optimizations Quoteand conditional moves Quote-Branch prediction Quote-Code hoisting Quote-Constant folding Quote-Control-flow optimizations Quote-Data prefetching Quote-Data-cache optimizations Quote-Dead-code elimination Quote-Global value numbering Quote-In-line expansion Quote-Induction-variable removal Quote-Induction-variable strength reduction Quote-Instruction prefetching Quote-Interprocedureal constant propagation Quote-Interprocedureal register allocation Quote-Intraprocedureal instruction cache optimization Quote-Leaf-routine optimization Quote-Linear-function test replacement Quote-Local and global common-subexpression elimination Quote-Local and global copy propagation Quote-Loop-invariant code motion Quote-Machine idioms Quote-Partial-redundancy elimination Quote-Procedure integration Quote-Procedure specialization and clonning Quote-Scalar replacement of aggregates Quote-Shrink wrapping Quote-Software pipelining, with loop unrolling, variable expansion, Quote-Sparse conditional constant propagation Quote-Tail call optimization, including tail recursion elimination Quote-Tail merging Quote-Unnecessary bounds checking elimination Quote
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. ;> QuoteNow going back to Delphi. It has always been a solid compiler with it many times faster than the more traditional compiler models that were originally concieved for batch processing of punched cards. Quote
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. Quote> takes days to get the smell of sulfur out of my hair. -Danny -- Delphi Compiler Core: blogs.borland.com/dcc |
Danny Thorpe
![]() Delphi Developer |
2005-01-22 04:03:23 AM
Re: Compiler optimisation
Paul Dolen writes:
QuoteI hadn't seen Danny here in a bit, but what's this about "no longer Delphi Compiler Core: blogs.borland.com/dcc |