[fpc-devel] Planning refactor of x86 OptPass1MOV

J. Gareth Moreton gareth at moreton-family.com
Mon Apr 15 17:47:02 CEST 2024


Hi everyone,

While I'm starting to focus more on node-level optimisations, since they 
benefit more platforms and can produce better optimisations in some 
situations due to cross-platform support and things like register 
allocation, I'm thinking about refactoring and improving x86's 
OptPass1MOV routine for the following main reasons:

  * It has become a massive, monolithic Frankenstein's monster of an
    optmisation routine with lots of different optimisations and styles
    of optimisation that are a little difficult to track sometimes (this
    is partly a given though since about 25% of all x86 assembly
    language consists of a MOV instruction).  Some refactoring will make
    it more maintainable and potentially faster and smaller.
  * It's not as neat and far-reaching as, say, the equivalent routine
    for the AArch64 peephole optimizer, which utilises
    GetNextInstructionUsingReg that can produce more long-range
    optimisations under -O3.

In other news, pure functions are still waiting for some third-party 
testing although I've fixed a couple of bugs in the interim.  Currently, 
the main sticking point are that floating-point values are not being 
propagated (pure function analysis utilises constant propagation, 
deadstore removal and in-depth node optimisation to calculate output 
values).  Making a patch to enable this has revealed some shortcomings, 
notably how programs and tests behave when floating-point exceptions are 
enabled (operations where deterministic values are divided by zero are 
being replaced with constants equalling infinity instead of raising an 
exception) and also some inconsistent behaviour across platforms where 
the Currency type is concerned.  Nevertheless, things are coming together.

Kit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20240415/2388afa5/attachment.htm>


More information about the fpc-devel mailing list