The latest in the series of blog posts on optimizing embedded software with the aim of improving (i.e. reducing) worst-case execution times focuses on global variables and aliasing.
Software optimization techniques which improve worst-case execution times #14: Global Variables and Aliasing
Global variables can be modified indirectly via pointers or function calls. This typically means that the compiler cannot keep the value of a global variable in a register; it must write the value back to memory and re-load it each time it is used. For this reason, the use of global variables should be avoided in worst-case hotspot code. If the use of global variables is unavoidable, then it can be more efficient to cache the value into a local variable, which is then used extensively before its value is written back into the global variable.