[fpc-devel] Prototype optimisation... Sliding Window

Jonas Maebe jonas at freepascal.org
Thu Feb 17 22:38:37 CET 2022


On 17/02/2022 20:25, J. Gareth Moreton via fpc-devel wrote:
> P.S. The term "sliding window" comes from the LZ77 compression algorithm 
> and is used to track repeated sequences in ZIP files, among others. This 
> prototype optimisation essentially uses the same construct, but built 
> for instructions instead of individual bytes.

The usual term for this kind of optimisations is common subexpression 
elimination (CSE). We used to have one at the assembler level for i386 
(my first main contribution to the compiler), but removed it in the end 
because it was extremely prone to breaking — even more so than the 
peephole optimiser. This happened in 
a04cae2c4ba32bc5c7a8461b5851dee8e70c272b (it was supposed to have 
happened in 1b439307490861afd739ba5a48dc175f09727a89, but I made a mistake).

It doesn't mean it can't be implemented in a robust way, but I can 
guarantee from experience that it is extremely hard.


Jonas


More information about the fpc-devel mailing list