Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site celerity.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!talcott!panda!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcc3!sdcc6!celerity!ps From: ps@celerity.UUCP (Pat Shanahan) Newsgroups: net.lang.c Subject: Re: Re: register variables Message-ID: <299@celerity.UUCP> Date: Mon, 1-Jul-85 14:04:50 EDT Article-I.D.: celerity.299 Posted: Mon Jul 1 14:04:50 1985 Date-Received: Wed, 3-Jul-85 09:34:43 EDT References: <472@crystal.UUCP> <365@umcp-cs.UUCP> <38@ucbcad.UUCP> Distribution: net Organization: Celerity Computing, San Diego, Ca. Lines: 48 > Speaking of register variables -- does anybody know what various C > compilers do when you don't declare variables as register, but there > are spare registers to use? From what I hear, neither ccom nor c2 are > smart enough to put local variables in registers when they are > available. It seems that it would be simple to just take the first few, > or even the most heavily used local variables that don't ever get &'d > and make them register... > > Wayne Release 2.1 of the Celerity C1200 C compiler implements simple automatic register allocation for optimized compiles. Declared register variables have priority for allocation of registers. The remaining registers are allocated for an arbitary selection of the simple automatic variables, excluding any that have their addresses calculated. Automatic register allocation is particularly important for the C1200, because it provides an unusually large number of registers and a wide range of types of register variables. The C1200 supports all integer types and both floating point types in registers. Depending on the number of registers that the function needs for arguments, up to 26 integer registers can be allocated. The C1200 also has 15 floating point registers, of which the C compiler will allocate up to 9 for variables. Each floating point register can contain either a float or a double. This large supply of registers is very desirable for big FORTRAN subroutines. The C compiler makes no attempt to do usage based allocation and allocates registers for the whole scope of the variables, since the number of registers exceeds the number of suitable variables in most C functions. For example, all suitable automatic variables in the C compiler first pass fit into registers. Excessive register allocation is not a concern on the C1200, because the architecture supports rapid saving and restoring of blocks of registers. The C1200 C compiler first pass user time improved by 5% due to automatic register allocation. This is probably typical of UNIX code that already has many register declarations, and that does not use floating point much. The largest improvement I have seen so far was in a small artificial benchmark. The user time reduced from 13.4 seconds to 8.6 seconds. Obviously, there would be no improvement in a program that already had all possible variables declared register. -- ps (Pat Shanahan) uucp : {decvax!ucbvax || ihnp4 || philabs}!sdcsvax!celerity!ps arpa : sdcsvax!celerity!ps@nosc