mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-06 05:07:20 +01:00
Fix a broken OpCp2Op optimization. It needed the added NR_DEFAULTFLAGS allocation to not break subsequent optimizations.
Updated the code for a_load_const_cgpara in case it needed stack parameters. This was completely broken before. Now it should allow things to compile at least. git-svn-id: trunk@32086 -
This commit is contained in:
parent
9193954d1c
commit
7fc3ed2644
@ -171,14 +171,19 @@ Implementation
|
|||||||
A_INC,A_LSL,A_LSR,
|
A_INC,A_LSL,A_LSR,
|
||||||
A_OR,A_ORI,A_ROL,A_ROR,A_SBC,A_SBCI,A_SUB,A_SUBI]) and
|
A_OR,A_ORI,A_ROL,A_ROR,A_SBC,A_SBCI,A_SUB,A_SUBI]) and
|
||||||
GetNextInstruction(p, hp1) and
|
GetNextInstruction(p, hp1) and
|
||||||
MatchInstruction(hp1, A_CP) and
|
((MatchInstruction(hp1, A_CP) and
|
||||||
(((taicpu(p).oper[0]^.reg = taicpu(hp1).oper[0]^.reg) and
|
(((taicpu(p).oper[0]^.reg = taicpu(hp1).oper[0]^.reg) and
|
||||||
(taicpu(hp1).oper[1]^.reg = NR_R1)) or
|
(taicpu(hp1).oper[1]^.reg = NR_R1)) or
|
||||||
((taicpu(p).oper[0]^.reg = taicpu(hp1).oper[1]^.reg) and
|
((taicpu(p).oper[0]^.reg = taicpu(hp1).oper[1]^.reg) and
|
||||||
(taicpu(hp1).oper[0]^.reg = NR_R1) and
|
(taicpu(hp1).oper[0]^.reg = NR_R1) and
|
||||||
(taicpu(p).opcode in [A_ADC,A_ADD,A_AND,A_ANDI,A_ASR,A_COM,A_EOR,
|
(taicpu(p).opcode in [A_ADC,A_ADD,A_AND,A_ANDI,A_ASR,A_COM,A_EOR,
|
||||||
A_LSL,A_LSR,
|
A_LSL,A_LSR,
|
||||||
A_OR,A_ORI,A_ROL,A_ROR]))) and
|
A_OR,A_ORI,A_ROL,A_ROR])))) or
|
||||||
|
(MatchInstruction(hp1, A_CPI) and
|
||||||
|
(taicpu(p).opcode in [A_ANDI,A_ORI]) and
|
||||||
|
(taicpu(p).oper[1]^.typ=top_const) and
|
||||||
|
(taicpu(hp1).oper[1]^.typ=top_const) and
|
||||||
|
(taicpu(p).oper[1]^.val=taicpu(hp1).oper[1]^.val))) and
|
||||||
GetNextInstruction(hp1, hp2) and
|
GetNextInstruction(hp1, hp2) and
|
||||||
{ be careful here, following instructions could use other flags
|
{ be careful here, following instructions could use other flags
|
||||||
however after a jump fpc never depends on the value of flags }
|
however after a jump fpc never depends on the value of flags }
|
||||||
@ -203,6 +208,10 @@ Implementation
|
|||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asml.InsertBefore(tai_regalloc.alloc(NR_DEFAULTFLAGS,p), p);
|
||||||
|
asml.InsertAfter(tai_regalloc.dealloc(NR_DEFAULTFLAGS,hp2), hp2);
|
||||||
|
IncludeRegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs);
|
||||||
|
|
||||||
DebugMsg('Peephole OpCp2Op performed', p);
|
DebugMsg('Peephole OpCp2Op performed', p);
|
||||||
|
|
||||||
asml.remove(hp1);
|
asml.remove(hp1);
|
||||||
@ -584,6 +593,7 @@ Implementation
|
|||||||
(not RegModifiedBetween(taicpu(p).oper[1]^.reg, p, hp1)) and
|
(not RegModifiedBetween(taicpu(p).oper[1]^.reg, p, hp1)) and
|
||||||
(hp1.typ = ait_instruction) and
|
(hp1.typ = ait_instruction) and
|
||||||
(taicpu(hp1).opcode in [A_PUSH,A_MOV,A_CP,A_CPC,A_ADD,A_SUB,A_ADC,A_SBC,A_EOR,A_AND,A_OR,
|
(taicpu(hp1).opcode in [A_PUSH,A_MOV,A_CP,A_CPC,A_ADD,A_SUB,A_ADC,A_SBC,A_EOR,A_AND,A_OR,
|
||||||
|
A_STD,A_ST,
|
||||||
A_OUT,A_IN]) and
|
A_OUT,A_IN]) and
|
||||||
RegInInstruction(taicpu(p).oper[0]^.reg, hp1) and
|
RegInInstruction(taicpu(p).oper[0]^.reg, hp1) and
|
||||||
(not RegModifiedByInstruction(taicpu(p).oper[0]^.reg, hp1)) and
|
(not RegModifiedByInstruction(taicpu(p).oper[0]^.reg, hp1)) and
|
||||||
|
|||||||
@ -308,13 +308,15 @@ unit cgcpu;
|
|||||||
var
|
var
|
||||||
i : longint;
|
i : longint;
|
||||||
hp : PCGParaLocation;
|
hp : PCGParaLocation;
|
||||||
|
ref: treference;
|
||||||
begin
|
begin
|
||||||
if not(tcgsize2size[paraloc.Size] in [1..4]) then
|
if not(tcgsize2size[paraloc.Size] in [1..4]) then
|
||||||
internalerror(2014011101);
|
internalerror(2014011101);
|
||||||
|
|
||||||
hp:=paraloc.location;
|
hp:=paraloc.location;
|
||||||
|
|
||||||
for i:=1 to tcgsize2size[paraloc.Size] do
|
i:=1;
|
||||||
|
while i<tcgsize2size[paraloc.Size] do
|
||||||
begin
|
begin
|
||||||
if not(assigned(hp)) then
|
if not(assigned(hp)) then
|
||||||
internalerror(2014011105);
|
internalerror(2014011105);
|
||||||
@ -326,9 +328,18 @@ unit cgcpu;
|
|||||||
internalerror(2015041101);
|
internalerror(2015041101);
|
||||||
a_load_const_reg(list,hp^.size,(a shr (8*(i-1))) and $ff,hp^.register);
|
a_load_const_reg(list,hp^.size,(a shr (8*(i-1))) and $ff,hp^.register);
|
||||||
hp:=hp^.Next;
|
hp:=hp^.Next;
|
||||||
|
inc(i);
|
||||||
end;
|
end;
|
||||||
LOC_REFERENCE,LOC_CREFERENCE:
|
LOC_REFERENCE,LOC_CREFERENCE:
|
||||||
list.concat(taicpu.op_const(A_PUSH,(a shr (8*(i-1))) and $ff));
|
begin
|
||||||
|
reference_reset(ref,paraloc.alignment);
|
||||||
|
ref.base:=hp^.reference.index;
|
||||||
|
ref.offset:=hp^.reference.offset;
|
||||||
|
a_load_const_ref(list,hp^.size,a shr (8*(i-1)),ref);
|
||||||
|
|
||||||
|
inc(i,tcgsize2size[hp^.size]);
|
||||||
|
hp:=hp^.Next;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
internalerror(2002071004);
|
internalerror(2002071004);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user