OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / tree-if-conv.c
index 289da6e..ec34929 100644 (file)
@@ -189,8 +189,14 @@ tree_if_conversion (struct loop *loop, bool for_vectorizer)
       if (single_succ_p (bb))
        {
          basic_block bb_n = single_succ (bb);
-         if (cond != NULL_TREE)
-           add_to_predicate_list (bb_n, cond);
+
+         /* Successor bb inherits predicate of its predecessor. If there
+            is no predicate in predecessor bb, then consider successor bb
+            as always executed.  */
+         if (cond == NULL_TREE)
+           cond = boolean_true_node;
+
+         add_to_predicate_list (bb_n, cond);
        }
     }
 
@@ -296,7 +302,8 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond,
    and it belongs to basic block BB.
    PHI is not if-convertible
    - if it has more than 2 arguments.
-   - Virtual PHI is immediately used in another PHI node.  */
+   - Virtual PHI is immediately used in another PHI node.
+   - Virtual PHI on BB other than header.  */
 
 static bool
 if_convertible_phi_p (struct loop *loop, basic_block bb, tree phi)
@@ -318,6 +325,13 @@ if_convertible_phi_p (struct loop *loop, basic_block bb, tree phi)
     {
       imm_use_iterator imm_iter;
       use_operand_p use_p;
+
+      if (bb != loop->header)
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           fprintf (dump_file, "Virtual phi not on loop header.\n");
+         return false;
+       }
       FOR_EACH_IMM_USE_FAST (use_p, imm_iter, PHI_RESULT (phi))
        {
          if (TREE_CODE (USE_STMT (use_p)) == PHI_NODE)
@@ -724,6 +738,8 @@ find_phi_replacement_condition (struct loop *loop,
 
   /* Select condition that is not TRUTH_NOT_EXPR.  */
   tmp_cond = (first_edge->src)->aux;
+  gcc_assert (tmp_cond);
+
   if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
     {
       edge tmp_edge;
@@ -865,7 +881,7 @@ process_phi_nodes (struct loop *loop)
   /* Replace phi nodes with cond. modify expr.  */
   for (i = 1; i < orig_loop_num_nodes; i++)
     {
-      tree phi, cond;
+      tree phi, cond = NULL_TREE;
       block_stmt_iterator bsi;
       basic_block true_bb = NULL;
       bb = ifc_bbs[i];
@@ -985,7 +1001,7 @@ combine_blocks (struct loop *loop)
       /* Update stmt list.  */
       last = tsi_last (bb_stmt_list (merge_target_bb));
       tsi_link_after (&last, bb_stmt_list (bb), TSI_NEW_STMT);
-      set_bb_stmt_list (bb, NULL);
+      set_bb_stmt_list (bb, alloc_stmt_list());
 
       delete_basic_block (bb);
     }