mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 19:09:16 +02:00
+ Teach peephole optimizer the cmc/adc trick I used in int_str.
git-svn-id: trunk@9799 -
This commit is contained in:
parent
5fbc947ae8
commit
459382faa8
@ -1745,6 +1745,7 @@ var
|
||||
hp3: tai;
|
||||
{$endif USECMOV}
|
||||
UsedRegs, TmpUsedRegs: TRegSet;
|
||||
carryadd_opcode: Tasmop;
|
||||
|
||||
begin
|
||||
p := BlockStart;
|
||||
@ -1756,8 +1757,61 @@ begin
|
||||
Ait_Instruction:
|
||||
begin
|
||||
case taicpu(p).opcode Of
|
||||
{$ifdef USECMOV}
|
||||
A_Jcc:
|
||||
begin
|
||||
{ jb @@1 cmc
|
||||
inc/dec operand --> adc/sbb operand,0
|
||||
@@1:
|
||||
|
||||
... and ...
|
||||
|
||||
jnb @@1
|
||||
inc/dec operand --> adc/sbb operand,0
|
||||
@@1: }
|
||||
if GetNextInstruction(p,hp1) and (hp1.typ=ait_instruction) and
|
||||
GetNextInstruction(hp1,hp2) and (hp2.typ=ait_label) and
|
||||
(Tasmlabel(Taicpu(p).oper[0]^.ref^.symbol)=Tai_label(hp2).labsym) then
|
||||
begin
|
||||
carryadd_opcode:=A_NONE;
|
||||
if Taicpu(p).condition in [C_NAE,C_B] then
|
||||
begin
|
||||
if Taicpu(hp1).opcode=A_INC then
|
||||
carryadd_opcode:=A_ADC;
|
||||
if Taicpu(hp1).opcode=A_DEC then
|
||||
carryadd_opcode:=A_SBB;
|
||||
if carryadd_opcode<>A_NONE then
|
||||
begin
|
||||
Taicpu(p).clearop(0);
|
||||
Taicpu(p).ops:=0;
|
||||
Taicpu(p).is_jmp:=false;
|
||||
Taicpu(p).opcode:=A_CMC;
|
||||
Taicpu(p).condition:=C_NONE;
|
||||
Taicpu(hp1).ops:=2;
|
||||
Taicpu(hp1).loadoper(1,Taicpu(hp1).oper[0]^);
|
||||
Taicpu(hp1).loadconst(0,0);
|
||||
Taicpu(hp1).opcode:=carryadd_opcode;
|
||||
continue;
|
||||
end;
|
||||
end;
|
||||
if Taicpu(p).condition in [C_AE,C_NB] then
|
||||
begin
|
||||
if Taicpu(hp1).opcode=A_INC then
|
||||
carryadd_opcode:=A_ADC;
|
||||
if Taicpu(hp1).opcode=A_DEC then
|
||||
carryadd_opcode:=A_SBB;
|
||||
if carryadd_opcode<>A_NONE then
|
||||
begin
|
||||
asml.remove(p);
|
||||
p.free;
|
||||
Taicpu(hp1).ops:=2;
|
||||
Taicpu(hp1).loadoper(1,Taicpu(hp1).oper[0]^);
|
||||
Taicpu(hp1).loadconst(0,0);
|
||||
Taicpu(hp1).opcode:=carryadd_opcode;
|
||||
continue;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$ifdef USECMOV}
|
||||
if (current_settings.cputype>=cpu_Pentium2) then
|
||||
begin
|
||||
{ check for
|
||||
@ -1881,6 +1935,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
{$endif USECMOV}
|
||||
end;
|
||||
A_FSTP,A_FISTP:
|
||||
if doFpuLoadStoreOpt(asmL,p) then
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user