mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-20 03:11:39 +02:00
* i386 uses OptPass1And from aoptx86
git-svn-id: trunk@33936 -
This commit is contained in:
parent
ff506eb219
commit
7f44774852
@ -835,34 +835,8 @@ begin
|
||||
end;
|
||||
case taicpu(p).opcode Of
|
||||
A_AND:
|
||||
begin
|
||||
if (taicpu(p).oper[0]^.typ = top_const) and
|
||||
(taicpu(p).oper[1]^.typ = top_reg) and
|
||||
GetNextInstruction(p, hp1) and
|
||||
(tai(hp1).typ = ait_instruction) and
|
||||
(taicpu(hp1).opcode = A_AND) and
|
||||
(taicpu(hp1).oper[0]^.typ = top_const) and
|
||||
(taicpu(hp1).oper[1]^.typ = top_reg) and
|
||||
(getsupreg(taicpu(p).oper[1]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg)) and
|
||||
(getsubreg(taicpu(p).oper[1]^.reg)<=getsubreg(taicpu(hp1).oper[1]^.reg)) then
|
||||
{change "and const1, reg; and const2, reg" to "and (const1 and const2), reg"}
|
||||
begin
|
||||
taicpu(hp1).loadConst(0,taicpu(p).oper[0]^.val and taicpu(hp1).oper[0]^.val);
|
||||
asml.remove(p);
|
||||
p.free;
|
||||
p:=hp1;
|
||||
end
|
||||
else
|
||||
{change "and x, reg; jxx" to "test x, reg", if reg is deallocated before the
|
||||
jump, but only if it's a conditional jump (PFV) }
|
||||
if (taicpu(p).oper[1]^.typ = top_reg) and
|
||||
GetNextInstruction(p, hp1) and
|
||||
(hp1.typ = ait_instruction) and
|
||||
(taicpu(hp1).is_jmp) and
|
||||
(taicpu(hp1).opcode<>A_JMP) and
|
||||
not(RegInUsedRegs(taicpu(p).oper[1]^.reg,UsedRegs)) then
|
||||
taicpu(p).opcode := A_TEST;
|
||||
end;
|
||||
if OptPass1And(p) then
|
||||
continue;
|
||||
A_CMP:
|
||||
begin
|
||||
{ cmp register,$8000 neg register
|
||||
|
@ -1155,19 +1155,26 @@ unit aoptx86;
|
||||
(((taicpu(p).opsize=S_W) and
|
||||
(taicpu(hp1).opsize=S_BW)) or
|
||||
((taicpu(p).opsize=S_L) and
|
||||
(taicpu(hp1).opsize in [S_WL,S_BL])) or
|
||||
(taicpu(hp1).opsize in [S_WL,S_BL]))
|
||||
{$ifdef x86_64}
|
||||
or
|
||||
((taicpu(p).opsize=S_Q) and
|
||||
(taicpu(hp1).opsize in [S_BQ,S_WQ,S_LQ]))
|
||||
(taicpu(hp1).opsize in [S_BQ,S_WQ,S_LQ]))
|
||||
{$endif x86_64}
|
||||
) then
|
||||
begin
|
||||
if (((taicpu(hp1).opsize) in [S_BW,S_BL,S_BQ]) and
|
||||
if (((taicpu(hp1).opsize) in [S_BW,S_BL{$ifdef x86_64},S_BQ{$endif x86_64}]) and
|
||||
((taicpu(p).oper[0]^.val and $ff)=taicpu(p).oper[0]^.val)
|
||||
) or
|
||||
(((taicpu(hp1).opsize) in [S_WL,S_WQ]) and
|
||||
((taicpu(p).oper[0]^.val and $ffff)=taicpu(p).oper[0]^.val)) or
|
||||
(((taicpu(hp1).opsize) in [S_WL{$ifdef x86_64},S_WQ{$endif x86_64}]) and
|
||||
((taicpu(p).oper[0]^.val and $ffff)=taicpu(p).oper[0]^.val))
|
||||
{$ifdef x86_64}
|
||||
or
|
||||
(((taicpu(hp1).opsize)=S_LQ) and
|
||||
((taicpu(p).oper[0]^.val and $ffffffff)=taicpu(p).oper[0]^.val)
|
||||
) then
|
||||
)
|
||||
{$endif x86_64}
|
||||
then
|
||||
begin
|
||||
DebugMsg('Peephole AndMovzToAnd done',p);
|
||||
asml.remove(hp1);
|
||||
@ -1175,28 +1182,33 @@ unit aoptx86;
|
||||
end;
|
||||
end
|
||||
else if MatchOpType(p,top_const,top_reg) and
|
||||
MatchInstruction(hp1,A_MOVSX,A_MOVSXD,[]) and
|
||||
MatchInstruction(hp1,A_MOVSX{$ifdef x86_64},A_MOVSXD{$endif x86_64},[]) and
|
||||
(taicpu(hp1).oper[0]^.typ = top_reg) and
|
||||
MatchOperand(taicpu(p).oper[1]^,taicpu(hp1).oper[1]^) and
|
||||
(getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg)) and
|
||||
(((taicpu(p).opsize=S_W) and
|
||||
(taicpu(hp1).opsize=S_BW)) or
|
||||
((taicpu(p).opsize=S_L) and
|
||||
(taicpu(hp1).opsize in [S_WL,S_BL])) or
|
||||
(taicpu(hp1).opsize in [S_WL,S_BL]))
|
||||
{$ifdef x86_64}
|
||||
or
|
||||
((taicpu(p).opsize=S_Q) and
|
||||
(taicpu(hp1).opsize in [S_BQ,S_WQ,S_LQ]))
|
||||
{$endif x86_64}
|
||||
) then
|
||||
begin
|
||||
if (((taicpu(hp1).opsize) in [S_BW,S_BL,S_BQ]) and
|
||||
if (((taicpu(hp1).opsize) in [S_BW,S_BL{$ifdef x86_64},S_BQ{$endif x86_64}]) and
|
||||
((taicpu(p).oper[0]^.val and $7f)=taicpu(p).oper[0]^.val)
|
||||
) or
|
||||
(((taicpu(hp1).opsize) in [S_WL,S_WQ]) and
|
||||
((taicpu(p).oper[0]^.val and $7fff)=taicpu(p).oper[0]
|
||||
^.val)) or
|
||||
(((taicpu(hp1).opsize) in [S_WL{$ifdef x86_64},S_WQ{$endif x86_64}]) and
|
||||
((taicpu(p).oper[0]^.val and $7fff)=taicpu(p).oper[0]^.val))
|
||||
{$ifdef x86_64}
|
||||
or
|
||||
(((taicpu(hp1).opsize)=S_LQ) and
|
||||
((taicpu(p).oper[0]^.val and $7fffffff)=taicpu(p).oper[0]
|
||||
^.val)
|
||||
) then
|
||||
((taicpu(p).oper[0]^.val and $7fffffff)=taicpu(p).oper[0]^.val)
|
||||
)
|
||||
{$endif x86_64}
|
||||
then
|
||||
begin
|
||||
DebugMsg('PeepHole Optimization,AndMovsxToAnd',p);
|
||||
asml.remove(hp1);
|
||||
|
Loading…
Reference in New Issue
Block a user