Browse Source

+ optimization in tcg64f8086.a_op64_const_reg for OP_ADD and OP_SUB when the
lowest 48, 32 or 16 bits of the constant are zeros

git-svn-id: trunk@25705 -

nickysn 12 years ago
parent
commit
3bdd3d9a4e
1 changed files with 22 additions and 4 deletions
  1. 22 4
      compiler/i8086/cgcpu.pas

+ 22 - 4
compiler/i8086/cgcpu.pas

@@ -1924,10 +1924,28 @@ unit cgcpu;
             begin
             begin
               // can't use a_op_const_ref because this may use dec/inc
               // can't use a_op_const_ref because this may use dec/inc
               get_64bit_ops(op,op1,op2);
               get_64bit_ops(op,op1,op2);
-              list.concat(taicpu.op_const_reg(op1,S_W,aint(value and $ffff),reg.reglo));
-              list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 16) and $ffff),GetNextReg(reg.reglo)));
-              list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 32) and $ffff),reg.reghi));
-              list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 48) and $ffff),GetNextReg(reg.reghi)));
+              if (value and $ffffffffffff) = 0 then
+                begin
+                  list.concat(taicpu.op_const_reg(op1,S_W,aint((value shr 48) and $ffff),GetNextReg(reg.reghi)));
+                end
+              else if (value and $ffffffff) = 0 then
+                begin
+                  list.concat(taicpu.op_const_reg(op1,S_W,aint((value shr 32) and $ffff),reg.reghi));
+                  list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 48) and $ffff),GetNextReg(reg.reghi)));
+                end
+              else if (value and $ffff) = 0 then
+                begin
+                  list.concat(taicpu.op_const_reg(op1,S_W,aint((value shr 16) and $ffff),GetNextReg(reg.reglo)));
+                  list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 32) and $ffff),reg.reghi));
+                  list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 48) and $ffff),GetNextReg(reg.reghi)));
+                end
+              else
+                begin
+                  list.concat(taicpu.op_const_reg(op1,S_W,aint(value and $ffff),reg.reglo));
+                  list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 16) and $ffff),GetNextReg(reg.reglo)));
+                  list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 32) and $ffff),reg.reghi));
+                  list.concat(taicpu.op_const_reg(op2,S_W,aint((value shr 48) and $ffff),GetNextReg(reg.reghi)));
+                end;
             end;
             end;
           else
           else
             internalerror(200204021);
             internalerror(200204021);