Selaa lähdekoodia

* 8086: Fixed loading a 32-bit ref to a register in case the target register is used as the ref base or index.

git-svn-id: trunk@46490 -
yury 5 vuotta sitten
vanhempi
commit
4873ec73a7
1 muutettua tiedostoa jossa 15 lisäystä ja 4 poistoa
  1. 15 4
      compiler/i8086/cgcpu.pas

+ 15 - 4
compiler/i8086/cgcpu.pas

@@ -1876,14 +1876,25 @@ unit cgcpu;
                 end;
               OS_32,OS_S32:
                 begin
-                  { Preload the ref base to reduce spilling }
-                  if (tmpref.base<>NR_NO) and
-                     (tmpref.index<>NR_NO) and
-                     (getsupreg(tmpref.base)>=first_int_imreg) then
+                  { Preload the ref base to a new register to reduce spilling
+                    Also preload if the first target reg is used as base or index
+                    to prevent overwriting }
+                  if ((tmpref.base<>NR_NO) and
+                      (tmpref.index<>NR_NO) and
+                      (getsupreg(tmpref.base)>=first_int_imreg)) or
+                     (tmpref.base=reg) or
+                     (tmpref.index=reg) then
                     begin
                       tmpreg:=getaddressregister(list);
                       a_load_reg_reg(list,OS_ADDR,OS_ADDR,tmpref.base,tmpreg);
                       tmpref.base:=tmpreg;
+                      if tmpref.index=reg then
+                        begin
+                          list.concat(taicpu.op_ref_reg(A_LEA, S_W, tmpref, tmpref.base));
+                          tmpref.index:=NR_NO;
+                          tmpref.offset:=0;
+                          tmpref.scalefactor:=0;
+                        end;
                     end;
                   list.concat(taicpu.op_ref_reg(A_MOV, S_W, tmpref, reg));
                   inc(tmpref.offset, 2);