|
@@ -111,16 +111,6 @@ unit aoptx86;
|
|
and having an offset }
|
|
and having an offset }
|
|
function MatchReferenceWithOffset(const ref : treference;base,index : TRegister) : Boolean;
|
|
function MatchReferenceWithOffset(const ref : treference;base,index : TRegister) : Boolean;
|
|
|
|
|
|
-{$ifdef DEBUG_AOPTCPU}
|
|
|
|
- const
|
|
|
|
- SPeepholeOptimization: shortstring = 'Peephole Optimization: ';
|
|
|
|
-{$else DEBUG_AOPTCPU}
|
|
|
|
- { Empty strings help the optimizer to remove string concatenations that won't
|
|
|
|
- ever appear to the user on release builds. [Kit] }
|
|
|
|
- const
|
|
|
|
- SPeepholeOptimization = '';
|
|
|
|
-{$endif DEBUG_AOPTCPU}
|
|
|
|
-
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
@@ -134,6 +124,16 @@ unit aoptx86;
|
|
cgx86,
|
|
cgx86,
|
|
itcpugas;
|
|
itcpugas;
|
|
|
|
|
|
|
|
+{$ifdef DEBUG_AOPTCPU}
|
|
|
|
+ const
|
|
|
|
+ SPeepholeOptimization: shortstring = 'Peephole Optimization: ';
|
|
|
|
+{$else DEBUG_AOPTCPU}
|
|
|
|
+ { Empty strings help the optimizer to remove string concatenations that won't
|
|
|
|
+ ever appear to the user on release builds. [Kit] }
|
|
|
|
+ const
|
|
|
|
+ SPeepholeOptimization = '';
|
|
|
|
+{$endif DEBUG_AOPTCPU}
|
|
|
|
+
|
|
function MatchInstruction(const instr: tai; const op: TAsmOp; const opsize: topsizes): boolean;
|
|
function MatchInstruction(const instr: tai; const op: TAsmOp; const opsize: topsizes): boolean;
|
|
begin
|
|
begin
|
|
result :=
|
|
result :=
|
|
@@ -3427,9 +3427,9 @@ unit aoptx86;
|
|
jmp<inv_cond> @Lbl2
|
|
jmp<inv_cond> @Lbl2
|
|
ret
|
|
ret
|
|
}
|
|
}
|
|
- if MatchInstruction(hp1, A_JMP, []) then
|
|
|
|
|
|
+ if MatchInstruction(hp1,A_JMP,[]) and (taicpu(hp1).oper[0]^.ref^.refaddr=addr_full) then
|
|
begin
|
|
begin
|
|
- hp2 := getlabelwithsym(TAsmLabel(symbol));
|
|
|
|
|
|
+ hp2:=getlabelwithsym(TAsmLabel(symbol));
|
|
if Assigned(hp2) and SkipLabels(hp2,hp2) and
|
|
if Assigned(hp2) and SkipLabels(hp2,hp2) and
|
|
MatchInstruction(hp2,A_RET,[S_NO]) then
|
|
MatchInstruction(hp2,A_RET,[S_NO]) then
|
|
begin
|
|
begin
|
|
@@ -3442,6 +3442,7 @@ unit aoptx86;
|
|
taicpu(hp1).opcode := A_RET;
|
|
taicpu(hp1).opcode := A_RET;
|
|
taicpu(hp1).is_jmp := false;
|
|
taicpu(hp1).is_jmp := false;
|
|
taicpu(hp1).ops := taicpu(hp2).ops;
|
|
taicpu(hp1).ops := taicpu(hp2).ops;
|
|
|
|
+ DebugMsg(SPeepholeOptimization+'JccJmpRet2J!ccRet',p);
|
|
case taicpu(hp2).ops of
|
|
case taicpu(hp2).ops of
|
|
0:
|
|
0:
|
|
taicpu(hp1).clearop(0);
|
|
taicpu(hp1).clearop(0);
|
|
@@ -3522,6 +3523,8 @@ unit aoptx86;
|
|
{ Now we can safely decrement the reference count }
|
|
{ Now we can safely decrement the reference count }
|
|
tasmlabel(symbol).decrefs;
|
|
tasmlabel(symbol).decrefs;
|
|
|
|
|
|
|
|
+ DebugMsg(SPeepholeOptimization+'JccMov2CMov',p);
|
|
|
|
+
|
|
{ Remove the original jump }
|
|
{ Remove the original jump }
|
|
asml.Remove(p);
|
|
asml.Remove(p);
|
|
p.Free;
|
|
p.Free;
|
|
@@ -3619,6 +3622,8 @@ unit aoptx86;
|
|
optional align marker. [Kit] }
|
|
optional align marker. [Kit] }
|
|
GetNextInstruction(hp2, hp4);
|
|
GetNextInstruction(hp2, hp4);
|
|
|
|
|
|
|
|
+ DebugMsg(SPeepholeOptimization+'JccMovJmpMov2CMovCMov',hp1);
|
|
|
|
+
|
|
{ remove jCC }
|
|
{ remove jCC }
|
|
asml.remove(hp1);
|
|
asml.remove(hp1);
|
|
hp1.free;
|
|
hp1.free;
|