I admit I do wonder how hard maintenance will be. True, there is some more looking ahead, but it's not really any more complex than what it is already (e.g. take a look at OptPass1MOV in the trunk).
When it comes to debugging the peephole optimiser, one thing I did was write a function that wrote the assembly of the current block to the console, so I could visually see the commands ahead. It's not part of the submitted patches because it only works for i386 and x86_64 under Windows, but it's proven useful.
If there's interest, I can submit it as a separate patch, but it's not really suitable as a permanent fixture unless someone wants to try to make it a feature only enabled with debug defines.
Gareth aka. Kit
On Sat 01/12/18 18:57 , "J. Gareth Moreton"
sent:
Aw, okay. Well, post peephole is still a separate stage, since that prevents a lot of other optimisations (e.g. changing mov 0,%reg into xor %reg,%reg).
I'll start breaking it up into smaller chunks.
Gareth aka. Kit
On Sat 01/12/18 19:54 , Florian Klämpfl sent:
J. Gareth Moreton wroteThanks Bart,
I managed to get it to build after reinstalling the FPC compiler 3.0.4 -
it seems it was getting confused between two
different versions on my virtual machine - but after all that it does
look like a bug in my new code. I've managed to
get it to compile from a clean build and with a couple of modified files
that don't do anything drastic, so now I'll try
to isolate the issue and update my patch file. An overhauled peephole
optimizer is no use if it breaks Linux!
I had a quick look at the patch and I strongly recommend to split it in multiple patches which can be reviewed more
easily. This allows also to detect easier which change breaks things and also to measure which change increases speed
and which change is not needed.
In general, I am not happy with the merge of the four passes as it makes maintenance much harder.