Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Is the register keyword really useful?

Author: Robert Hyatt

Date: 19:44:33 10/30/00

Go up one level in this thread


On October 30, 2000 at 22:40:50, Pham Minh Tri wrote:

>I see that many programs (like GNU, Crafty) use the register keyword too many -
>for almost all integer valuables. This keyword indicates the CPU try to load a
>valuable into a register, if posible, and hope that program may run little
>quicker.

On modern compilers, using "register" is worthless.  The compiler is very good
at doing this automatically.  But on some older compilers, it can make a big
difference...

The main thing it saves is that it tells the compiler "once this procedure
is finished, there is no need to store any of these values, even if they
are global values."

It can save a few register spills here and there.

>
>However, in my view and in the PC machine, it is hopeless or harmful. The number
>of registers is very small, and the number of available ones is smaller, and the
>number of integer valuables at one time is usually several bigger than them. As
>a result, instead of doing something directly in the memory of a valuable, the
>CPU has to load it into a register to do this work then store it into memory for
>making the register be available for the next command. It turns out, many extra
>instructions of loading and storing will make program little slower.


It doesn't hurt on the PC.  The "register" specification is given as "advisory"
anyway, which means you are asking the compiler to hold the value in a register,
you aren't "demanding" it...



>
>I know this difference is very small and almost can not be measured (and some
>compilers like Visual C ignore this keyword) so people could program without
>concerning about it.
>
>Pham



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.