Browse Source

* patch by J. Gareth Moreton, avoid illegal MovAdd2Lea and MovSub2Lea optimziations, resolves #36630

git-svn-id: trunk@44101 -
florian 5 years ago
parent
commit
bbcbd4eae1
1 changed files with 7 additions and 1 deletions
  1. 7 1
      compiler/x86/aoptx86.pas

+ 7 - 1
compiler/x86/aoptx86.pas

@@ -3900,10 +3900,16 @@ unit aoptx86;
               To:
                 leal/q x(%reg1),%reg2   leal/q -x(%reg1),%reg2
             }
+            TransferUsedRegs(TmpUsedRegs);
+            UpdateUsedRegs(TmpUsedRegs, tai(p.Next));
+            UpdateUsedRegs(TmpUsedRegs, tai(hp1.Next));
             if not GetNextInstruction(hp1, hp2) or
+              (
               { The FLAGS register isn't always tracked properly, so do not
                 perform this optimisation if a conditional statement follows }
-              not MatchInstruction(hp2, [A_Jcc, A_SETcc, A_CMOVcc], []) then
+                not RegReadByInstruction(NR_DEFAULTFLAGS, hp2) and
+                not RegUsedAfterInstruction(NR_DEFAULTFLAGS, hp2, TmpUsedRegs)
+              ) then
               begin
                 reference_reset(NewRef, 1, []);
                 NewRef.base := taicpu(p).oper[0]^.reg;