http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47737

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-18 
11:41:40 UTC ---
The code tries to use existing dominance information to answer the edge
dominance question but indeed gets it wrong by using the dest/src blocks
of the edges without verifying that doing so will not affect the dominance
check.

I am testing a fix along

Index: tree-ssa-loop-im.c
===================================================================
--- tree-ssa-loop-im.c  (revision 170249)
+++ tree-ssa-loop-im.c  (working copy)
@@ -676,31 +676,38 @@ extract_true_false_args_from_phi (basic_
      by the true edge of the predicate block and the other edge
      dominated by the false edge.  This ensures that the PHI argument
      we are going to take is completely determined by the path we
-     take from the predicate block.  */
+     take from the predicate block.
+     We can only use BB dominance checks below if the destination of
+     the true/false edges are dominated by their edge, thus only
+     have a single predecessor.  */
   extract_true_false_edges_from_block (dom, &true_edge, &false_edge);
   tem = EDGE_PRED (bb, 0);
   if (tem == true_edge
-      || tem->src == true_edge->dest
-      || dominated_by_p (CDI_DOMINATORS,
-                        tem->src, true_edge->dest))
+      || (single_pred_p (true_edge->dest)
+         && (tem->src == true_edge->dest
+             || dominated_by_p (CDI_DOMINATORS,
+                                tem->src, true_edge->dest))))
     arg0 = PHI_ARG_DEF (phi, tem->dest_idx);

...

Reply via email to