Quellcode durchsuchen

* try to get rid at least of one mov when looking for les/lds optimization
+ debug messages

git-svn-id: trunk@38191 -

florian vor 7 Jahren
Ursprung
Commit
09af451c2e
1 geänderte Dateien mit 15 neuen und 4 gelöschten Zeilen
  1. 15 4
      compiler/i8086/aoptcpu.pas

+ 15 - 4
compiler/i8086/aoptcpu.pas

@@ -25,6 +25,8 @@ unit aoptcpu;
 
 
 {$i fpcdefs.inc}
 {$i fpcdefs.inc}
 
 
+{$define DEBUG_AOPTCPU}
+
   Interface
   Interface
 
 
     uses
     uses
@@ -85,8 +87,7 @@ unit aoptcpu;
                       (taicpu(p).oper[0]^.ref^.segment=taicpu(hp1).oper[0]^.ref^.segment) and
                       (taicpu(p).oper[0]^.ref^.segment=taicpu(hp1).oper[0]^.ref^.segment) and
                       (taicpu(p).oper[0]^.ref^.symbol=taicpu(hp1).oper[0]^.ref^.symbol) and
                       (taicpu(p).oper[0]^.ref^.symbol=taicpu(hp1).oper[0]^.ref^.symbol) and
                       (taicpu(p).oper[0]^.ref^.relsymbol=taicpu(hp1).oper[0]^.ref^.relsymbol) and
                       (taicpu(p).oper[0]^.ref^.relsymbol=taicpu(hp1).oper[0]^.ref^.relsymbol) and
-                      (taicpu(p).oper[0]^.ref^.offset+2=taicpu(hp1).oper[0]^.ref^.offset) and
-                      assigned(FindRegDealloc(taicpu(hp2).oper[0]^.reg,tai(hp2.Next)))  then
+                      (taicpu(p).oper[0]^.ref^.offset+2=taicpu(hp1).oper[0]^.ref^.offset) then
                       begin
                       begin
                         case taicpu(hp2).oper[1]^.reg of
                         case taicpu(hp2).oper[1]^.reg of
                           NR_DS:
                           NR_DS:
@@ -102,8 +103,18 @@ unit aoptcpu;
                           else
                           else
                             internalerror(2015092601);
                             internalerror(2015092601);
                         end;
                         end;
-                        asml.remove(hp1);
-                        hp1.free;
+                        if assigned(FindRegDealloc(taicpu(hp2).oper[0]^.reg,tai(hp2.Next))) then
+                          begin
+                            asml.remove(hp1);
+                            hp1.free;
+                            DebugMsg('Peephole optimizer MovMovMov2LXX',p);
+                          end
+                        else
+                          begin
+                            taicpu(hp1).loadreg(0,taicpu(hp2).oper[1]^.reg);
+                            DebugMsg('Peephole optimizer MovMovMov2LXXMov',p);
+                          end;
+
                         asml.remove(hp2);
                         asml.remove(hp2);
                         hp2.free;
                         hp2.free;
                         result:=true;
                         result:=true;