mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 17:13:02 +02:00
+ change "mov reg1,reg2;imul x,reg2" to "imul x,reg1,reg2" in popt386
(-dnewoptimizations) * shl(d) and shr(d) are considered to have a hardcoded register if they use cl as shift count (since you can't replace them with another register) in csopt386 (also for -dnewoptimizations)
This commit is contained in:
parent
ba7b10c01d
commit
0cbad4fe45
@ -509,11 +509,14 @@ begin
|
||||
{$endif replaceregdebug}
|
||||
end;
|
||||
|
||||
function NoHardCodedRegs(p: paicpu): boolean;
|
||||
function NoHardCodedRegs(p: paicpu; orgReg, newReg: tRegister): boolean;
|
||||
var chCount: byte;
|
||||
begin
|
||||
case p^.opcode of
|
||||
A_IMUL: noHardCodedRegs := p^.ops <> 1;
|
||||
A_SHL,A_SHR,A_SHLD,A_SHRD: noHardCodedRegs :=
|
||||
(p^.oper[0].typ <> top_reg) or
|
||||
((orgReg <> R_ECX) and (newReg <> R_ECX));
|
||||
else
|
||||
begin
|
||||
NoHardCodedRegs := true;
|
||||
@ -716,7 +719,7 @@ begin
|
||||
Not (PPaiProp(endP^.optInfo)^.canBeRemoved) then
|
||||
begin
|
||||
sequenceEnd :=
|
||||
noHardCodedRegs(paicpu(endP)) and
|
||||
noHardCodedRegs(paicpu(endP),orgReg,newReg) and
|
||||
RegLoadedWithNewValue(newReg,true,paicpu(endP)) or
|
||||
(GetNextInstruction(endp,hp) and
|
||||
FindRegDealloc(newReg,hp));
|
||||
@ -739,7 +742,7 @@ begin
|
||||
(orgRegCanBeModified or not(newRegModified)) and
|
||||
(endP^.typ = ait_instruction) and
|
||||
not(paicpu(endP)^.is_jmp) and
|
||||
NoHardCodedRegs(paicpu(endP)) and
|
||||
NoHardCodedRegs(paicpu(endP),orgReg,newReg) and
|
||||
RegSizesOk(orgReg,newReg,paicpu(endP)) and
|
||||
not RegModifiedByInstruction(orgReg,endP);
|
||||
end;
|
||||
@ -747,7 +750,7 @@ begin
|
||||
sequenceEnd := sequenceEnd and
|
||||
(not(assigned(endp)) or
|
||||
not(endp^.typ = ait_instruction) or
|
||||
(noHardCodedRegs(paicpu(endP)) and
|
||||
(noHardCodedRegs(paicpu(endP),orgReg,newReg) and
|
||||
RegSizesOk(orgReg,newReg,paicpu(endP)) and
|
||||
not(newRegModified and
|
||||
(orgReg in PPaiProp(endP^.optInfo)^.usedRegs) and
|
||||
@ -1142,31 +1145,33 @@ Begin
|
||||
End;
|
||||
|
||||
Procedure RemoveInstructs(AsmL: PAasmOutput; First, Last: Pai);
|
||||
{Removes the marked instructions and disposes the PPaiProps of the other
|
||||
instructions, restoring their line number}
|
||||
{ Removes the marked instructions and disposes the PPaiProps of the other }
|
||||
{ instructions }
|
||||
Var p, hp1: Pai;
|
||||
{$IfDef TP}
|
||||
TmpLine: Longint;
|
||||
{$EndIf TP}
|
||||
InstrCnt: Longint;
|
||||
Begin
|
||||
begin
|
||||
p := First;
|
||||
SkipHead(P);
|
||||
InstrCnt := 1;
|
||||
While (p <> Last) Do
|
||||
Begin
|
||||
If (p^.typ = ait_marker) and
|
||||
(pai_marker(p)^.kind in [noPropInfoStart,noPropInfoEnd]) then
|
||||
begin
|
||||
hp1 := pai(p^.next);
|
||||
asmL^.remove(p);
|
||||
dispose(p,done);
|
||||
p := hp1
|
||||
end
|
||||
else
|
||||
{$ifndef noinstremove}
|
||||
If PPaiProp(p^.OptInfo)^.CanBeRemoved
|
||||
Then
|
||||
Begin
|
||||
if assigned(p^.optInfo) and
|
||||
PPaiProp(p^.optInfo)^.canBeRemoved then
|
||||
begin
|
||||
{$IfDef TP}
|
||||
Dispose(PPaiProp(p^.OptInfo));
|
||||
{$EndIf}
|
||||
GetNextInstruction(p, hp1);
|
||||
hp1 := pai(p^.next);
|
||||
AsmL^.Remove(p);
|
||||
Dispose(p, Done);
|
||||
p := hp1;
|
||||
Inc(InstrCnt);
|
||||
End
|
||||
Else
|
||||
{$endif noinstremove}
|
||||
@ -1175,8 +1180,7 @@ Begin
|
||||
Dispose(PPaiProp(p^.OptInfo));
|
||||
{$EndIf TP}
|
||||
p^.OptInfo := nil;
|
||||
GetNextInstruction(p, p);
|
||||
Inc(InstrCnt);
|
||||
p := pai(p^.next);;
|
||||
End;
|
||||
End;
|
||||
{$IfNDef TP}
|
||||
@ -1194,7 +1198,14 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.49 2000-02-12 10:54:18 jonas
|
||||
Revision 1.50 2000-02-12 14:10:14 jonas
|
||||
+ change "mov reg1,reg2;imul x,reg2" to "imul x,reg1,reg2" in popt386
|
||||
(-dnewoptimizations)
|
||||
* shl(d) and shr(d) are considered to have a hardcoded register if
|
||||
they use cl as shift count (since you can't replace them with
|
||||
another register) in csopt386 (also for -dnewoptimizations)
|
||||
|
||||
Revision 1.49 2000/02/12 10:54:18 jonas
|
||||
* fixed edi allocation in allocRegBetween
|
||||
* fixed bug I introduced yesterday, added comment to prevent it from
|
||||
happening again in the future
|
||||
|
@ -44,7 +44,7 @@ Uses
|
||||
{$ifdef finaldestdebug}
|
||||
cobjects,
|
||||
{$endif finaldestdebug}
|
||||
cpubase,cpuasm,DAOpt386;
|
||||
cpubase,cpuasm,DAOpt386,cobjects;
|
||||
|
||||
Function RegUsedAfterInstruction(Reg: TRegister; p: Pai; Var UsedRegs: TRegSet): Boolean;
|
||||
Begin
|
||||
@ -1738,6 +1738,29 @@ Begin
|
||||
A_FSTP,A_FISTP:
|
||||
if doFpuLoadStoreOpt(asmL,p) then
|
||||
continue;
|
||||
{$ifdef foldArithOps}
|
||||
A_IMUL:
|
||||
begin
|
||||
if (paicpu(p)^.oper[1].typ = top_reg) and
|
||||
((paicpu(p)^.oper[2].typ = top_none) or
|
||||
((paicpu(p)^.oper[2].typ = top_reg) and
|
||||
(paicpu(p)^.oper[2].reg = paicpu(p)^.oper[1].reg))) and
|
||||
getLastInstruction(p,hp1) and
|
||||
(hp1^.typ = ait_instruction) and
|
||||
(paicpu(hp1)^.opcode = A_MOV) and
|
||||
(paicpu(hp1)^.oper[0].typ = top_reg) and
|
||||
(paicpu(hp1)^.oper[1].typ = top_reg) and
|
||||
(paicpu(hp1)^.oper[1].reg = paicpu(p)^.oper[1].reg) then
|
||||
{ change "mov reg1,reg2; imul y,reg2" to "imul y,reg1,reg2" }
|
||||
begin
|
||||
paicpu(p)^.ops := 3;
|
||||
paicpu(p)^.loadreg(1,paicpu(hp1)^.oper[0].reg);
|
||||
paicpu(p)^.loadreg(2,paicpu(hp1)^.oper[1].reg);
|
||||
asmL^.remove(hp1);
|
||||
dispose(hp1,done);
|
||||
end;
|
||||
end;
|
||||
{$endif foldArithOps}
|
||||
A_MOV:
|
||||
Begin
|
||||
If (Paicpu(p)^.oper[0].typ = top_reg) And
|
||||
@ -1865,7 +1888,14 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.84 2000-02-09 13:22:58 peter
|
||||
Revision 1.85 2000-02-12 14:10:15 jonas
|
||||
+ change "mov reg1,reg2;imul x,reg2" to "imul x,reg1,reg2" in popt386
|
||||
(-dnewoptimizations)
|
||||
* shl(d) and shr(d) are considered to have a hardcoded register if
|
||||
they use cl as shift count (since you can't replace them with
|
||||
another register) in csopt386 (also for -dnewoptimizations)
|
||||
|
||||
Revision 1.84 2000/02/09 13:22:58 peter
|
||||
* log truncated
|
||||
|
||||
Revision 1.83 2000/02/04 13:53:04 jonas
|
||||
|
Loading…
Reference in New Issue
Block a user