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

2022-12-09 Thread J. Gareth Moreton via fpc-devel
Any word on testing and approval on the Assembly-level Common Subexpression Eliminator (using Sliding Window) over at https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/191? I know there's room for improvement in the future for sure.  I just hope it won't be prone to breaking like

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

2022-03-27 Thread J. Gareth Moreton via fpc-devel
It's done! https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/191 Whitepaper can be found as an attachment in that merge request. Go ham on trying to break it! It will likely need refactoring later, especially as I want to port it to AArch64 at some point to see how it affects

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

2022-03-11 Thread J. Gareth Moreton via fpc-devel
So far I haven't managed to do very accurate timing measurements - I'll try to resolve that and get more accurate figures, especially as I'm still writing up the whitepaper explaining everything before I make a merge request.  Compilation time I'm not hugely concerned about since this sliding

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

2022-03-11 Thread Flávio Etrusco via fpc-devel
Kudos! In the end, did it make much of a difference in the compilation time? Em sex., 25 de fev. de 2022 às 02:08, J. Gareth Moreton via fpc-devel escreveu: > > I did it! > > After a good week of work and getting things wrong, I finally found a > solution that works nicely and is extensible, at

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

2022-03-07 Thread J. Gareth Moreton via fpc-devel
Hey everyone.  I'm having a bit of difficulty with writing the whitepaper for this feature since I'm struggling to find the words to explain what I've done and why I've done it the way I've done it.  Of course it could mean it's too complicated, but I'm also possibly very out of practice or

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

2022-02-27 Thread J. Gareth Moreton via fpc-devel
I will need to refactor this feature later on, especially with names, because the data structure is not a true sliding window because it only operates over a subset of instructions that are added to a list based on whether they fit the criteria of what I call 'seed instructions'.  In future,

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

2022-02-27 Thread J. Gareth Moreton via fpc-devel
All tests passed successfully, including an extra addition that shaved another 5kb off the compiler!  Now the hard part... writing that whitepaper for everyone, since I think this is one of those times where it will be necessary. But if anyone wants to analyse and test it out before I make a

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

2022-02-25 Thread J. Gareth Moreton via fpc-devel
Fixed those bugs.  I forgot to check to see if the input registers (if they are registers) were identical when it came across an arithmetic instruction (this was because the code was extended from just handling shift and rotate instructions, which can only read from %cl). Gareth aka. Kit On

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

2022-02-25 Thread J. Gareth Moreton via fpc-devel
On 25/02/2022 08:29, Marco Borsari via fpc-devel wrote: This is very useful, thank you. I think FPC has an excellent register allocator, but frustrated on 32 bit by scarce resources and by the lack of reloading check. Unfortunately the equivalent procedure isn't optimised on i386-win32:

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

2022-02-25 Thread J. Gareth Moreton via fpc-devel
Well I'm not out of the woods yet, I've got one failure on x86_64-win64 and two on i386-win32: x86_64-win64: Failed to run webtbs/tw16040.pp 2021/09/13 08:19:30 i386-win32: Failed to run test/packages/bzip2/tbzip2streamtest.pp 2021/09/13 08:19:28 Failed to run webtbs/tw16040.pp 2021/09/13

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

2022-02-25 Thread Marco Borsari via fpc-devel
On Fri, 25 Feb 2022 05:08:48 + "J. Gareth Moreton via fpc-devel" wrote: > Almost every source file in the compiler and the RTL shows some kind of > improvement.  A lot of them are just redundant pointer deallocations, so > this will help with cache misses and the like - that aside though,

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

2022-02-24 Thread J. Gareth Moreton via fpc-devel
I did it! After a good week of work and getting things wrong, I finally found a solution that works nicely and is extensible, at least for x86.  A bit of refactoring and it can be ported to other platforms.  I'm just running the test suites to see if I can break things now.  Honestly the

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

2022-02-17 Thread J. Gareth Moreton via fpc-devel
That's useful to know, thanks.  Ideally I'd like to put it behind a kind of CSE compiler flag because this will add a degree of overhead to it and make compilation slower (currently I'm only doing it for -O3).  Currently I'm only tracking "mov (ref),%reg" and "lea (ref),%reg" instructions and

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

2022-02-17 Thread Jonas Maebe via fpc-devel
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

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

2022-02-17 Thread J. Gareth Moreton via fpc-devel
Hi everyone, So I've started experimenting with a new technique in the peephole optimizer for x86 platforms that I've named the Sliding Window.  The intention is to use it to help replace common blocks of code within a procedure, such as pointer dereferences.  So far I'm having a degree of