mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-24 21:11:46 +02:00
* factored out PostPeepholeOptCmp
+ use PostPeepholeOptCmp for x86_64 git-svn-id: trunk@37549 -
This commit is contained in:
parent
bc260d7284
commit
a7ea7fb569
@ -1309,17 +1309,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
A_CMP:
|
A_CMP:
|
||||||
begin
|
if PostPeepholeOptCmp(p) then
|
||||||
if (taicpu(p).oper[0]^.typ = top_const) and
|
Continue;
|
||||||
(taicpu(p).oper[0]^.val = 0) and
|
|
||||||
(taicpu(p).oper[1]^.typ = top_reg) then
|
|
||||||
{change "cmp $0, %reg" to "test %reg, %reg"}
|
|
||||||
begin
|
|
||||||
taicpu(p).opcode := A_TEST;
|
|
||||||
taicpu(p).loadreg(0,taicpu(p).oper[1]^.reg);
|
|
||||||
continue;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
A_MOV:
|
A_MOV:
|
||||||
PostPeepholeOptMov(p);
|
PostPeepholeOptMov(p);
|
||||||
A_MOVZX:
|
A_MOVZX:
|
||||||
|
|||||||
@ -73,6 +73,7 @@ unit aoptx86;
|
|||||||
function OptPass2Jcc(var p : tai) : boolean;
|
function OptPass2Jcc(var p : tai) : boolean;
|
||||||
|
|
||||||
procedure PostPeepholeOptMov(const p : tai);
|
procedure PostPeepholeOptMov(const p : tai);
|
||||||
|
function PostPeepholeOptCmp(var p : tai) : Boolean;
|
||||||
|
|
||||||
procedure OptReferences;
|
procedure OptReferences;
|
||||||
end;
|
end;
|
||||||
@ -2668,6 +2669,20 @@ unit aoptx86;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TX86AsmOptimizer.PostPeepholeOptCmp(var p : tai) : Boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
{ change "cmp $0, %reg" to "test %reg, %reg" }
|
||||||
|
if MatchOpType(taicpu(p),top_const,top_reg) and
|
||||||
|
(taicpu(p).oper[0]^.val = 0) then
|
||||||
|
begin
|
||||||
|
taicpu(p).opcode := A_TEST;
|
||||||
|
taicpu(p).loadreg(0,taicpu(p).oper[1]^.reg);
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TX86AsmOptimizer.OptReferences;
|
procedure TX86AsmOptimizer.OptReferences;
|
||||||
var
|
var
|
||||||
p: tai;
|
p: tai;
|
||||||
|
|||||||
@ -142,6 +142,8 @@ uses
|
|||||||
case taicpu(p).opcode of
|
case taicpu(p).opcode of
|
||||||
A_MOV:
|
A_MOV:
|
||||||
PostPeepholeOptMov(p);
|
PostPeepholeOptMov(p);
|
||||||
|
A_CMP:
|
||||||
|
Result:=PostPeepholeOptCmp(p);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user