Avoid lifting indirect loads out of loops where the value may be modified.

The code was not accounting for the possibility that the loaded-from location aliases with the destination of an indirect store in the loop, or for the possibility that it may be written by a function called in the loop. Since we don't have sophisticated alias analysis, we now conservatively assume there may be aliasing in all such cases.

This fixes #20 (compca20.c) and #21 (compca21.c).
This commit is contained in:
Stephen Heumann 2017-10-28 21:59:15 -05:00
parent 780c639112
commit 1e8413138e
1 changed files with 8 additions and 1 deletions

View File

@ -4040,7 +4040,7 @@ var
[pc_adi,pc_adl,pc_adr,pc_and,pc_lnd,pc_bnd,pc_bal,
pc_bnt,pc_bnl,pc_bor,pc_blr,pc_bxr,pc_blx,pc_bno,
pc_dec,pc_dvi,pc_udi,pc_dvl,pc_udl,pc_dvr,pc_equ,pc_neq,
pc_grt,pc_les,pc_geq,pc_leq,pc_inc,pc_ind,pc_ior,pc_lor,
pc_grt,pc_les,pc_geq,pc_leq,pc_inc,pc_ior,pc_lor,
pc_ixa,pc_lad,pc_lao,pc_lca,pc_lda,pc_ldc,pc_mod,pc_uim,
pc_mdl,pc_ulm,pc_mpi,pc_umi,pc_mpl,pc_uml,pc_mpr,pc_ngi,
pc_ngl,pc_ngr,pc_not,pc_pop,pc_sbf,pc_sbi,pc_sbl,pc_sbr,
@ -4049,6 +4049,13 @@ var
op^.parents := icount;
icount := icount+1;
end {if}
else if opcode = pc_ind then begin
{conservatively assume any indirect stores may alias with op}
if not indirectStores then begin
op^.parents := icount;
icount := icount+1;
end; {if}
end {else if}
else if opcode = pc_cnv then begin
if op^.q & $000F <> ord(cgVoid) then begin
op^.parents := icount;