Add a reassoc_running flag used to disable some local optimizations only while reasso...
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 20 Sep 2007 09:02:45 +0000 (09:02 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 20 Sep 2007 09:02:45 +0000 (09:02 +0000)
[r15895]

ir/ir/irflag_t.def
ir/ir/iropt.c
ir/opt/reassoc.c

index 80d06db..c64bb3b 100644 (file)
@@ -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)
index b0ba8c8..a16a2b0 100644 (file)
@@ -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);
 
index 4606878..1890716 100644 (file)
@@ -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) {