Ver código fonte

* do not allocate an extra register for some integer operations if not needed

git-svn-id: trunk@43412 -
florian 5 anos atrás
pai
commit
c8f746b881
2 arquivos alterados com 8 adições e 8 exclusões
  1. 2 1
      compiler/cgobj.pas
  2. 6 7
      compiler/x86/nx86add.pas

+ 2 - 1
compiler/cgobj.pas

@@ -1664,7 +1664,8 @@ implementation
           LOC_MMREGISTER,LOC_CMMREGISTER:
             a_loadmm_reg_intreg(list,loc.size,tosize,loc.register,reg,mms_movescalar);
           else
-            internalerror(200109092);
+            begin writeln(loc.loc);
+            internalerror(200109092); end;
         end;
       end;
 

+ 6 - 7
compiler/x86/nx86add.pas

@@ -245,8 +245,8 @@ unit nx86add;
               { maybe we can reuse a constant register when the
                 operation is a comparison that doesn't change the
                 value of the register }
-                hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,opdef,(nodetype in [ltn,lten,gtn,gten,equaln,unequaln]));
-                location:=left.location;
+              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,opdef,(nodetype in [ltn,lten,gtn,gten,equaln,unequaln]));
+              location:=left.location;
             end
            else
             begin
@@ -1474,8 +1474,9 @@ unit nx86add;
 
        pass_left_right;
 
-       { do have to allocate a register? If yes, then three opcode instructions are better }
-       if ((left.location.loc<>LOC_REGISTER) and (right.location.loc<>LOC_REGISTER)) or
+       { do have to allocate a register? If yes, then three opcode instructions are better, however for sub three op code instructions
+         make no sense if right is a reference }
+       if ((left.location.loc<>LOC_REGISTER) and (right.location.loc<>LOC_REGISTER) and ((nodetype<>subn) or not(right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]))) or
          ((nodetype=addn) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_CONSTANT]) and (right.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_CONSTANT])) then
          begin
            { allocate registers }
@@ -1524,12 +1525,10 @@ unit nx86add;
               begin
                 if right.location.loc<>LOC_REGISTER then
                   begin
-    {                tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
+                    tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
                     cg.a_load_loc_reg(current_asmdata.CurrAsmList,opsize,left.location,tmpreg);
                     location_reset(left.location,LOC_REGISTER,opsize);
                     left.location.register:=tmpreg;
-    }
-                    Internalerror(2018031102);
                   end
                 else
                   begin