Talk:Peephole optimization
Appearance
I know the article is lacking in quality and clarity, but it's better than nothing. Wouter Lievens 12:38, 4 November 2005 (UTC)
- Actually this is excellent. --Jorend 16:35, 14 March 2007 (UTC)
- 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)
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.