Path: utzoo!utgpu!cunews!cognos!alzabo!andras From: andras@alzabo.ocunix.on.ca (Andras Kovacs) Newsgroups: comp.arch Subject: Re: Optimising C compiler question Message-ID: <1991Apr11.003431.24918@alzabo.ocunix.on.ca> Date: 11 Apr 91 00:34:31 GMT References: <1991Apr8.193155.3911@vax5.cit.cornell.edu> Distribution: comp Organization: Brian's XENIXlings, Ottawa, Canada Lines: 31 umh@vax5.cit.cornell.edu writes: >C has provision for register variables, which are supposed to run faster than >standard variables. How come one never sees register variables in any code? >Are modern RISC compilers sufficiently good that they automatically make >sensible choice of register variables? Can I make my code run slower by using >them? My compiler is Norcroft ARM C V1.54A (admittedly an early release). It puts the first 10 variables into registers and the others are loaded/stored on demand. Now using 'register' means the same as moving the variable declaration into the first 10. Would be the compiler better, it would analyze the code and decide register usage based on that analysis; but then 'register'-ing a var could have two possible effects: 1, It is obeyed - but then better if you know what you are doing otherwise you can indeed slow down the code, or 2, Disregarded - because the compiler trusts itself that indeed it knows the best allocation scheme. I assume that good compilers use the second approach - not out of disregard to the programmer but either the programmer asks for the right var to be register and then it is already; or the compiler KNOWS that the register var would cost execution speed and then what is the point of using it? I hope my view is not too simplistic; could someone with actual experience follow up on the subject? Andras -- Andras Kovacs andras@alzabo.ocunix.on.ca Nepean, Ont.