浏览代码

* x86: Modification to PostPeepholeOptShr to skip over MOV instructions if they don't modify the current register

J. Gareth "Curious Kit" Moreton 2 年之前
父节点
当前提交
36f771a312
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      compiler/x86/aoptx86.pas

+ 12 - 1
compiler/x86/aoptx86.pas

@@ -16681,7 +16681,18 @@ unit aoptx86;
                   Continue;
                   Continue;
                 end;
                 end;
             else
             else
-              ;
+              { If the register isn't actually modified, move onto the next instruction,
+                but set DoNotMerge to True since the register is being read }
+              if (
+                  { Under -O2 and below, GetNextInstructionUsingReg only returns
+                    the next instruction, whether or not it contains the register }
+                  (cs_opt_level3 in current_settings.optimizerswitches) or
+                  RegReadByInstruction(taicpu(p).oper[1]^.reg, hp1)
+                ) and not RegModifiedByInstruction(taicpu(p).oper[1]^.reg, hp1) then
+                begin
+                  DoNotMerge := True;
+                  Continue;
+                end;
           end;
           end;
 
 
           Break;
           Break;