* run dead store elimination multiple times if needed

This commit is contained in:
florian 2022-11-02 22:14:12 +01:00
parent a0366d7d28
commit 342524c312
2 changed files with 12 additions and 7 deletions

View File

@ -31,7 +31,7 @@ unit optdeadstore;
uses
node;
function do_optdeadstoreelim(var rootnode : tnode) : tnode;
function do_optdeadstoreelim(var rootnode : tnode;changed: boolean) : tnode;
implementation
@ -106,9 +106,7 @@ unit optdeadstore;
end;
function do_optdeadstoreelim(var rootnode: tnode): tnode;
var
changed: boolean;
function do_optdeadstoreelim(var rootnode: tnode;changed: boolean): tnode;
begin
{$ifdef EXTDEBUG_DEADSTORE}
writeln('******************* Tree before deadstore elimination **********************');

View File

@ -1294,15 +1294,22 @@ implementation
tabstractnormalvarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).noregvarinitneeded:=true
end;
end;
if cs_opt_dead_store_eliminate in current_settings.optimizerswitches then
begin
changed:=false;
repeat
do_optdeadstoreelim(code,changed);
if changed then
dfabuilder.redodfainfo(code);
until not(changed);
end;
end
else
begin
ConvertForLoops(code);
end;
if (pi_dfaavailable in flags) and (cs_opt_dead_store_eliminate in current_settings.optimizerswitches) then
do_optdeadstoreelim(code);
if (cs_opt_remove_empty_proc in current_settings.optimizerswitches) and
(procdef.proctypeoption in [potype_operator,potype_procedure,potype_function]) and
(code.nodetype=blockn) and (tblocknode(code).statements=nil) then