Change copies to stores when the value is unused.

This was already done by the optimizer, but it is simple enough to just do it all the time. This avoids most performance regressions from the previous commit, and also generates more efficient code for long long stores (in the common cases where the value of an assignment expression is not used in any larger expression).
This commit is contained in:
Stephen Heumann 2021-03-05 19:44:38 -06:00
parent 4a7e994da8
commit 95f5182442

11
Gen.pas
View File

@ -6528,6 +6528,17 @@ procedure GenTree {op: icptr};
skipLoad := true; skipLoad := true;
if op^.left^.opcode = pc_mov then if op^.left^.opcode = pc_mov then
GenMov(op^.left, false) GenMov(op^.left, false)
else if op^.left^.opcode in [pc_cop,pc_cpo,pc_cpi,pc_cbf] then begin
if op^.left^.opcode = pc_cop then
op^.left^.opcode := pc_str
else if op^.left^.opcode = pc_cpo then
op^.left^.opcode := pc_sro
else if op^.left^.opcode = pc_cpi then
op^.left^.opcode := pc_sto
else {if op^.left^.opcode = pc_cbf then}
op^.left^.opcode := pc_sbf;
GenTree(op^.left);
end {else if}
else begin else begin
GenTree(op^.left); GenTree(op^.left);
if isIncLoad then if isIncLoad then