Browse Source

m68k: while updating reference, don't reallocate and copy the index to another register if we can apply scaling for it and we don't need to multiply, so the maybe_const_reg doesn't change. this improves generated code when a const reg (eg: a loop counter) is used as array index

git-svn-id: trunk@32830 -
Károly Balogh 9 years ago
parent
commit
ff7a0c5235
1 changed files with 2 additions and 3 deletions
  1. 2 3
      compiler/m68k/n68kmem.pas

+ 2 - 3
compiler/m68k/n68kmem.pas

@@ -72,7 +72,6 @@ implementation
         if l<>1 then
         if l<>1 then
           begin
           begin
             //current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('updref: l <> 1')));
             //current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('updref: l <> 1')));
-            hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
             { if we have a possibility, setup a scalefactor instead of the MUL }
             { if we have a possibility, setup a scalefactor instead of the MUL }
             if (location.reference.index<>NR_NO) or
             if (location.reference.index<>NR_NO) or
                (current_settings.cputype in [cpu_mc68000]) or
                (current_settings.cputype in [cpu_mc68000]) or
@@ -80,15 +79,15 @@ implementation
                not (l in [2,4,8]) then
                not (l in [2,4,8]) then
               begin
               begin
                 //current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('updref: mul')));
                 //current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('updref: mul')));
+                hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
                 cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_IMUL,OS_ADDR,l,maybe_const_reg,hreg);
                 cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_IMUL,OS_ADDR,l,maybe_const_reg,hreg);
+                maybe_const_reg:=hreg;
               end
               end
             else
             else
               begin
               begin
                 //current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('updref: scale')));
                 //current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('updref: scale')));
-                cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,maybe_const_reg,hreg);
                 scaled:=true;
                 scaled:=true;
               end;
               end;
-            maybe_const_reg:=hreg;
           end;
           end;
 
 
         if (location.reference.base=NR_NO) and not (scaled) then
         if (location.reference.base=NR_NO) and not (scaled) then