Quantcast
Channel: User CPlus - Programming Language Design and Implementation Stack Exchange
Viewing all articles
Browse latest Browse all 66

How do modern compilers choose which variables to put in registers?

$
0
0

C has the register keyword, originally designed as a hint to the compiler that a variable should be placed in a register rather than on the stack. However this is generally considered an unneeded feature in this day and age:

Most modern compilers do that automatically, and are better at picking them than us humans.

Intuitively, a variable that is used a lot in a lifetime would be a register, at least to a human programmer such as myself. But if modern compilers are better at picking them than us humans as the linked answer suggests, what heuristics/tests do they use to determine what should go into a register, besides having a short lifetime and/or being accessed very frequently?


Viewing all articles
Browse latest Browse all 66

Trending Articles