Please note: I was originally going to title this question "When to use registers in C?", however it seems like someone already beat me to the punch. However, the way that question was asked when compared to the title is a bit misleading, and I believe this question is unique and not a dupe of it.
Whereas, that question really ought to have been titled "Are register variables really faster?", I actually want to know when one should be using registers. It's obvious to me that they are in fact faster, but obviously your CPU only has so many register on chip, and so you are limited by what you can store on them.
So I ask: How do I select which variables should be qualified with register? Variables that are used with a certain frequency? Variables of a particular size or type? Variables that are used in compute-bound problems? Something else?
I look at it like this: to every product owner or stakeholder, every single bug or feature is "top priority" and critical. But if you really analyse their needs, you will see that some features are in deed more "top priority" than others. With code, you want it to run as fast as possible, and so I'm sure every variable is a candidate for optimization/performance tuning. But I would imagine that if you really analyse a program (or the C compiler for that matter, let's assume gcc), I'm sure there's a way to determine which variables are best suited for use with register.