Jump to content

Talk:Peephole optimization

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lycurgus (talk | contribs) at 01:41, 22 June 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconComputer science Unassessed
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.
Things you can help WikiProject Computer science with:

untitled

I know the article is lacking in quality and clarity, but it's better than nothing. Wouter Lievens 12:38, 4 November 2005 (UTC)[reply]

Actually this is excellent. --Jorend 16:35, 14 March 2007 (UTC)[reply]


Your optimisation example is incorrect, as the value of a is not written back from the stack in the second example. If a where to be referenced later in the program, it would not be the correct value. However, if a was never accessed again, that would be a valid optimisation, but you would need to state that the compiler knew this was the case. Mattmilford 19:24, 16 October 2007 (UTC)[reply]


Is it possible for a compiler todo optimized loading of constants like this:

- i have the value 10000 in regX which is used no longer 
- i need the constant 20000 for the next operation
- instead of loading 20000 i do regX+= regX

This would save space in the L1 cache. I guess this *2 example is not very practical but if you use all instructions of a given architecture (like LEA on X86 for fast multiply) you could save some constant loading, and even more on 64 bit architectures where opcodesize would be opcode + 8 byte data. The drawback like with most optimizations would be much longer compiling times. —Preceding unsigned comment added by 94.222.5.89 (talk) 20:47, 25 January 2009 (UTC)[reply]

Removing redundant code example is wrong

When removing redundant POP/PUSH pairs where is it being considered that the call to the second function needs those registers with the right values? The first function call might have modified any of those registers and therefore POPs are needed to restore pre-call values to CPU registers. Then a series of PUSHes are needed to store those registers again to be able to restore values after the second call has finished. TWiStErRob (talk) 07:45, 3 June 2010 (UTC)[reply]

Replacement rules

The characterization of peephole optimization is far too broad. Constant folding, strength reduction, and dead code elimination are optimatizations in their own right. Furthermore, those optimizations often require information that is not available in just a peephole window.

Peephole optimization looks at a short sequence of instructions and replaces them with a better sequence.

I'd trim the list of "replacement rules". Glrx (talk) 19:15, 28 December 2010 (UTC)[reply]