[Patch] x86: MovMovSar2MovCltd bug fix
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 fixes a bug with the MovMovSar2MovCltd optimisation that might rarely rear its head under i386. Specifically, it would erroneously change:
movl x, %edx
movl y, %edx
sarl $31,%edx
To:
movl x, %eax
ctld
This produces incorrect machine code if %eax was in use.
Steps to reproduce:
Apply patch and confirm correct compilation.
Additional information:
The bug was masked by the Mov2Nop 5 optimisation (which removed 'dominated' writes to a register, in this case it removed the equivalent of "movl x, %edx") and so was almost never triggered.
This fix seems to trigger MovMovSar2MovCtld in favour of the simpler MovSar2Ctld to the point that the latter does not seem to appear at all in the RTL (the main units I use for optimisation testing and analysis).
Mantis conversion info:
- Mantis ID: 39180
- OS: Microsoft Windows
- OS Build: 10 Home
- Build: r49583
- Platform: i386
- Version: 3.2.1
- Fixed in version: 3.3.1
- Fixed in revision: 49586 (#cb0f422e)