From 342524c31234981a48e52659d07ff2e52cbd81b4 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 2 Nov 2022 22:14:12 +0100 Subject: [PATCH] * run dead store elimination multiple times if needed --- compiler/optdeadstore.pas | 6 ++---- compiler/psub.pas | 13 ++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/compiler/optdeadstore.pas b/compiler/optdeadstore.pas index 15cc52658c..72af98e611 100644 --- a/compiler/optdeadstore.pas +++ b/compiler/optdeadstore.pas @@ -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 **********************'); diff --git a/compiler/psub.pas b/compiler/psub.pas index 1637da941e..60702a347a 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -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