Prechádzať zdrojové kódy

* tcg8086.a_op_const_reg: perform the OP_AND, OP_OR and OP_XOR optimizations for
$0000 and $FFFF values on the low and the high words independently.

git-svn-id: trunk@26344 -

nickysn 11 rokov pred
rodič
commit
9a1e33d2a0
1 zmenil súbory, kde vykonal 44 pridanie a 10 odobranie
  1. 44 10
      compiler/i8086/cgcpu.pas

+ 44 - 10
compiler/i8086/cgcpu.pas

@@ -308,27 +308,61 @@ unit cgcpu;
                 end;
               OP_AND, OP_OR, OP_XOR:
                 begin
-                  if longword(a) = high(longword) then
+                  { low word operation }
+                  if aint(a and $FFFF) = aint(0) then
                     begin
                       case op of
                         OP_AND:
-                          exit;
+                          a_load_const_reg(list,OS_16,aint(0),reg);
+                        OP_OR,OP_XOR:
+                          {do nothing};
+                        else
+                          InternalError(2013100701);
+                      end;
+                    end
+                  else if aint(a and $FFFF) = aint($FFFF) then
+                    begin
+                      case op of
+                        OP_AND:
+                          {do nothing};
                         OP_OR:
-                          a_load_const_reg(list,size,high(longword),reg);
+                          a_load_const_reg(list,OS_16,aint($FFFF),reg);
                         OP_XOR:
-                          begin
-                            list.concat(taicpu.op_reg(A_NOT,S_W,reg));
-                            list.concat(taicpu.op_reg(A_NOT,S_W,GetNextReg(reg)));
-                          end;
+                          list.concat(taicpu.op_reg(A_NOT,S_W,reg));
                         else
                           InternalError(2013100701);
-                      end
+                      end;
                     end
                   else
-                  begin
                     a_op_const_reg(list,op,OS_16,aint(a and $FFFF),reg);
+
+                  { high word operation }
+                  if aint(a shr 16) = aint(0) then
+                    begin
+                      case op of
+                        OP_AND:
+                          a_load_const_reg(list,OS_16,aint(0),GetNextReg(reg));
+                        OP_OR,OP_XOR:
+                          {do nothing};
+                        else
+                          InternalError(2013100701);
+                      end;
+                    end
+                  else if aint(a shr 16) = aint($FFFF) then
+                    begin
+                      case op of
+                        OP_AND:
+                          {do nothing};
+                        OP_OR:
+                          a_load_const_reg(list,OS_16,aint($FFFF),GetNextReg(reg));
+                        OP_XOR:
+                          list.concat(taicpu.op_reg(A_NOT,S_W,GetNextReg(reg)));
+                        else
+                          InternalError(2013100701);
+                      end;
+                    end
+                  else
                     a_op_const_reg(list,op,OS_16,aint(a shr 16),GetNextReg(reg));
-                  end;
                 end;
               OP_SHR,OP_SHL,OP_SAR:
                 begin