Don't do common subexpression elimination for indirect accesses where there is an intervening operation that may write to the same location.

This fixes the bug in the compca05.c test case.
This commit is contained in:
Stephen Heumann 2015-12-20 00:19:24 -06:00
parent 3225a54d76
commit b9446a28a7
1 changed files with 16 additions and 0 deletions

16
DAG.pas
View File

@ -2546,6 +2546,22 @@ var
kill := false;
stop := true;
end {if}
{kill indirect accesses on stores}
{to indirectly-accessible locations}
else if op1^.opcode in [pc_sto,pc_cpi,pc_iil,pc_ili,pc_idl,pc_ild,
pc_cup,pc_cui,pc_tl1,pc_ind] then begin
if list^.opcode in [pc_sto,pc_cpi,pc_iil,pc_ili,pc_idl,pc_ild,
pc_cup,pc_cui,pc_tl1] then begin
kill := true;
stop := true;
end {if}
else if list^.opcode in [pc_str,pc_sro,pc_cop,pc_cpo,pc_lli,
pc_lil,pc_lld,pc_ldl,pc_gli,pc_gil,pc_gld,pc_gdl] then
if Member(list, c_ind) then begin
kill := true;
stop := true;
end {if}
end {else if}
else if list^.opcode in [pc_str,pc_sro,pc_cop,pc_cpo,pc_lli,pc_lil,
pc_lld,pc_ldl,pc_gli,pc_gil,pc_gld,pc_gdl] then begin
if MatchLoc(list, op2) then begin