Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!winchester!mash From: mash@mips.COM (John Mashey) Newsgroups: comp.arch Subject: Re: Compiler Costs Message-ID: <40052@mips.mips.COM> Date: 11 Jul 90 10:50:33 GMT Sender: news@mips.COM Reply-To: mash@mips.COM (John Mashey) Organization: MIPS Computer Systems, Inc. Lines: 68 Since this discussion pops up here every 6-9 months, maybe it's worth a shot at some generalizations, to put some structure around the flood of anecdotal examples and counter-examples. First MY anecdote: I wrote all of the C string library in assembler for the R2000 a long while back, because you ALWAYS do that when you do a new UNIX. THEN, after looking at the generated code from the standard C functions, we threw out most of the assmebly code, because the compiler was good enough that it wasn't worth QAing the assembly code. Generalizations: the following factors will encourage one to use assembly code (left) or compiled code (right). I think most of the anecdotes so far fit at least one of these. The interesting questions are: 1) Are there more good genralizations? 2) What kind of experiments can be done to quantify these more specifically? ASSEMBLER COMPILER 1. Old, non-optimizing compiler Modern, global optimizer, at least In scientific world, vectorizer/parallizer if appropriate. 2. Architecture/language mismatch Architecture/language well matched 2a. Architecture weird 2b. Language not expressive enough 3. One architecture target, forever Portability (as in some embedded) (as in UNIX commands) 4. Absolute speed requirement Premium on development cost, maintenance 5. Absolute space requirement Space costs, but no hard, low limit 6. Programming time is cheap Programming time is not cheap As usual, in a domain-of-discourse-confusion type of discussion, much of the arguments would disappear if people would preface their opinion by specifiying which domain they're living in (i.e., which of the attributes above apply to what they do.) ALso, it would probably encourage light, and reduce heat, if people would avoid statements of the form I haven't seen it so, it must not exist in favor of In domain X, it doesn't seem to exist. Does it elsewhere? In this light: a) People with RISCs, good optimizers, doing general-purpose code, using C or FORTRAN seldom write assembler code. b) People with CISCs are more likely to go to assembler, especially when using pcc-style compilers. Likewise, people using machineswith vector units, special graphics operations, unusual pipelines or some parallel architectures. c) People that need operations not easily expressed in popular languages go to assembler more often. d) Embedded control folks are more likely to use assembler. etc. Of course, it is the job of computer system designers to make systems for which the assembler/compiler tradeoff increasingly favors compilers, and the higher the level the better (i.e., do it in shell or awk ... or 4GLs, or whatever, if possible), but this doesn't mean that there are not sometimes good reasons for doing it in assembler some of the time..... Let's just hope that we can make it less often. -- -john mashey DISCLAIMER: UUCP: mash@mips.com OR {ames,decwrl,prls,pyramid}!mips!mash DDD: 408-524-7015, 524-8253 or (main number) 408-720-1700 USPS: MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086