Browse Source

* x86: Minor efficiency gains in OptPass1CMP

J. Gareth "Curious Kit" Moreton 1 year ago
parent
commit
e406cbd9c8
1 changed files with 9 additions and 1 deletions
  1. 9 1
      compiler/x86/aoptx86.pas

+ 9 - 1
compiler/x86/aoptx86.pas

@@ -7902,6 +7902,7 @@ unit aoptx86;
          p_jump := hp1;
          p_jump := hp1;
          while Assigned(p_jump) and MatchInstruction(p_jump, A_JCC, []) do
          while Assigned(p_jump) and MatchInstruction(p_jump, A_JCC, []) do
            begin
            begin
+             Prefetch(p_jump.Next);
              if IsJumpToLabel(taicpu(p_jump)) then
              if IsJumpToLabel(taicpu(p_jump)) then
                begin
                begin
                  { Do jump optimisations first in case the condition becomes
                  { Do jump optimisations first in case the condition becomes
@@ -7985,7 +7986,7 @@ unit aoptx86;
 
 
                          DebugMsg(SPeepholeOptimization + 'CMP/Jcc/@Lbl/CMP/Jcc -> CMP/Jcc, redirecting first jump', p_jump);
                          DebugMsg(SPeepholeOptimization + 'CMP/Jcc/@Lbl/CMP/Jcc -> CMP/Jcc, redirecting first jump', p_jump);
                          taicpu(p_jump).loadref(0, taicpu(hp1_dist).oper[0]^.ref^); { This also increases the reference count }
                          taicpu(p_jump).loadref(0, taicpu(hp1_dist).oper[0]^.ref^); { This also increases the reference count }
-                         Result := True;
+                         Include(OptsToCheck, aoc_ForceNewIteration);
                          { Don't exit yet.  Since p and p_jump haven't actually been
                          { Don't exit yet.  Since p and p_jump haven't actually been
                            removed, we can check for more on this iteration }
                            removed, we can check for more on this iteration }
                        end
                        end
@@ -8060,6 +8061,13 @@ unit aoptx86;
                  RemoveInstruction(hp2);
                  RemoveInstruction(hp2);
                  Result := True;
                  Result := True;
                  { Continue the while loop in case "Jcc/CMP" follows the second CMP that was just removed }
                  { Continue the while loop in case "Jcc/CMP" follows the second CMP that was just removed }
+               end
+             else
+               begin
+                 { hp2 is the next instruction, so save time and just set p_jump
+                   to it instead of calling GetNextInstruction below }
+                 p_jump := hp2;
+                 Continue;
                end;
                end;
 
 
              GetNextInstruction(p_jump, p_jump);
              GetNextInstruction(p_jump, p_jump);