Eliminate extra precision when doing floating-point assignments.

The value of an assignment expression should be exactly what gets written to the destination, without any extra range or precision. Since floating-point expressions generally do have extra precision, we need to load the actual stored value to get rid of it.
This commit is contained in:
Stephen Heumann 2021-03-05 19:21:54 -06:00
parent 4ad7a65de6
commit 4a7e994da8

116
Gen.pas
View File

@ -3936,12 +3936,24 @@ case optype of
GenCall(67); GenCall(67);
end {if} end {if}
else {if opcode = pc_cpo then} begin else {if opcode = pc_cpo then} begin
if optype = cgReal then if optype = cgReal then begin
GenCall(51) GenCall(9);
else if optype = cgDouble then GenNative(m_pea, immediate, q, lab, shift16);
GenCall(52) GenNative(m_pea, immediate, q, lab, 0);
else if optype = cgComp then GenCall(21);
GenCall(68) end {if}
else if optype = cgDouble then begin
GenCall(10);
GenNative(m_pea, immediate, q, lab, shift16);
GenNative(m_pea, immediate, q, lab, 0);
GenCall(22);
end {else if}
else if optype = cgComp then begin
GenCall(66);
GenNative(m_pea, immediate, q, lab, shift16);
GenNative(m_pea, immediate, q, lab, 0);
GenCall(70);
end {else if}
else {if optype = cgExtended then} else {if optype = cgExtended then}
GenCall(69); GenCall(69);
end; {else} end; {else}
@ -4268,32 +4280,47 @@ optype := op^.optype;
case optype of case optype of
cgReal,cgDouble,cgComp,cgExtended: begin cgReal,cgDouble,cgComp,cgExtended: begin
GenTree(op^.right); if opcode = pc_sto then begin
gLong.preference := onStack; GenTree(op^.right);
GenTree(op^.left); gLong.preference := onStack;
if optype = cgReal then begin GenTree(op^.left);
if opcode = pc_sto then if optype = cgReal then
GenCall(9) GenCall(9)
else else if optype = cgDouble then
GenCall(51);
end {if}
else if optype = cgDouble then begin
if opcode = pc_sto then
GenCall(10) GenCall(10)
else else if optype = cgComp then
GenCall(52);
end {else if}
else if optype = cgComp then begin
if opcode = pc_sto then
GenCall(66) GenCall(66)
else else {if optype = cgExtended then}
GenCall(68); GenCall(67);
end {else if} end {if}
else {if optype = cgExtended then} begin else {if opcode = pc_cpi then} begin
if opcode = pc_sto then if optype = cgExtended then begin
GenCall(67) GenTree(op^.right);
else gLong.preference := onStack;
GenTree(op^.left);
GenCall(69); GenCall(69);
end {if}
else begin
gLong.preference := onStack;
GenTree(op^.left);
GenTree(op^.right);
GenNative(m_lda_s, direct, 13, nil, 0);
GenImplied(m_pha);
GenNative(m_lda_s, direct, 13, nil, 0);
GenImplied(m_pha);
if optype = cgReal then begin
GenCall(9);
GenCall(21);
end {if}
else if optype = cgDouble then begin
GenCall(10);
GenCall(22);
end {else if}
else {if optype = cgComp then} begin
GenCall(66);
GenCall(70);
end; {else}
end; {else}
end; {else} end; {else}
end; {case cgReal,cgDouble,cgComp,cgExtended} end; {case cgReal,cgDouble,cgComp,cgExtended}
@ -4660,12 +4687,33 @@ case optype of
GenCall(67); GenCall(67);
end {if} end {if}
else begin else begin
if optype = cgReal then if optype = cgReal then begin
GenCall(51) GenCall(9);
else if optype = cgDouble then GenNative(m_pea, immediate, 0, nil, 0);
GenCall(52) GenImplied(m_tdc);
else if optype = cgComp then GenImplied(m_clc);
GenCall(68) GenNative(m_adc_imm, immediate, disp, nil, 0);
GenImplied(m_pha);
GenCall(21);
end {if}
else if optype = cgDouble then begin
GenCall(10);
GenNative(m_pea, immediate, 0, nil, 0);
GenImplied(m_tdc);
GenImplied(m_clc);
GenNative(m_adc_imm, immediate, disp, nil, 0);
GenImplied(m_pha);
GenCall(22);
end {else if}
else if optype = cgComp then begin
GenCall(66);
GenNative(m_pea, immediate, 0, nil, 0);
GenImplied(m_tdc);
GenImplied(m_clc);
GenNative(m_adc_imm, immediate, disp, nil, 0);
GenImplied(m_pha);
GenCall(70);
end {else if}
else {if optype = cgExtended then} else {if optype = cgExtended then}
GenCall(69); GenCall(69);
end; {else} end; {else}