* factored out PostPeepholeOptCmp

+ use PostPeepholeOptCmp for x86_64

git-svn-id: trunk@37549 -
This commit is contained in:
florian 2017-11-04 19:10:09 +00:00
parent bc260d7284
commit a7ea7fb569
3 changed files with 19 additions and 11 deletions

View File

@ -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:

View File

@ -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;

View File

@ -142,6 +142,8 @@ uses
case taicpu(p).opcode of
A_MOV:
PostPeepholeOptMov(p);
A_CMP:
Result:=PostPeepholeOptCmp(p);
end;
end;
end;