mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-16 18:26:00 +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;
|
||||
A_CMP:
|
||||
begin
|
||||
if (taicpu(p).oper[0]^.typ = top_const) and
|
||||
(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;
|
||||
if PostPeepholeOptCmp(p) then
|
||||
Continue;
|
||||
A_MOV:
|
||||
PostPeepholeOptMov(p);
|
||||
A_MOVZX:
|
||||
|
@ -73,6 +73,7 @@ unit aoptx86;
|
||||
function OptPass2Jcc(var p : tai) : boolean;
|
||||
|
||||
procedure PostPeepholeOptMov(const p : tai);
|
||||
function PostPeepholeOptCmp(var p : tai) : Boolean;
|
||||
|
||||
procedure OptReferences;
|
||||
end;
|
||||
@ -2668,6 +2669,20 @@ unit aoptx86;
|
||||
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;
|
||||
var
|
||||
p: tai;
|
||||
|
@ -142,6 +142,8 @@ uses
|
||||
case taicpu(p).opcode of
|
||||
A_MOV:
|
||||
PostPeepholeOptMov(p);
|
||||
A_CMP:
|
||||
Result:=PostPeepholeOptCmp(p);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user