[Patch] x86 SUB and LEA 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 breaks some dependency chains in compiled code, as well as simplifying it in some cases:
- movl/q %reg1,%reg2; addl/q $x,%reg2 -> leal/q x(%reg1),%reg2 (so long as a conditional statement doesn't follow)
- movl/q %reg1,%reg2; subl/q $x,%reg2 -> leal/q -x(%reg1),%reg2 (so long as a conditional statement doesn't follow)
- subl/q $x,%reg1; movl/q %reg1,%reg2 -> leal/q -x(%reg1),%reg2; subl/q %x,%reg1 (won't perform when optimising for size)
Steps to reproduce:
Apply patch and confirm correct (and improved) compilation in i386 and x86_64 platforms
Additional information:
The last one is notable in that it sometimes permits the removal of a cmp instruction if one immediately follows.
Mantis conversion info:
- Mantis ID: 36622
- OS: Microsoft Windows
- OS Build: 10 Professional
- Build: r44021
- Platform: i386 and x86_64
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 44030 (#993144b9)