BugFix: when we create a new Conv node in combo's exchange_leader(), this irn has...
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 3 Feb 2011 21:50:54 +0000 (21:50 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 3 Feb 2011 21:50:54 +0000 (21:50 +0000)
When we create a new Conv node in combo's exchange_leader(), this irn has no node_t.
This is ok, replace the original node in a post walker.
However, as the new node has a visited count of 0 it might be revisited
again.
Fix this by copying the visited count.

This fixes testsuite/opt/fehler179.c

[r28291]

ir/opt/combo.c

index 54a13d2..815822b 100644 (file)
@@ -3255,8 +3255,20 @@ static void exchange_leader(ir_node *irn, ir_node *leader)
                 * the number of Conv due to CSE. */
                ir_node  *block = get_nodes_block(leader);
                dbg_info *dbg   = get_irn_dbg_info(irn);
-
-               leader = new_rd_Conv(dbg, block, leader, mode);
+               ir_node  *nlead = new_rd_Conv(dbg, block, leader, mode);
+
+               if (nlead != leader) {
+                       /* Note: this newly create irn has no node info because
+                        * it is created after the analysis. However, this node
+                        * replaces the node irn and should not be visited again,
+                        * so set its visited count to the count of irn.
+                        * Otherwise we might visited this node more than once if
+                        * irn had more than one user.
+                        */
+                       set_irn_node(nlead, NULL);
+                       set_irn_visited(nlead, get_irn_visited(irn));
+                       leader = nlead;
+               }
        }
        exchange(irn, leader);
 }  /* exchange_leader */