Fixed an off-by-one error in a_load_const_cgpara which caused some problems.

Added some minor CG optimizations.

git-svn-id: trunk@32088 -
This commit is contained in:
Jeppe Johansen 2015-10-18 11:03:57 +00:00
parent be6bcb71dc
commit 1a285a7d24

View File

@ -316,10 +316,11 @@ unit cgcpu;
hp:=paraloc.location;
i:=1;
while i<tcgsize2size[paraloc.Size] do
while i<=tcgsize2size[paraloc.Size] do
begin
if not(assigned(hp)) then
internalerror(2014011105);
//paramanager.allocparaloc(list,hp);
case hp^.loc of
LOC_REGISTER,LOC_CREGISTER:
begin
@ -327,8 +328,9 @@ unit cgcpu;
(hp^.shiftval<>0) then
internalerror(2015041101);
a_load_const_reg(list,hp^.size,(a shr (8*(i-1))) and $ff,hp^.register);
inc(i,tcgsize2size[hp^.size]);
hp:=hp^.Next;
inc(i);
end;
LOC_REFERENCE,LOC_CREFERENCE:
begin
@ -776,7 +778,8 @@ unit cgcpu;
begin
for i:=1 to tcgsize2size[size] do
begin
list.concat(taicpu.op_reg_const(A_ORI,reg,(qword(a) and mask) shr shift));
if ((qword(a) and mask) shr shift)<>0 then
list.concat(taicpu.op_reg_const(A_ORI,reg,(qword(a) and mask) shr shift));
NextReg;
mask:=mask shl 8;
inc(shift,8);
@ -786,7 +789,10 @@ unit cgcpu;
begin
for i:=1 to tcgsize2size[size] do
begin
list.concat(taicpu.op_reg_const(A_ANDI,reg,(qword(a) and mask) shr shift));
if ((qword(a) and mask) shr shift)=0 then
list.concat(taicpu.op_reg_reg(A_MOV,reg,NR_R1))
else
list.concat(taicpu.op_reg_const(A_ANDI,reg,(qword(a) and mask) shr shift));
NextReg;
mask:=mask shl 8;
inc(shift,8);
@ -794,7 +800,10 @@ unit cgcpu;
end;
OP_SUB:
begin
list.concat(taicpu.op_reg_const(A_SUBI,reg,a and mask));
if ((a and mask)=1) and (tcgsize2size[size]=1) then
list.concat(taicpu.op_reg(A_DEC,reg))
else
list.concat(taicpu.op_reg_const(A_SUBI,reg,a and mask));
if size in [OS_S16,OS_16,OS_S32,OS_32,OS_S64,OS_64] then
begin
for i:=2 to tcgsize2size[size] do
@ -882,6 +891,8 @@ unit cgcpu;
curvalue:=a and mask;
if curvalue=0 then
list.concat(taicpu.op_reg_reg(A_ADD,reg,NR_R1))
else if (curvalue=1) and (tcgsize2size[size]=1) then
list.concat(taicpu.op_reg(A_INC,reg))
else
begin
tmpreg:=getintregister(list,OS_8);