Quellcode durchsuchen

m68k: on a '000, optimize CLR.L Dx to MOVEQ #0,Dx which is slightly faster

git-svn-id: trunk@34760 -
Károly Balogh vor 8 Jahren
Ursprung
Commit
41776e9608
1 geänderte Dateien mit 15 neuen und 1 gelöschten Zeilen
  1. 15 1
      compiler/m68k/aoptcpu.pas

+ 15 - 1
compiler/m68k/aoptcpu.pas

@@ -43,7 +43,7 @@ unit aoptcpu;
   Implementation
 
     uses
-      cutils, aasmcpu, cgutils;
+      cutils, aasmcpu, cgutils, globals, cpuinfo;
 
 {$ifdef DEBUG_AOPTCPU}
   procedure TCpuAsmOptimizer.DebugMsg(const s: string; p : tai);
@@ -124,6 +124,20 @@ unit aoptcpu;
                     taicpu(p).loadoper(0,taicpu(p).oper[1]^);
                     result:=true;
                   end;
+              { CLR.L Dx on a 68000 is slower than MOVEQ #0,Dx }
+              A_CLR:
+                if (current_settings.cputype in [cpu_mc68000]) and
+                   (taicpu(p).oper[0]^.typ = top_reg) and
+                   (taicpu(p).opsize = S_L) and
+                   isintregister(taicpu(p).oper[0]^.reg) then
+                  begin
+                    //DebugMsg('Optimizer: CLR.L Dx to MOVEQ #0,Dx',p);
+                    taicpu(p).opcode:=A_MOVEQ;
+                    taicpu(p).loadoper(1,taicpu(p).oper[0]^);
+                    taicpu(p).loadconst(0,0);
+                    taicpu(p).ops:=2;
+                    result:=true;
+                  end;
               { CMP #0,<ea> equals to TST <ea>, just shorter and TST is more flexible anyway }
               A_CMP,A_CMPI:
                 if (taicpu(p).oper[0]^.typ = top_const) and