Browse Source

a_load_const_reg: don't sign_extend after MOVEQ, it's not needed. also use CRL.L before loading to reg instead of sign_extend when possible

git-svn-id: trunk@25615 -
Károly Balogh 12 years ago
parent
commit
31e7b790a7
1 changed files with 11 additions and 2 deletions
  1. 11 2
      compiler/m68k/cgcpu.pas

+ 11 - 2
compiler/m68k/cgcpu.pas

@@ -727,8 +727,17 @@ unit cgcpu;
            if (longint(a) >= low(shortint)) and (longint(a) <= high(shortint)) then
               list.concat(taicpu.op_const_reg(A_MOVEQ,S_L,longint(a),register))
            else
-              list.concat(taicpu.op_const_reg(A_MOVE,tcgsize2opsize[size],longint(a),register));
-           sign_extend(list,size,register);
+             begin
+               { clear the register first, for unsigned and positive values, so
+                  we don't need to zero extend after }
+               if (size in [OS_16,OS_8]) or
+                  ((size in [OS_S16,OS_S8]) and (a > 0)) then
+                 list.concat(taicpu.op_reg(A_CLR,S_L,register));
+               list.concat(taicpu.op_const_reg(A_MOVE,tcgsize2opsize[size],longint(a),register));
+               { only sign extend if we need to, zero extension is not necessary because the CLR.L above }
+               if (size in [OS_S16,OS_S8]) and (a < 0) then
+                 sign_extend(list,size,register);
+             end;
          end;
       end;