Avoid a precision reduction in some cases where it is not needed.

This commit is contained in:
Stephen Heumann 2021-03-06 23:14:29 -06:00
parent fc515108f4
commit acddd93ffb
2 changed files with 25 additions and 5 deletions

21
DAG.pas
View File

@ -586,7 +586,12 @@ var
end;
begin {RealStoreOptimizations}
if opl^.opcode = pc_ngr then begin
if opl^.opcode = pc_cnv then
if baseTypeEnum(opl^.q & $000F) = op^.optype then
opl^.q := (opl^.q & $FFF0) | ord(cgExtended);
if (op^.optype = cgComp) or not (op^.opcode in [pc_sro,pc_str,pc_sto]) then
{skip below optimizations}
else if opl^.opcode = pc_ngr then begin
same := false;
with opl^.left^ do
if op^.opcode = pc_sro then begin
@ -1452,6 +1457,16 @@ case op^.opcode of {check for optimizations of this node}
end; {else if}
end; {case pc_cnv}
pc_cop,pc_cpo: begin {pc_cop,pc_cpo}
if op^.optype in [cgReal,cgDouble,cgExtended,cgComp] then
RealStoreOptimizations(op, op^.left);
end; {case pc_cop,pc_cpo}
pc_cpi: begin {pc_cpi}
if op^.optype in [cgReal,cgDouble,cgExtended,cgComp] then
RealStoreOptimizations(op, op^.right);
end; {case pc_cpi}
pc_dec: begin {pc_dec}
if op^.q = 0 then
opv := op^.left
@ -2427,12 +2442,12 @@ case op^.opcode of {check for optimizations of this node}
end; {case pc_slq}
pc_sro, pc_str: begin {pc_sro, pc_str}
if op^.optype in [cgReal,cgDouble,cgExtended] then
if op^.optype in [cgReal,cgDouble,cgExtended,cgComp] then
RealStoreOptimizations(op, op^.left);
end; {case pc_sro, pc_str}
pc_sto: begin {pc_sto}
if op^.optype in [cgReal,cgDouble,cgExtended] then
if op^.optype in [cgReal,cgDouble,cgExtended,cgComp] then
RealStoreOptimizations(op, op^.right);
if op^.left^.opcode = pc_lao then begin
op^.q := op^.left^.q;

View File

@ -1731,11 +1731,14 @@ else if op^.q in [wordToByte,uwordToByte] then begin
GenNative(m_ora_imm, immediate, $FF00, nil, 0);
GenLab(lab1);
end {else if}
else if op^.q in [byteToReal,uByteToReal,wordToReal] then
GenCall(11)
else if op^.q in [byteToReal,uByteToReal,wordToReal] then begin
GenCall(11);
toRealType := cgExtended;
end {else if}
else if op^.q = uwordToReal then begin
GenNative(m_ldx_imm, immediate, 0, nil, 0);
GenCall(12);
toRealType := cgExtended;
end {else if}
else if op^.q in [longToUbyte,ulongToUbyte] then begin
if gLong.where = A_X then
@ -1786,6 +1789,8 @@ else if op^.q in [longToReal,uLongToReal] then begin
GenCall(12)
else
GenCall(13);
if toRealType <> cgReal then
toRealType := cgExtended;
end {else if}
else if op^.q = realToWord then
GenCall(14)