[Patch / Refactor] RemoveCurrentP optimisations
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch adds a new version of RemoveCurrentP that, along with the current functionality, will also set p to the specified parameter instead of calling GetNextInstruction. This serves to reduce the number of calls to GetNextInstruction when the next instruction is already known (often the case with a number of peephole optimisations).
Steps to reproduce:
Apply patch, confirm all compilers build correctly, and also confirm that the binaries produced with the compilers do NOT change (pure refactor).
Additional information:
The existing version of RemoveCurrentP that takes only a single parameter has not changed. The new version takes a second paramter (declared as "const hp1: tai") but doesn't return a result. Calls to RemoveCurrentP where the next instruction is known have been replaced, as well as a more complex block in the AVR peephole optimiser where RemoveCurrentP was called 3 times sequentially - this has been changed to removing two of the instructions manually, then calling RemoveCurrentP once in order to set p to the instruction that appears after this triplet, and so UpdateUsedRegs is only called once.
There are a couple of points in the code where I've added the comment "// <-- Is this actually safe? hp1 is not necessarily the next instruction. [Kit]" because I replaced the duplet "RemoveCurrentP(p); p := hp1;" with "RemoveCurrentP(p, hp1);"; however, following the program flow yields the fact that hp1 is not necessarily the next instruction (it was obained through "GetNextInstructionUsingReg"). Program functionality is identical, and probably is safe, but optimisations between p and hp1 may get missed in the cases where the two instructions are not adjacent... this is something to check at another time.
Mantis conversion info:
- Mantis ID: 36797
- OS: Microsoft Windows
- OS Build: 10 Professional
- Build: r44287
- Platform: Cross-platform
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 45142 (#a084c882)