浏览代码

* patch by rasberryrabbit: Preventing release register for lealea2lealea optimization. This patch doesn't skip lealea2lealea optimization, resolves #41466

florian 1 月之前
父节点
当前提交
9d6b66c9e4
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      compiler/x86/aoptx86.pas

+ 16 - 0
compiler/x86/aoptx86.pas

@@ -6939,6 +6939,14 @@ unit aoptx86;
                             else
                             else
                               taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(hp1).oper[0]^.ref^.scalefactor * max(taicpu(p).oper[0]^.ref^.scalefactor, 1);
                               taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(hp1).oper[0]^.ref^.scalefactor * max(taicpu(p).oper[0]^.ref^.scalefactor, 1);
 
 
+                            if (taicpu(p).oper[0]^.ref^.base<>NR_NO) and 
+                               (not RegInUsedRegs(taicpu(p).oper[0]^.ref^.base, TmpUsedRegs)) then
+                              AllocRegBetween(taicpu(p).oper[0]^.ref^.base , p, hp1, TmpUsedRegs);
+                            if (taicpu(p).oper[0]^.ref^.index<>NR_NO) and
+                               (not RegInUsedRegs(taicpu(p).oper[0]^.ref^.index, TmpUsedRegs)) then
+                              AllocRegBetween(taicpu(p).oper[0]^.ref^.index , p, hp1, TmpUsedRegs);
+                            UpdateUsedRegsBetween(TmpUsedRegs, p, hp1);
+
                             { Only remove the first LEA if we don't need the intermediate register's value as is }
                             { Only remove the first LEA if we don't need the intermediate register's value as is }
                             if IntermediateRegDiscarded then
                             if IntermediateRegDiscarded then
                               begin
                               begin
@@ -7036,6 +7044,14 @@ unit aoptx86;
                                   taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(p).oper[0]^.ref^.scalefactor;
                                   taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(p).oper[0]^.ref^.scalefactor;
                               end;
                               end;
 
 
+                            if (taicpu(p).oper[0]^.ref^.base<>NR_NO) and 
+                               (not RegInUsedRegs(taicpu(p).oper[0]^.ref^.base, TmpUsedRegs)) then
+                              AllocRegBetween(taicpu(p).oper[0]^.ref^.base , p, hp1, TmpUsedRegs);
+                            if (taicpu(p).oper[0]^.ref^.index<>NR_NO) and
+                               (not RegInUsedRegs(taicpu(p).oper[0]^.ref^.index, TmpUsedRegs)) then
+                              AllocRegBetween(taicpu(p).oper[0]^.ref^.index , p, hp1, TmpUsedRegs);
+                            UpdateUsedRegsBetween(TmpUsedRegs, p, hp1);
+
                             { Only remove the first LEA if we don't need the intermediate register's value as is }
                             { Only remove the first LEA if we don't need the intermediate register's value as is }
                             if IntermediateRegDiscarded then
                             if IntermediateRegDiscarded then
                               begin
                               begin