te common code paths to reduce testing. This suggestion may seem like it is too obvious to mention, but we have found that as an application goes through a series of revisions, additional tests and branches can be introduced. If an application has undergone updates to the logic, you should review the code path to be sure that unnecessary tests and branches have not been introduced. What you may find in an application is as sequence like this: if (cond) { common path here (x==1) do something This code fragment can be consolidated to: if (cond) { common path here do something Avoid direct control register bit masking. Use optimized macros for bit operations such as BitIsSet and BitIsClear, even if you need to custom define them. These macros can be optimized to produce efficient code. Also, using these macros will isolate your application from later implementation changes. If more efficient implementations of these macros are devised, or bit positions need to shift for some reason, the applications will not need to change to take advantage of the improvements. Avoid use of global variables, file statics, and pointers wherever possible. A local variable is a lot easier for the compiler to disambiguate, SO it usually gets promoted to a register for the lifetime of the routine. This can save cycles for each reference to the variable by avoiding load and store operations. In some cases, it may be beneficial to copy some of these variables to locals. For example: // Compiler can't tell if someOtherGlobal and *pmight overlap SO it generates // a load *p every time through the loop. foo (int* p) for (expensive loop) { if (someOtherGlobal = ===p){ do something someOtherGlobal = something. Chapter 9 Software performance 325 // If you know that they never overlap, copy *p before entering the loop. // Here compiler knows local can never intefere someOtherGlobal and should // put local into a register avoiding a load each time through the loop. foo (int*p) int local = *p; for (expensive loop) { if (someOtherGlobal = local) { d