Browse Source

* x86: Arithmetic combination optimisations are now much more careful about the flags being in use

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

+ 4 - 3
compiler/x86/aoptx86.pas

@@ -6803,9 +6803,10 @@ unit aoptx86;
 
 
         SubInstr := (taicpu(p).opcode = A_SUB);
         SubInstr := (taicpu(p).opcode = A_SUB);
 
 
-        if GetLastInstruction(p, hp1) and
-           (hp1.typ = ait_instruction) and
-           (taicpu(hp1).opsize = taicpu(p).opsize) then
+        if not RegInUsedRegs(NR_DEFAULTFLAGS, UsedRegs) and
+          GetLastInstruction(p, hp1) and
+          (hp1.typ = ait_instruction) and
+          (taicpu(hp1).opsize = taicpu(p).opsize) then
           begin
           begin
             if not (taicpu(p).opsize in [S_B, S_W, S_L{$ifdef x86_64}, S_Q{$endif x86_64}]) then
             if not (taicpu(p).opsize in [S_B, S_W, S_L{$ifdef x86_64}, S_Q{$endif x86_64}]) then
               { Bad size }
               { Bad size }