mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 18:09:15 +02:00
Improve handling of set operations with constant values on ARM
tarmaddnode.second_cmpsmallset always forced a value into a register even when it could be represented as a constant, resulting in wasted registers. mov r1, #5 cmp r0, r1 If possible we'll now create: cmp r0, #5 git-svn-id: trunk@22366 -
This commit is contained in:
parent
1a895a875b
commit
0f40429389
@ -286,39 +286,54 @@ interface
|
|||||||
procedure tarmaddnode.second_cmpsmallset;
|
procedure tarmaddnode.second_cmpsmallset;
|
||||||
var
|
var
|
||||||
tmpreg : tregister;
|
tmpreg : tregister;
|
||||||
|
b: byte;
|
||||||
begin
|
begin
|
||||||
pass_left_right;
|
pass_left_right;
|
||||||
|
|
||||||
location_reset(location,LOC_FLAGS,OS_NO);
|
location_reset(location,LOC_FLAGS,OS_NO);
|
||||||
|
|
||||||
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
|
||||||
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
|
|
||||||
|
|
||||||
case nodetype of
|
|
||||||
equaln:
|
|
||||||
begin
|
|
||||||
cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
|
|
||||||
location.resflags:=F_EQ;
|
|
||||||
end;
|
|
||||||
unequaln:
|
|
||||||
begin
|
|
||||||
cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
|
|
||||||
location.resflags:=F_NE;
|
|
||||||
end;
|
|
||||||
lten,
|
|
||||||
gten:
|
|
||||||
begin
|
|
||||||
if (not(nf_swapped in flags) and
|
if (not(nf_swapped in flags) and
|
||||||
(nodetype = lten)) or
|
(nodetype = lten)) or
|
||||||
((nf_swapped in flags) and
|
((nf_swapped in flags) and
|
||||||
(nodetype = gten)) then
|
(nodetype = gten)) then
|
||||||
swapleftright;
|
swapleftright;
|
||||||
|
|
||||||
|
(* Try to keep right as a constant *)
|
||||||
|
if (right.location.loc <> LOC_CONSTANT) or
|
||||||
|
not(is_shifter_const(right.location.value, b)) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
|
|
||||||
|
case nodetype of
|
||||||
|
equaln,
|
||||||
|
unequaln:
|
||||||
|
begin
|
||||||
|
cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||||
|
if right.location.loc = LOC_CONSTANT then
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
|
||||||
|
else
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
|
||||||
|
if nodetype = equaln then
|
||||||
|
location.resflags:=F_EQ
|
||||||
|
else
|
||||||
|
location.resflags:=F_NE;
|
||||||
|
end;
|
||||||
|
lten,
|
||||||
|
gten:
|
||||||
|
begin
|
||||||
tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
||||||
|
if right.location.loc = LOC_CONSTANT then
|
||||||
|
begin
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_AND,tmpreg,left.location.register,right.location.value));
|
||||||
|
cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,tmpreg,right.location.value));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_AND,tmpreg,left.location.register,right.location.register));
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_AND,tmpreg,left.location.register,right.location.register));
|
||||||
cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,tmpreg,right.location.register));
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,tmpreg,right.location.register));
|
||||||
|
end;
|
||||||
location.resflags:=F_EQ;
|
location.resflags:=F_EQ;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user