Browse Source

* optimized SAR by 31 to use only one SAR instruction in tcg8086.a_op_const_reg

git-svn-id: trunk@25883 -
nickysn 11 years ago
parent
commit
8bfe2a56dd
1 changed files with 11 additions and 3 deletions
  1. 11 3
      compiler/i8086/cgcpu.pas

+ 11 - 3
compiler/i8086/cgcpu.pas

@@ -353,9 +353,17 @@ unit cgcpu;
                         end;
                         end;
                       OP_SAR:
                       OP_SAR:
                         begin
                         begin
-                          a_load_reg_reg(list,OS_16,OS_16,GetNextReg(reg),reg);
-                          a_op_const_reg(list,OP_SAR,OS_16,15,GetNextReg(reg));
-                          a_op_const_reg(list,OP_SAR,OS_16,a-16,reg);
+                          if a=31 then
+                            begin
+                              a_op_const_reg(list,OP_SAR,OS_16,15,GetNextReg(reg));
+                              a_load_reg_reg(list,OS_16,OS_16,GetNextReg(reg),reg);
+                            end
+                          else
+                            begin
+                              a_load_reg_reg(list,OS_16,OS_16,GetNextReg(reg),reg);
+                              a_op_const_reg(list,OP_SAR,OS_16,15,GetNextReg(reg));
+                              a_op_const_reg(list,OP_SAR,OS_16,a-16,reg);
+                            end;
                         end;
                         end;
                       else
                       else
                         internalerror(2013060201);
                         internalerror(2013060201);