OSDN Git Service

2009-04-21 Taras Glek <tglek@mozilla.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-scalar-evolution.c
index 8e12c2b..2d31f9f 100644 (file)
@@ -282,8 +282,7 @@ static tree analyze_scalar_evolution_1 (struct loop *, tree, tree);
    basic block INSTANTIATED_BELOW, the value of VAR can be expressed
    as CHREC.  */
 
-struct scev_info_str GTY(())
-{
+struct GTY(()) scev_info_str {
   basic_block instantiated_below;
   tree var;
   tree chrec;
@@ -1577,6 +1576,20 @@ analyze_initial_condition (gimple loop_phi_node)
   if (init_cond == chrec_not_analyzed_yet)
     init_cond = chrec_dont_know;
 
+  /* During early loop unrolling we do not have fully constant propagated IL.
+     Handle degenerate PHIs here to not miss important unrollings.  */
+  if (TREE_CODE (init_cond) == SSA_NAME)
+    {
+      gimple def = SSA_NAME_DEF_STMT (init_cond);
+      tree res;
+      if (gimple_code (def) == GIMPLE_PHI
+         && (res = degenerate_phi_result (def)) != NULL_TREE
+         /* Only allow invariants here, otherwise we may break
+            loop-closed SSA form.  */
+         && is_gimple_min_invariant (res))
+       init_cond = res;
+    }
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "  (init_cond = ");