Browse Source

* fixed and simplified tcgaddnode.second_addsmallset: don't modify
right.register for subn, because it may be constant

git-svn-id: trunk@16663 -

Jonas Maebe 14 years ago
parent
commit
e8871f0885
1 changed files with 8 additions and 14 deletions
  1. 8 14
      compiler/ncgadd.pas

+ 8 - 14
compiler/ncgadd.pas

@@ -269,7 +269,6 @@ interface
 
 
     procedure tcgaddnode.second_addsmallset;
     procedure tcgaddnode.second_addsmallset;
       var
       var
-        tmpreg : tregister;
         cgop    : TOpCg;
         cgop    : TOpCg;
         opdone  : boolean;
         opdone  : boolean;
       begin
       begin
@@ -301,21 +300,16 @@ interface
                  end;
                  end;
               if opdone then
               if opdone then
                 begin
                 begin
+                  if (right.location.size<>left.location.size) or
+                     (location.size<>left.location.size) then
+                    internalerror(2010123001);
+                  { make sure we don't modify left/right.location, because we told
+                    force_reg_left_right above that they can be constant }
+                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NOT,location.size,right.location.register,location.register);
                   if left.location.loc = LOC_CONSTANT then
                   if left.location.loc = LOC_CONSTANT then
-                    begin
-                      tmpreg := cg.getintregister(current_asmdata.CurrAsmList,location.size);
-                      cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,
-                        left.location.value,tmpreg);
-                      cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NOT,location.size,right.location.register,right.location.register);
-                      cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_AND,location.size,right.location.register,tmpreg);
-                      cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_INT,location.size,tmpreg,location.register);
-                    end
+                    cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_AND,location.size,left.location.value,location.register)
                   else
                   else
-                    begin
-                      cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NOT,right.location.size,right.location.register,right.location.register);
-                      cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_AND,left.location.size,right.location.register,left.location.register);
-                      cg.a_load_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register);
-                    end;
+                    cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_AND,location.size,left.location.register,location.register);
                 end;
                 end;
             end;
             end;
           else
           else