[Patch] SubMov2LeaSub optimisation improvement
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 improves upon the SubMov2LeaSub optimisation by removing the SUB instruction if the register is not used afterwards, thus reducing the instruction count as well as breaking the dependency chain.
Steps to reproduce:
Apply patch and confirm correct compilation.
Additional information:
Whether or not the SUB instruction is successfully removed, the current instruction ends up being an LEA instruction, which can sometimes be optimised further if it is adjacent to another LEA instruction, but these kinds of optimisations occur in Pass 1. As a compromise, OptPass2SUB now checks the previous instruction after the optimisation and, if it's a LEA, will call OptPass1LEA on it.
Tests on i386-win32 and x86_64-win64, both without special options and with TEST_OPT="-O4 -gl", pass without incident.
Mantis conversion info:
- Mantis ID: 38555
- OS: Microsoft Windows
- OS Build: 10 Home
- Build: r48813
- Platform: i386 and x86_64
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 48871 (#01937c46)