From 95f518244212c1d1d46500da21c096c6bf8dee3b Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 5 Mar 2021 19:44:38 -0600 Subject: [PATCH] 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). --- Gen.pas | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Gen.pas b/Gen.pas index 51c38f9..c027e31 100644 --- a/Gen.pas +++ b/Gen.pas @@ -6528,6 +6528,17 @@ procedure GenTree {op: icptr}; skipLoad := true; if op^.left^.opcode = pc_mov then 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 GenTree(op^.left); if isIncLoad then