Newsgroups: | comp.compilers |
From: | mps@dent.uchicago.edu (Michael Spertus) |
Keywords: | assembler, optimize, performance |
Organization: | University of Chicago -- Academic & Public Computing |
References: | 93-10-114 93-10-123 |
Date: | Thu, 28 Oct 1993 14:51:04 GMT |
I write most of my programs in high level languages. Usually C++. My
definition of high level is whatever states the problem best. Where
performance is important I use a profiler to discover where the program or
class is spending its time. Then I may recode the hot spots in assembler
often starting from the code generated by the compiler.
Generally this produces a small but useful improvement but there are
stunning exceptions. The best is multiple precision arithmetic functions.
C does not let you get at the carry flag or the overflow flag. This makes
writing multi precision arithmetic in C harder than doing the same job in
assembler. The best way (on 80x86s) is to do it a byte at a time and look
at the top of a word. In assembler everything is a word at a time and much
more readable and direct. The result is about 5 times faster.
There are stories like this for every language (with the possible
exception of Cobol) some problem so well suited to the language that
everything else looks stupid. By the way I did not spend time worrying
about pipelining or getting every last cycle down. I tried to write the
most direct and readable code. It was more direct and readable in
assembler than in any other language but Icon where it would be too slow.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.