[Patch] Additional SETcc 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 extends the "SETcc/Mov -> SETcc" optimisation to be performed on memory operands, and also has a secondary version for if the register specified in SETcc is used in the MOV instruction but then remains live. In this situation, the MOV instruction is transformed into another SETcc instruction with the same condition in order to break the dependency.
Example in Classes unit (-O2) - before:
.Lj5453:
movw 64(%rbx),%dx
# Peephole Optimization: Mov2Nop 3 done
# Peephole Optimization: %eax = %edi; changed to minimise pipeline stall (MovXXX2MovXXX)
cmpw %di,%dx
setneb %al
movb %al,32(%rsp)
After:
.Lj5453: movw 64(%rbx),%dx # Peephole Optimization: Mov2Nop 3 done # Peephole Optimization: %eax = %edi; changed to minimise pipeline stall (MovXXX2MovXXX) cmpw %di,%dx # Peephole Optimization: SETcc/Mov -> SETcc
setneb 32(%rsp)
Steps to reproduce:
Apply patch and confirm correct compilation.
Additional information:
Currently, only two invocations of 'SETcc/Mov -> SETcc/SETcc' have been noted under x86_64, both of which occur in the compiler source, and they seem to be due to inaccurate register tracking - the register is still considered live but other than a 'pop' instruction, is not used after the original MOV instruction - so this optimisation may become obsolete later on when tracking accuracy is improved.
Mantis conversion info:
- Mantis ID: 38767
- OS: Microsoft Windows
- OS Build: 10 Home
- Build: r49207
- Platform: i386 and x86_64
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 49386 (#5726428d)