language-icon Old Web
English
Sign In

Peephole optimization

Peephole optimization is an optimization technique performed on a small set of compiler-generated instructions; the small set is known as the peephole or window. Peephole optimization involves changing the small set of instructions to an equivalent set that has better performance. For example, instead of pushing register A onto the stack and then immediately popping the value back into register A, a peephole optimization would remove both instructions. Instead of adding A to A, a peephole optimization might do an arithmetic shift left. Instead of multiplying a floating point register by 8, a peephole optimization might scale the floating point register's exponent by 3. Instead of multiplying an index by 4, adding the result to a base address to get a pointer value, and then dereferencing the pointer, a peephole optimization may use a hardware addressing mode that accomplishes the same result with one instruction. Peephole optimization is an optimization technique performed on a small set of compiler-generated instructions; the small set is known as the peephole or window. Peephole optimization involves changing the small set of instructions to an equivalent set that has better performance. For example, instead of pushing register A onto the stack and then immediately popping the value back into register A, a peephole optimization would remove both instructions. Instead of adding A to A, a peephole optimization might do an arithmetic shift left. Instead of multiplying a floating point register by 8, a peephole optimization might scale the floating point register's exponent by 3. Instead of multiplying an index by 4, adding the result to a base address to get a pointer value, and then dereferencing the pointer, a peephole optimization may use a hardware addressing mode that accomplishes the same result with one instruction. Common techniques applied in peephole optimization:

[ "Compiler correctness", "Program optimization", "Optimizing compiler", "Peephole", "Code generation" ]
Parent Topic
Child Topic
    No Parent Topic