[LCP]register question

Joachim Bauernberger bj at gmx.net
Mon Nov 19 21:38:25 UTC 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
I am just experimenting with some code to find out what are the benefits of 
declaring a variable as register int. are.

I have referred to some textbooks but all it says is that:
 
"You can declare register int in order to speed up some cpu intensive code. 
You should only declare them register inside a function (i.e. not global 
variables). Some of the register types will be used and some not depending 
how many registers are available in the CPU at the time..."

My question. When do I know that using register will gain me some processing 
speed. (Apart from when I am actually running the program ant checking with 
time) 

Is there really any benefit from declaring an int with register on modern 
Pentium class CPU's? 
Or is the compiler already smart enough to know when he should internally 
speed things up so it wouldn't really be necesarry with gcc?

Is there any drawbacks from using register (apart that i can not use &var) 
I.e if I use register somewhere where there would be no gain then this 
variable will nevertheless take up space in CPU?

Thanks & best regards,
Joachim
 
- -- 
You can get my public pgp key here:
http://foobar.gmxhome.de/pgp/joachim.html
PGP fingerprint:
25 96 E0 25 48 D9 8E 10  3C C0 48 E7 AF 5A E2 C6  A3 15 05 E6


-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQA/AwUBO/jdPK9a4sajFQXmEQJDyQCeNqqPcUjHR/TYAqN6S4Efs8hOaqEAnAgp
1F76dCxIN/ACqGccBIHpFRwV
=e9JV
-----END PGP SIGNATURE-----



More information about the linuxCprogramming mailing list