Re: Folk Theorem: Assemblers are superior

mchapman@eis.k8.rt.bosch.de (Michael Chapman K8/EIS1. Tel. 1662)
Tue, 2 Nov 1993 12:16:28 GMT

          From comp.compilers

Related articles
re: Folk Theorem: Assemblers are superior to Compilers jm@tao.univ-paris8.fr (1993-10-27)
Re: Folk Theorem: Assemblers are superior mchapman@eis.k8.rt.bosch.de (1993-11-02)
| List of all articles for this month |
Newsgroups: comp.compilers
From: mchapman@eis.k8.rt.bosch.de (Michael Chapman K8/EIS1. Tel. 1662)
Keywords: C, optimize
Organization: Robert Bosch GmbH., Reutlingen, Germany.
References: 93-10-116
Date: Tue, 2 Nov 1993 12:16:28 GMT

jm@tao.univ-paris8.fr (Jean Mehat) writes:
>At least for C, what makes the compiler (relatively) inefficient is that
>the functions are compiled independently. It forbids register allocation
>across function calls. It constrains the compiler to make pessimistic
>assumptions on the register usage by the called functions. Didn't Ritchie
>accounted for a 10% loss when the Unix kernel was rewritten in C?


Who says so????


There is nothing in 'C' or in any standard for 'C' which prevents the
compiler from optimizing the program in one go or says that each function
must be compiled seperately. There is also nothing which prevents the
compiler inlining functions to its hearts content (or from factoring
common subexpressions into functions).


I think there is a MIPS compiler which actually does global optimization.
It first munches each individual source file to some internal form (I
don't know at what level), and then during the 'ld' phase actually
compiles the program with truly global optimization.


It is an approach we are using here for a cross compiler for 'C' for a
microcontroller which has a variable length instruction coding for all
jump and call instructions (which are all relative). During the classical
'ld' phase we actually sort the functions into an order (we have not yet
found a sensible algorithm to find the optimal order) which minimises the
total length of code. It then compacts the program to its shortest length
by optimally coding all the offsets (a multipass transformation).


Memory references for data are similiar. We allocate variable addresses
according to number of references in order to minimise the lengths of
addresses used to refer to data.


This of course requires lots of memory (which is why it was not done on
the PDP 11 for the PDP 11). This is no problem for a workstation
generating code for a micro controller which has 64KB memory.


------------------------------------------------------------------------------
Mike Chapman e-mail: mchapman@eis.k8.rt.bosch.de (office)
fax: (+49) 7121/35-1746 Mike.Chapman@isis.seicom.de (home)
tel: (+49) 7121/35-1662 (office)
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.