[comp.lang.c] Register Usage

bs@linus.UUCP (Robert D. Silverman) (01/20/87)

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.
 
Bob Silverman