From: Michael Beck Date: Thu, 20 Sep 2007 09:02:45 +0000 (+0000) Subject: Add a reassoc_running flag used to disable some local optimizations only while reasso... X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=f210fb5c29c0d72050c8150db3b814b624389faa;p=libfirm Add a reassoc_running flag used to disable some local optimizations only while reassoc is running (to prevent endless loops) [r15895] --- diff --git a/ir/ir/irflag_t.def b/ir/ir/irflag_t.def index 80d06db0f..c64bb3b35 100644 --- a/ir/ir/irflag_t.def +++ b/ir/ir/irflag_t.def @@ -114,8 +114,11 @@ I_FLAG(auto_create_sync , 27, OFF) /** Enable Alias-analysis. */ I_FLAG(alias_analysis , 28, ON) +/** This flag is set while the reassociation optimizations are running */ +I_FLAG(reassoc_running , 29, OFF) + /** This flag is set while architecture dependent optimizations are running */ -I_FLAG(arch_dep_running , 29, OFF) +I_FLAG(arch_dep_running , 30, OFF) /** Closed world assumption. */ I_FLAG(closed_world , 31, OFF) diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index b0ba8c800..a16a2b004 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -1943,7 +1943,7 @@ static ir_node *transform_node_Add(ir_node *n) { DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B); return n; } - if (! get_opt_reassociation()) { + if (! get_opt_reassoc_running()) { /* do NOT execute this code if reassociation is enabled, it does the inverse! */ if (is_Mul(a)) { ir_node *ma = get_Mul_left(a); @@ -2247,7 +2247,7 @@ restart: } } /* do NOT execute this code if reassociation is enabled, it does the inverse! */ - if (get_opt_reassociation() && is_Mul(a)) { + if (get_opt_reassoc_running() && is_Mul(a)) { ir_node *ma = get_Mul_left(a); ir_node *mb = get_Mul_right(a); diff --git a/ir/opt/reassoc.c b/ir/opt/reassoc.c index 46068786e..1890716b7 100644 --- a/ir/opt/reassoc.c +++ b/ir/opt/reassoc.c @@ -761,12 +761,17 @@ void optimize_reassociation(ir_graph *irg) env.changes = 0; env.wq = new_waitq(); - /* now we have collected enough information, optimize */ - irg_walk_graph(irg, NULL, wq_walker, &env); - do_reassociation(&env); - - /* reverse those rules that do not result in collapsed constants */ - irg_walk_graph(irg, NULL, reverse_rules, &env); + /* disable some optimizations while reassoc is running to prevent endless loops */ + set_opt_reassoc_running(1); + { + /* now we have collected enough information, optimize */ + irg_walk_graph(irg, NULL, wq_walker, &env); + do_reassociation(&env); + + /* reverse those rules that do not result in collapsed constants */ + irg_walk_graph(irg, NULL, reverse_rules, &env); + } + set_opt_reassoc_running(0); /* Handle graph state */ if (env.changes) {