View Issue Details

IDProjectCategoryView StatusLast Update
0038767FPCCompilerpublic2021-05-04 00:08
ReporterJ. Gareth Moreton Assigned To 
PrioritylowSeveritytweakReproducibilityN/A
Status newResolutionopen 
Platformi386 and x86_64OSMicrosoft Windows 
Product Version3.3.1 
Summary0038767: [Patch] Additional SETcc optimisations
DescriptionThis 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 ReproduceApply patch and confirm correct compilation.
Additional InformationCurrently, 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.
Tagscompiler, i386, optimizations, patch, x86, x86_64
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Relationships

child of 0038761 new [Patch] x86 JccMovJmpMov2MovSetcc improvement 

Activities

J. Gareth Moreton

2021-05-04 00:04

developer   ~0130745

I apologise - I put the SETcc/MOV -> SETcc addition in with the patch over at 0038761. I'll see if I can separate them.

J. Gareth Moreton

2021-05-04 00:07

developer   ~0130746

Last edited: 2021-05-04 00:07

View 2 revisions

Ah, I understand why I didn't now. Some shared functions and overlapping diffs. SETcc changes are over at 0038761.

Issue History

Date Modified Username Field Change
2021-04-16 22:27 J. Gareth Moreton New Issue
2021-04-16 22:27 J. Gareth Moreton File Added: setcc-upgrade.patch
2021-04-16 22:28 J. Gareth Moreton Tag Attached: patch
2021-04-16 22:28 J. Gareth Moreton Tag Attached: compiler
2021-04-16 22:28 J. Gareth Moreton Tag Attached: optimizations
2021-04-16 22:28 J. Gareth Moreton Tag Attached: i386
2021-04-16 22:28 J. Gareth Moreton Tag Attached: x86
2021-04-16 22:28 J. Gareth Moreton Tag Attached: x86_64
2021-04-16 22:28 J. Gareth Moreton Priority normal => low
2021-04-16 22:28 J. Gareth Moreton Severity minor => tweak
2021-04-16 22:28 J. Gareth Moreton FPCTarget => -
2021-05-04 00:04 J. Gareth Moreton Note Added: 0130745
2021-05-04 00:07 J. Gareth Moreton Note Added: 0130746
2021-05-04 00:07 J. Gareth Moreton Note Edited: 0130746 View Revisions
2021-05-04 00:07 J. Gareth Moreton File Deleted: setcc-upgrade.patch
2021-05-04 00:08 J. Gareth Moreton Relationship added child of 0038761