Résumé
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; and 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 might use a hardware addressing mode that accomplishes the same result with one instruction. The term peephole optimization was introduced by William Marshall McKeeman in 1965. Common techniques applied in peephole optimization: Null sequences – Delete useless operations. Combine operations – Replace several operations with one equivalent. Algebraic laws – Use algebraic laws to simplify or reorder instructions. Special case instructions – Use instructions designed for special operand cases. Address mode operations – Use address modes to simplify code. There can be other types of peephole optimizations. The following Java bytecode aload 1 aload 1 mul can be replaced by aload 1 dup mul This kind of optimization, like most peephole optimizations, makes certain assumptions about the efficiency of instructions. For instance, in this case, it is assumed that the dup operation (which duplicates and pushes the top of the stack) is more efficient than the aload X operation (which loads a local variable identified as X and pushes it on the stack). Another example is to eliminate redundant load stores.
À propos de ce résultat
Cette page est générée automatiquement et peut contenir des informations qui ne sont pas correctes, complètes, à jour ou pertinentes par rapport à votre recherche. Il en va de même pour toutes les autres pages de ce site. Veillez à vérifier les informations auprès des sources officielles de l'EPFL.