Przeglądaj źródła

* x86: PostPeepholeOptTestOr has different debug messages for each found instruction, and also tests for BEXTR and BZHI.

J. Gareth "Curious Kit" Moreton 2 lat temu
rodzic
commit
3ba9cf5b4f
1 zmienionych plików z 19 dodań i 7 usunięć
  1. 19 7
      compiler/x86/aoptx86.pas

+ 19 - 7
compiler/x86/aoptx86.pas

@@ -14018,7 +14018,7 @@ unit aoptx86;
                     )
                     )
                   ) then
                   ) then
                   begin
                   begin
-                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op done', hp1);
+                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op (2-op) done', hp1);
                     RemoveCurrentP(p, hp2);
                     RemoveCurrentP(p, hp2);
                     Result:=true;
                     Result:=true;
                     Exit;
                     Exit;
@@ -14036,7 +14036,7 @@ unit aoptx86;
                   { and in case of carry for A(E)/B(E)/C/NC                  }
                   { and in case of carry for A(E)/B(E)/C/NC                  }
                    (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                    (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                   begin
                   begin
-                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op done', hp1);
+                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op (shift) done', hp1);
                     RemoveCurrentP(p, hp2);
                     RemoveCurrentP(p, hp2);
                     Result:=true;
                     Result:=true;
                     Exit;
                     Exit;
@@ -14049,24 +14049,36 @@ unit aoptx86;
                   { and in case of carry for A(E)/B(E)/C/NC                  }
                   { and in case of carry for A(E)/B(E)/C/NC                  }
                   (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                   (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                   begin
                   begin
-                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op done', hp1);
+                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op (1-op) done', hp1);
                     RemoveCurrentP(p, hp2);
                     RemoveCurrentP(p, hp2);
                     Result:=true;
                     Result:=true;
                     Exit;
                     Exit;
                   end;
                   end;
               end;
               end;
-            A_ANDN:
+            A_ANDN, A_BZHI:
               begin
               begin
                 if OpsEqual(taicpu(hp1).oper[2]^,taicpu(p).oper[1]^) and
                 if OpsEqual(taicpu(hp1).oper[2]^,taicpu(p).oper[1]^) and
-                  { ANDN sets only the Z and S flag }
+                  { Only the zero and sign flags are consistent with what the result is }
+                  (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE,C_S,C_NS]) then
+                  begin
+                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op (ANDN/BZHI) done', hp1);
+                    RemoveCurrentP(p, hp2);
+                    Result:=true;
+                    Exit;
+                  end;
+              end;
+            A_BEXTR:
+              begin
+                if OpsEqual(taicpu(hp1).oper[2]^,taicpu(p).oper[1]^) and
+                  { Only the zero flag is set }
                   (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                   (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                   begin
                   begin
-                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op done', hp1);
+                    DebugMsg(SPeepholeOptimization + 'OpTest/Or2Op (BEXTR) done', hp1);
                     RemoveCurrentP(p, hp2);
                     RemoveCurrentP(p, hp2);
                     Result:=true;
                     Result:=true;
                     Exit;
                     Exit;
                   end;
                   end;
-              end
+              end;
           else
           else
             ;
             ;
           end; { case }
           end; { case }