Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!princeton!allegra!ulysses!faline!bellcore!mrevox!whuxcc!lcuxlm!whuts!houxm!homxc!dwc From: dwc@homxc.UUCP Newsgroups: comp.arch Subject: re: subroutine frequency Message-ID: <1881@homxc.UUCP> Date: Sat, 24-Jan-87 00:42:02 EST Article-I.D.: homxc.1881 Posted: Sat Jan 24 00:42:02 1987 Date-Received: Sat, 24-Jan-87 16:03:45 EST Organization: AT&T Bell Laboratories, Holmdel Lines: 35 >There is some ongoing discussion about register usage in programs. >While it is true that one generally wants to keep as many variables >as possible (especially such things as loop indices!) there are times >when using a lot of registers can actually slow things down. >This arises when a subroutine shares registers in common with its >parent. If the routine is called many times the cost of saving and >restoring registers during the call and return can offset any >speed savings thru register usage. I have actually seen this >phenomenon occur quite strikingly in programs that require >multi-precision arithmetic. The cost of saving the registers for >a multi-precise add or multiply routine (say) when they are called >~10^8 or 10^9 times can greatly slow down a program. am i missing something or does the frequency of calls not matter? if it is slower to save the registers over many calls, is it not slower to save the registers for just one call? isn't it just an issue of memory references within the routine? if the register saves result in a greater number of references than without the register saves (i.e. register variables), then it is not worth it no matter how many times the routine is called. and doesn't this only show up with assembly level programming? do compilers take the time to keep track of which registers have been used and only save the 'dirty' ones or do most call and return mechanisms save the entire register set on the stack? any one know? if not, i guess this is still a valid issue in c, since you can declare register variable within any block (is this the correct term?). danny chen ihnp4!homxc!dwc