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 94.222.5.89 (talk) at 20:47, 25 January 2009 (question to experts). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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.