Browse Source

* x86: Safety check, since after calling DoJumpOptimizations, the input may no longer be the same tai

J. Gareth "Curious Kit" Moreton 1 year ago
parent
commit
af40ae2c91
1 changed files with 7 additions and 2 deletions
  1. 7 2
      compiler/x86/aoptx86.pas

+ 7 - 2
compiler/x86/aoptx86.pas

@@ -3559,10 +3559,15 @@ unit aoptx86;
                                 case taicpu(hp3).opcode of
                                   A_Jcc:
                                     begin
-                                      DebugMsg(SPeepholeOptimization + 'Condition is always true (jump made unconditional)', hp3);
                                       { Check for jump shortcuts before we destroy the condition }
+                                      hp4 := hp3;
                                       DoJumpOptimizations(hp3, TempBool);
-                                      MakeUnconditional(taicpu(hp3));
+                                      { Make sure hp3 hasn't changed }
+                                      if (hp4 = hp3) then
+                                        begin
+                                          DebugMsg(SPeepholeOptimization + 'Condition is always true (jump made unconditional)', hp3);
+                                          MakeUnconditional(taicpu(hp3));
+                                        end;
                                       Result := True;
                                     end;
                                   A_CMOVcc: