View Issue Details

IDProjectCategoryView StatusLast Update
0036295FPCCompilerpublic2019-11-11 22:29
ReporterJ. Gareth MoretonAssigned ToFlorian 
PrioritylowSeveritytrivialReproducibilityN/A
Status resolvedResolutionfixed 
Platformx86_64 (all OS's)OSMicrosoft WindowsOS Version10 Professional
Product Version3.3.1Product Buildr43451 
Target VersionFixed in Version3.3.1 
Summary0036295: [Refactor] OptPass2Jcc clean-up
DescriptionThis is a minor refactor of the x86 Peephole Optimizer function OptPass2Jcc after my original submission of its redesign over in 0036271. It seeks to remove duplicate functionality that was left-over from before its overhaul.

Genereated code should be completely identical, but the particular routine is smaller and faster now.
Steps To ReproduceApply patch and confirm correct compilation. Optionally, compare the compiler, with and without the patch applied, to determine that the generated binaries of some particular project (other than the compiler itself) are identical.
Additional InformationDuplicate functionality is in regards to stripping alignment fields of dead labels when optimising Jcc/MOV instructions into CMOV instructions.
Tagscompiler, optimizations, patch, refactor, x86_64
Fixed in Revision43452
FPCOldBugId
FPCTarget-
Attached Files
  • optpass2jcc-refactor.patch (2,044 bytes)
    Index: compiler/x86/aoptx86.pas
    ===================================================================
    --- compiler/x86/aoptx86.pas	(revision 43449)
    +++ compiler/x86/aoptx86.pas	(working copy)
    @@ -3392,26 +3392,8 @@
                                 GetNextInstruction(hp1,hp1);
                               until not(CanBeCMOV(hp1));
     
    -                          { Don't decrement the reference count on the label yet, otherwise
    -                            GetNextInstruction might skip over the label if it drops to
    -                            zero. }
    -                          GetNextInstruction(hp1,hp2);
    -
    -                          { if the label refs. reach zero, remove any alignment before the label }
    -                          if (hp1.typ = ait_align) and (hp2.typ = ait_label) then
    -                            begin
    -                              { Ref = 1 means it will drop to zero }
    -                              if (tasmlabel(symbol).getrefs=1) then
    -                                begin
    -                                  asml.Remove(hp1);
    -                                  hp1.Free;
    -                                end;
    -                            end
    -                          else
    -                            hp2 := hp1;
    -
    -                          { Remember what the first hp2 is in case there's multiple aligns and labels to get rid of }
    -                          hp3 := hp2;
    +                          { Remember what hp1 is in case there's multiple aligns to get rid of }
    +                          hp2 := hp1;
                               repeat
                                 if not Assigned(hp2) then
                                   InternalError(2018062910);
    @@ -3444,7 +3426,7 @@
     
                               { Remove the label if this is its final reference }
                               if (tasmlabel(symbol).getrefs=0) then
    -                            StripLabelFast(hp3);
    +                            StripLabelFast(hp1);
     
                               if Assigned(p) then
                                 begin
    

Relationships

child of 0036271 resolvedFlorian [Patch] Jump optimisations in code generator 

Activities

J. Gareth Moreton

2019-11-11 20:39

developer  

optpass2jcc-refactor.patch (2,044 bytes)
Index: compiler/x86/aoptx86.pas
===================================================================
--- compiler/x86/aoptx86.pas	(revision 43449)
+++ compiler/x86/aoptx86.pas	(working copy)
@@ -3392,26 +3392,8 @@
                             GetNextInstruction(hp1,hp1);
                           until not(CanBeCMOV(hp1));
 
-                          { Don't decrement the reference count on the label yet, otherwise
-                            GetNextInstruction might skip over the label if it drops to
-                            zero. }
-                          GetNextInstruction(hp1,hp2);
-
-                          { if the label refs. reach zero, remove any alignment before the label }
-                          if (hp1.typ = ait_align) and (hp2.typ = ait_label) then
-                            begin
-                              { Ref = 1 means it will drop to zero }
-                              if (tasmlabel(symbol).getrefs=1) then
-                                begin
-                                  asml.Remove(hp1);
-                                  hp1.Free;
-                                end;
-                            end
-                          else
-                            hp2 := hp1;
-
-                          { Remember what the first hp2 is in case there's multiple aligns and labels to get rid of }
-                          hp3 := hp2;
+                          { Remember what hp1 is in case there's multiple aligns to get rid of }
+                          hp2 := hp1;
                           repeat
                             if not Assigned(hp2) then
                               InternalError(2018062910);
@@ -3444,7 +3426,7 @@
 
                           { Remove the label if this is its final reference }
                           if (tasmlabel(symbol).getrefs=0) then
-                            StripLabelFast(hp3);
+                            StripLabelFast(hp1);
 
                           if Assigned(p) then
                             begin

Florian

2019-11-11 22:29

administrator   ~0119233

Thanks, removing code without functional changes is always good :)

Issue History

Date Modified Username Field Change
2019-11-11 20:39 J. Gareth Moreton New Issue
2019-11-11 20:39 J. Gareth Moreton File Added: optpass2jcc-refactor.patch
2019-11-11 20:40 J. Gareth Moreton Relationship added child of 0036271
2019-11-11 20:41 J. Gareth Moreton Tag Attached: patch
2019-11-11 20:41 J. Gareth Moreton Tag Attached: compiler
2019-11-11 20:41 J. Gareth Moreton Tag Attached: optimizations
2019-11-11 20:41 J. Gareth Moreton Tag Attached: refactor
2019-11-11 20:41 J. Gareth Moreton Tag Attached: x86_64
2019-11-11 20:41 J. Gareth Moreton Priority normal => low
2019-11-11 20:41 J. Gareth Moreton Severity minor => trivial
2019-11-11 20:41 J. Gareth Moreton FPCTarget => -
2019-11-11 22:29 Florian Assigned To => Florian
2019-11-11 22:29 Florian Status new => resolved
2019-11-11 22:29 Florian Resolution open => fixed
2019-11-11 22:29 Florian Fixed in Version => 3.3.1
2019-11-11 22:29 Florian Fixed in Revision => 43452
2019-11-11 22:29 Florian Note Added: 0119233