From 09af451c2ea10ba1e8ae29f973743eb8cbb2ed41 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 10 Feb 2018 22:19:57 +0000 Subject: [PATCH] * try to get rid at least of one mov when looking for les/lds optimization + debug messages git-svn-id: trunk@38191 - --- compiler/i8086/aoptcpu.pas | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/compiler/i8086/aoptcpu.pas b/compiler/i8086/aoptcpu.pas index 62cd5a3e56..3c995640f7 100644 --- a/compiler/i8086/aoptcpu.pas +++ b/compiler/i8086/aoptcpu.pas @@ -25,6 +25,8 @@ unit aoptcpu; {$i fpcdefs.inc} +{$define DEBUG_AOPTCPU} + Interface 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^.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^.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 case taicpu(hp2).oper[1]^.reg of NR_DS: @@ -102,8 +103,18 @@ unit aoptcpu; else internalerror(2015092601); 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); hp2.free; result:=true;