Re: register variables in C.

bliss@sp64.csrd.uiuc.edu (Brian Bliss)
Fri, 1 May 1992 20:20:20 GMT

          From comp.compilers

Related articles
[5 earlier articles]
Re: register variables in C. bart@cs.uoregon.edu (1992-04-29)
Re: register variables in C. jeff@dsp.sps.mot.com (1992-04-30)
Re: register variables in C. Brian.Scearce@Eng.Sun.COM (1992-04-30)
Re: register variables in C. pardo@cs.washington.edu (1992-05-01)
Re: register variables in C. metaware!miker@uunet.UU.NET (1992-05-01)
Re: register variables in C. preston@dawn.cs.rice.edu (1992-05-01)
Re: register variables in C. bliss@sp64.csrd.uiuc.edu (1992-05-01)
Re: register variables in C. ressler@cs.cornell.edu (1992-05-02)
Re: register variables in C. stephen@estragon.uchicago.edu (1992-05-04)
Re: register variables in C. macrakis@osf.org (1992-05-04)
Re: register variables in C. gnb@bby.oz.au (1992-05-04)
Re: register variables in C. cliffc@cs.rice.edu (1992-05-06)
| List of all articles for this month |

Newsgroups: comp.compilers
From: bliss@sp64.csrd.uiuc.edu (Brian Bliss)
Keywords: C, registers, optimize
Organization: UIUC Center for Supercomputing Research and Development
References: 92-04-125 92-05-003
Date: Fri, 1 May 1992 20:20:20 GMT

[with respect to "register" declarations and related optimizer hints]


just my 3 cents worth:


$.01 : declare the variables that are most important to put into registers
                first; compiler might try to keep n variables in registers, but when
                the n+1 st declaration for a register variable is seen, it is stored
                in memory.


$.02 : declare variables in the innermost scope in which they are active,
                and use {} frequently to reduce the scope of temporaries. Doing
                so will reduce optimization time drastically, can only increase
                performance of less-than-optimal optimizers, especially if the
                optimizer has a "time-out" switch (like many chess programs), where,
                if iterative optimization becomes too complex, the optimizer will,
                iterate until a time/count limit. Doing so may also force a compiler
                to spill a register variable in an outer scope to memory while the
                newly-declared register variable in the inner scope occupies the
                register, which is usually what one would want.


$.03 : if you know a machine has, say 3, registers for local temporaries,
then put the following in a header file:


                #define register1 register
                #define register2 register
                #define register3 register
                #define register4
                #define register5
                        .
                        .
                        .


                then declare the local var that is most important to put in a
register with register1, the second most important with register2,
etc.




On my wish list:


                there would be a construct registerof(local) or locationof(local)
                that you could use within asm stmts to access the storage location
                of <local>, and not have to disable optimizations for the entire
                subroutine when you use asm's, just because the optimizer allocates
                registers in an unpredictable manner.


bb
[Most of the C compilers I know have some sort of hack to let you splice
register or local names into asm's. -John]
--


Post a followup to this message

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