Ver Fonte

* x86: "StcClcSet(c)2Mov" optimisation now checks to see if the destination register is in use

J. Gareth "Curious Kit" Moreton há 1 ano atrás
pai
commit
7c5847bc70
1 ficheiros alterados com 7 adições e 1 exclusões
  1. 7 1
      compiler/x86/aoptx86.pas

+ 7 - 1
compiler/x86/aoptx86.pas

@@ -9578,7 +9578,13 @@ unit aoptx86;
                     IsJumpToLabel(taicpu(hp1_dist)) and
                     not (taicpu(hp1_dist).condition in [C_AE, C_NB, C_NC, C_B, C_C, C_NAE, C_BE, C_NA]) and
                     { This works if hp1_dist or both are regular JMP instructions }
-                    condition_in(taicpu(hp1).condition, taicpu(hp1_dist).condition) then
+                    condition_in(taicpu(hp1).condition, taicpu(hp1_dist).condition) and
+                    (
+                      (taicpu(p_dist).oper[0]^.typ <> top_reg) or
+                      { Make sure the register isn't still in use, otherwise it
+                        may get corrupted (fixes #40659) }
+                      not RegUsedBetween(taicpu(p_dist).oper[0]^.reg, p, p_dist)
+                    ) then
                     begin
                       taicpu(p).allocate_oper(2);
                       taicpu(p).ops := 2;