As I know that in C we could use the keyword “register” to suggest to the compiler that the variable should be stored in the CPU register. Isn’t it true that all variables that involved in CPU instructions will be eventually stored in CPU registers for execution?
Share
The
registerkeyword is a way of telling the compiler that the variable is heavily used. It’s true that values must usually be loaded temporarily into registers to perform calculations on them. The name comes from the idea that a compiler might keep the variable in a register for the entire duration that it is in scope, rather than only temporarily when it is being used in a calculation.The keyword is obsolete for the purpose of optimisation, since modern compilers can determine when a variable is heavily used (and when it does not have its address taken) without help from the programmer.