Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: comp.lang.c Subject: Re: Available No. of Registers Message-ID: <3959@utcsri.UUCP> Date: Tue, 20-Jan-87 12:12:31 EST Article-I.D.: utcsri.3959 Posted: Tue Jan 20 12:12:31 1987 Date-Received: Tue, 20-Jan-87 23:48:43 EST References: <3950004@nucsrl.UUCP> <83@ucdavis.UUCP> <2250@jade.BERKELEY.EDU> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 41 Summary: In article <2250@jade.BERKELEY.EDU> mwm@eris.BERKELEY.EDU (Mike Meyer) writes: >There is a false implication in the above: that it doesn't hurt to add >register declerations. There is at least one compiler out there that >effectively allocates registers from the last declared instead of the >first, so that blindly adding registers to code can slow the generatred >code down. Furthermore, in most run-time environments, functions are expected to preserve that set of registers which are available for 'register' vars. So if you declare six register variables, they must be pushed on entry and popped on exit. If the function in question does very little, this pushing and popping may become a significant portion of the function's execution time. It may seem silly to want a large number of register vars on a function that does very little. This problem applies, though, to any function that *Usually* does very little: /* update the data structure */ Update(){ register foo *first, *last, *current; register int loops, item_count, *bats_knees; extern int Dirty; /* dirty flag */ extern ... if(Dirty){ ... mucho code using register vars ... Dirty = FALSE; } } Assume Update() is called very frequently, but that Dirty is false on 98% of these calls. Then it looks bad, no? A fix might be to remove the 'Dirty' test from Update(), and use if(Dirty)Update(); whenever Update() was called. -- ---------------------------------------------------------------------- Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg Have vAX, will hack...