Xref: utzoo comp.arch:16967 comp.lang.misc:5102 Path: utzoo!attcan!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma From: toma@tekgvs.LABS.TEK.COM (Tom Almy) Newsgroups: comp.arch,comp.lang.misc Subject: Re: Compiler Costs Message-ID: <7764@tekgvs.LABS.TEK.COM> Date: 6 Jul 90 16:06:14 GMT References: <1797@apctrc.UUCP> Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy) Followup-To: comp.arch Organization: Tektronix, Inc., Beaverton, OR. Lines: 34 In article <1797@apctrc.UUCP> zrra07@backus (Randall R. Appleton) writes: >I have a simple question: Does anyone know what sort of speed-up >on gets by going from a good implementation of some algorithm in a >third generation language (C, Fortran) and a good optimizing compiler >to hand-coded assembly? Simple Answer: That depends... If the program implements an algorithm that is well suited for the compiler (standard matrix multiplication in Fortran, for example) or is a program that is a standard benchmark for which *every* compiler writer optimizes, you might not see any improvement at all. If fact it might run slower if you are not as clever as the compiler writer! On the other hand, if the algorithm cannot be efficiently represented in the language (string manipulation in Fortran, complex numbers in C) or there are special cpu instructions you can take advantage of that the compiler doesn't, then you can get major improvements, even order of magnitude. In general, there is only a small portion of the code that uses most of the execution time, and by coding those portions in assembler, you can get most of the assembler performance while still enjoying the convenience of a high level language for the bulk of the code. If you are concerned about code size, there still is a major improvement to be offered with assembler, typically because you can custom tailor subroutine calling conventions and register usage. But then again many modern compilers let you do the same. (I hope this won't be the start of some "language war" :-) Tom Almy toma@tekgvs.labs.tek.com Standard Disclaimers Apply