Peephole optimization
Peephole optimization is an optimization technique performed on a small set of compiler-generated instructions, known as a peephole or window,[1][2] that involves replacing the instructions with a logically equivalent set that has better performance.For example: The term peephole optimization was introduced by William Marshall McKeeman in 1965.[5] The following Java bytecode: can be replaced with the following which executes faster: As for most peephole optimizations, this is based on the relative efficiency of different instructions.The following source code: is straightforwardly compiled to: but can be optimized to: If the compiler saves registers on the stack before calling a subroutine and restores them when returning, consecutive calls to subroutines may have redundant stack instructions.Assuming that subroutine _ADDR2 does not depend on previous register values, removing all of the redundant code in the example above would eventually leave the following code: The dictionary definition of peephole optimization at Wiktionary