Sfoglia il codice sorgente

m68k: disabled premature MOVEA #0,Ax to SUBA Ax,Ax in the CG, because it breaks with spilling temp replacement and moved it to the optimizer, where it belongs. this fixes some code with potentially heavy address register pressure, like the IDE.

git-svn-id: trunk@30245 -
Károly Balogh 10 anni fa
parent
commit
b617345e43
2 ha cambiato i file con 17 aggiunte e 2 eliminazioni
  1. 11 0
      compiler/m68k/aoptcpu.pas
  2. 6 2
      compiler/m68k/cgcpu.pas

+ 11 - 0
compiler/m68k/aoptcpu.pas

@@ -112,6 +112,17 @@ unit aoptcpu;
                           result:=true;
                           result:=true;
                         end;
                         end;
                   end;
                   end;
+              { MOVEA #0,Ax to SUBA Ax,Ax, because it's shorter }
+              A_MOVEA:
+                if (taicpu(p).oper[0]^.typ = top_const) and
+                   (taicpu(p).oper[0]^.val = 0) then
+                  begin
+                    DebugMsg('Optimizer: MOVEA #0,Ax to SUBA Ax,Ax',p);
+                    taicpu(p).opcode:=A_SUBA;
+                    taicpu(p).opsize:=S_L; { otherwise it will be .W -> BOOM }
+                    taicpu(p).loadoper(0,taicpu(p).oper[1]^);
+                    result:=true;
+                  end;
               { CMP #0,<ea> equals to TST <ea>, just shorter and TST is more flexible anyway }
               { CMP #0,<ea> equals to TST <ea>, just shorter and TST is more flexible anyway }
               A_CMP:
               A_CMP:
                 if (taicpu(p).oper[0]^.typ = top_const) and
                 if (taicpu(p).oper[0]^.typ = top_const) and

+ 6 - 2
compiler/m68k/cgcpu.pas

@@ -742,9 +742,13 @@ unit cgcpu;
         if isaddressregister(register) then
         if isaddressregister(register) then
           begin
           begin
             { an m68k manual I have recommends SUB Ax,Ax to be used instead of CLR for address regs }
             { an m68k manual I have recommends SUB Ax,Ax to be used instead of CLR for address regs }
-            if a = 0 then
+            { Premature optimization is the root of all evil - this code breaks spilling if the
+              register contains a spilled regvar, eg. a Pointer which is set to nil, then random
+              havoc happens... This is kept here for reference now, to allow fixing of the spilling
+              later. Most of the optimizations below here could be moved to the optimizer. (KB) }
+            {if a = 0 then
               list.concat(taicpu.op_reg_reg(A_SUB,S_L,register,register))
               list.concat(taicpu.op_reg_reg(A_SUB,S_L,register,register))
-            else
+            else}
               { ISA B/C Coldfire has MOV3Q which can move -1 or 1..7 to any reg }
               { ISA B/C Coldfire has MOV3Q which can move -1 or 1..7 to any reg }
               if (current_settings.cputype in [cpu_isa_b,cpu_isa_c]) and 
               if (current_settings.cputype in [cpu_isa_b,cpu_isa_c]) and 
                  ((longint(a) = -1) or ((longint(a) > 0) and (longint(a) < 8))) then
                  ((longint(a) = -1) or ((longint(a) > 0) and (longint(a) < 8))) then