Browse Source

* x86: Bug fix where improved AddMov2Mov optimisation didn't
check to see if the other register was modified in between

J. Gareth "Curious Kit" Moreton 2 years ago
parent
commit
41b8f6a42e
1 changed files with 6 additions and 0 deletions
  1. 6 0
      compiler/x86/aoptx86.pas

+ 6 - 0
compiler/x86/aoptx86.pas

@@ -12799,6 +12799,7 @@ unit aoptx86;
 
             { Change:
                 add     %reg2,%reg1
+                (%reg2 not modified in between)
                 mov/s/z #(%reg1),%reg1  (%reg1 superregisters must be the same)
 
               To:
@@ -12825,6 +12826,11 @@ unit aoptx86;
                   not SuperRegistersEqual(taicpu(p).oper[1]^.reg, taicpu(hp1).oper[1]^.reg) and
                   MemRegisterNotUsedLater
                 )
+              ) and
+              (
+                { Instructions are guaranteed to be adjacent on -O2 and under }
+                not (cs_opt_level3 in current_settings.optimizerswitches) or
+                not RegModifiedBetween(taicpu(p).oper[0]^.reg, p, hp1)
               ) then
               begin
                 AllocRegBetween(taicpu(p).oper[0]^.reg, p, hp1, UsedRegs);