OSDN Git Service

* matrix-reorg.c (analyze_matrix_allocation_site): Remove unused
[pf3gnuchains/gcc-fork.git] / gcc / sese.c
index 394d465..338f482 100644 (file)
@@ -235,8 +235,73 @@ sese_build_liveouts_bb (sese region, bitmap liveouts, basic_block bb)
                               PHI_ARG_DEF_FROM_EDGE (gsi_stmt (bsi), e));
 
   for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
-    FOR_EACH_SSA_USE_OPERAND (use_p, gsi_stmt (bsi), iter, SSA_OP_ALL_USES)
-      sese_build_liveouts_use (region, liveouts, bb, USE_FROM_PTR (use_p));
+    {
+      gimple stmt = gsi_stmt (bsi);
+
+      if (is_gimple_debug (stmt))
+       continue;
+
+      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
+       sese_build_liveouts_use (region, liveouts, bb, USE_FROM_PTR (use_p));
+    }
+}
+
+/* For a USE in BB, return true if BB is outside REGION and it's not
+   in the LIVEOUTS set.  */
+
+static bool
+sese_bad_liveouts_use (sese region, bitmap liveouts, basic_block bb,
+                      tree use)
+{
+  unsigned ver;
+  basic_block def_bb;
+
+  if (TREE_CODE (use) != SSA_NAME)
+    return false;
+
+  ver = SSA_NAME_VERSION (use);
+
+  /* If it's in liveouts, the variable will get a new PHI node, and
+     the debug use will be properly adjusted.  */
+  if (bitmap_bit_p (liveouts, ver))
+    return false;
+
+  def_bb = gimple_bb (SSA_NAME_DEF_STMT (use));
+
+  if (!def_bb
+      || !bb_in_sese_p (def_bb, region)
+      || bb_in_sese_p (bb, region))
+    return false;
+
+  return true;
+}
+
+/* Reset debug stmts that reference SSA_NAMES defined in REGION that
+   are not marked as liveouts.  */
+
+static void
+sese_reset_debug_liveouts_bb (sese region, bitmap liveouts, basic_block bb)
+{
+  gimple_stmt_iterator bsi;
+  ssa_op_iter iter;
+  use_operand_p use_p;
+
+  for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+    {
+      gimple stmt = gsi_stmt (bsi);
+
+      if (!is_gimple_debug (stmt))
+       continue;
+
+      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
+       if (sese_bad_liveouts_use (region, liveouts, bb,
+                                  USE_FROM_PTR (use_p)))
+         {
+           gimple_debug_bind_reset_value (stmt);
+           update_stmt (stmt);
+           break;
+         }
+    }
 }
 
 /* Build the LIVEOUTS of REGION: the set of variables defined inside
@@ -249,6 +314,9 @@ sese_build_liveouts (sese region, bitmap liveouts)
 
   FOR_EACH_BB (bb)
     sese_build_liveouts_bb (region, liveouts, bb);
+  if (MAY_HAVE_DEBUG_INSNS)
+    FOR_EACH_BB (bb)
+      sese_reset_debug_liveouts_bb (region, liveouts, bb);
 }
 
 /* Builds a new SESE region from edges ENTRY and EXIT.  */
@@ -280,7 +348,7 @@ free_sese (sese region)
     SESE_LOOPS (region) = BITMAP_ALLOC (NULL);
 
   VEC_free (tree, heap, SESE_PARAMS (region));
-  VEC_free (loop_p, heap, SESE_LOOP_NEST (region)); 
+  VEC_free (loop_p, heap, SESE_LOOP_NEST (region));
 
   if (SESE_PARAMS_INDEX (region))
     htab_delete (SESE_PARAMS_INDEX (region));
@@ -339,8 +407,8 @@ static tree
 get_vdef_before_sese (sese region, tree name, sbitmap visited)
 {
   unsigned i;
-  gimple def_stmt = SSA_NAME_DEF_STMT (name);
-  basic_block def_bb = gimple_bb (def_stmt);
+  gimple stmt = SSA_NAME_DEF_STMT (name);
+  basic_block def_bb = gimple_bb (stmt);
 
   if (!def_bb || !bb_in_sese_p (def_bb, region))
     return name;
@@ -350,18 +418,36 @@ get_vdef_before_sese (sese region, tree name, sbitmap visited)
 
   SET_BIT (visited, def_bb->index);
 
-  switch (gimple_code (def_stmt))
+  switch (gimple_code (stmt))
     {
     case GIMPLE_PHI:
-      for (i = 0; i < gimple_phi_num_args (def_stmt); i++)
+      for (i = 0; i < gimple_phi_num_args (stmt); i++)
        {
-         tree arg = gimple_phi_arg_def (def_stmt, i);
-         tree res = get_vdef_before_sese (region, arg, visited);
+         tree arg = gimple_phi_arg_def (stmt, i);
+         tree res;
+
+         if (gimple_bb (SSA_NAME_DEF_STMT (arg))
+             && def_bb->index == gimple_bb (SSA_NAME_DEF_STMT (arg))->index)
+           continue;
+
+         res = get_vdef_before_sese (region, arg, visited);
          if (res)
            return res;
        }
       return NULL_TREE;
 
+    case GIMPLE_ASSIGN:
+    case GIMPLE_CALL:
+      {
+       use_operand_p use_p = gimple_vuse_op (stmt);
+       tree use = USE_FROM_PTR (use_p);
+
+       if (def_bb->index == gimple_bb (SSA_NAME_DEF_STMT (use))->index)
+         RESET_BIT (visited, def_bb->index);
+
+       return get_vdef_before_sese (region, use, visited);
+      }
+
     default:
       return NULL_TREE;
     }
@@ -513,7 +599,7 @@ sese_adjust_liveout_phis (sese region, htab_t rename_map, basic_block bb,
 
 /* Rename the SSA_NAMEs used in STMT and that appear in MAP.  */
 
-static void 
+static void
 rename_variables_in_stmt (gimple stmt, htab_t map, gimple_stmt_iterator *insert_gsi)
 {
   ssa_op_iter iter;
@@ -534,7 +620,19 @@ rename_variables_in_stmt (gimple stmt, htab_t map, gimple_stmt_iterator *insert_
          || (TREE_CODE (expr) != SSA_NAME
              && is_gimple_reg (use)))
        {
-         tree var = create_tmp_var (type_use, "var");
+         tree var;
+
+         if (is_gimple_debug (stmt))
+           {
+             if (gimple_debug_bind_p (stmt))
+               gimple_debug_bind_reset_value (stmt);
+             else
+               gcc_unreachable ();
+
+             break;
+           }
+
+         var = create_tmp_var (type_use, "var");
 
          if (type_use != type_expr)
            expr = fold_convert (type_use, expr);
@@ -625,16 +723,16 @@ expand_scalar_variables_call (gimple stmt, basic_block bb, sese region,
 
 static tree
 expand_scalar_variables_ssa_name (tree op0, basic_block bb,
-                                 sese region, htab_t map, 
+                                 sese region, htab_t map,
                                  gimple_stmt_iterator *gsi)
 {
   gimple def_stmt;
   tree new_op;
-      
+
   if (is_parameter (region, op0)
       || is_iv (op0))
     return get_rename (map, op0);
-      
+
   def_stmt = SSA_NAME_DEF_STMT (op0);
 
   /* Check whether we already have a rename for OP0.  */
@@ -643,7 +741,7 @@ expand_scalar_variables_ssa_name (tree op0, basic_block bb,
   if (new_op != op0
       && gimple_bb (SSA_NAME_DEF_STMT (new_op)) == bb)
     return new_op;
-      
+
   if (gimple_bb (def_stmt) == bb)
     {
       /* If the defining statement is in the basic block already
@@ -690,8 +788,8 @@ expand_scalar_variables_ssa_name (tree op0, basic_block bb,
    used to translate the names of induction variables.  */
 
 static tree
-expand_scalar_variables_expr (tree type, tree op0, enum tree_code code, 
-                             tree op1, basic_block bb, sese region, 
+expand_scalar_variables_expr (tree type, tree op0, enum tree_code code,
+                             tree op1, basic_block bb, sese region,
                              htab_t map, gimple_stmt_iterator *gsi)
 {
   if (TREE_CODE_CLASS (code) == tcc_constant
@@ -761,7 +859,7 @@ expand_scalar_variables_expr (tree type, tree op0, enum tree_code code,
       enum tree_code op0_code = TREE_CODE (op0);
       tree op0_expr = expand_scalar_variables_expr (op0_type, op0, op0_code,
                                                    NULL, bb, region, map, gsi);
-  
+
       return fold_build1 (code, type, op0_expr);
     }
 
@@ -797,7 +895,7 @@ expand_scalar_variables_expr (tree type, tree op0, enum tree_code code,
    only induction variables from the generated code: MAP contains the
    induction variables renaming mapping, and is used to translate the
    names of induction variables.  */
+
 static void
 expand_scalar_variables_stmt (gimple stmt, basic_block bb, sese region,
                              htab_t map, gimple_stmt_iterator *gsi)
@@ -827,6 +925,16 @@ expand_scalar_variables_stmt (gimple stmt, basic_block bb, sese region,
       if (use_expr == use)
        continue;
 
+      if (is_gimple_debug (stmt))
+       {
+         if (gimple_debug_bind_p (stmt))
+           gimple_debug_bind_reset_value (stmt);
+         else
+           gcc_unreachable ();
+
+         break;
+       }
+
       if (TREE_CODE (use_expr) != SSA_NAME)
        {
          tree var = create_tmp_var (type, "var");
@@ -850,11 +958,11 @@ expand_scalar_variables_stmt (gimple stmt, basic_block bb, sese region,
    induction variables renaming mapping, and is used to translate the
    names of induction variables.  */
 
-static void 
+static void
 expand_scalar_variables (basic_block bb, sese region, htab_t map)
 {
   gimple_stmt_iterator gsi;
-  
+
   for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi);)
     {
       gimple stmt = gsi_stmt (gsi);
@@ -865,12 +973,12 @@ expand_scalar_variables (basic_block bb, sese region, htab_t map)
 
 /* Rename all the SSA_NAMEs from block BB according to the MAP.  */
 
-static void 
+static void
 rename_variables (basic_block bb, htab_t map)
 {
   gimple_stmt_iterator gsi;
   gimple_stmt_iterator insert_gsi = gsi_start_bb (bb);
-  
+
   for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     rename_variables_in_stmt (gsi_stmt (gsi), map, &insert_gsi);
 }
@@ -898,7 +1006,7 @@ get_true_edge_from_guard_bb (basic_block bb)
   edge_iterator ei;
 
   FOR_EACH_EDGE (e, ei, bb->succs)
-    if (e->flags & EDGE_TRUE_VALUE) 
+    if (e->flags & EDGE_TRUE_VALUE)
       return e;
 
   gcc_unreachable ();
@@ -914,7 +1022,7 @@ get_false_edge_from_guard_bb (basic_block bb)
   edge_iterator ei;
 
   FOR_EACH_EDGE (e, ei, bb->succs)
-    if (!(e->flags & EDGE_TRUE_VALUE)) 
+    if (!(e->flags & EDGE_TRUE_VALUE))
       return e;
 
   gcc_unreachable ();
@@ -1186,7 +1294,6 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, htab_t map)
     {
       def_operand_p def_p;
       ssa_op_iter op_iter;
-      int region;
       gimple stmt = gsi_stmt (gsi);
       gimple copy;
 
@@ -1199,9 +1306,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, htab_t map)
       gsi_insert_after (&gsi_tgt, copy, GSI_NEW_STMT);
       mark_sym_for_renaming (gimple_vop (cfun));
 
-      region = lookup_stmt_eh_region (stmt);
-      if (region >= 0)
-       add_stmt_to_eh_region (copy, region);
+      maybe_duplicate_eh_stmt (copy, stmt);
       gimple_duplicate_stmt_histograms (cfun, copy, cfun, stmt);
 
       /* Create new names for all the definitions created by COPY and
@@ -1218,7 +1323,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, htab_t map)
 /* Copies BB and includes in the copied BB all the statements that can
    be reached following the use-def chains from the memory accesses,
    and returns the next edge following this new block.  */
+
 edge
 copy_bb_and_scalar_dependences (basic_block bb, sese region,
                                edge next_e, htab_t map)
@@ -1279,6 +1384,9 @@ if_region_set_false_region (ifsese if_region, sese region)
   recompute_all_dominators ();
 
   SESE_EXIT (region) = false_edge;
+
+  if (if_region->false_region)
+    free (if_region->false_region);
   if_region->false_region = region;
 
   if (slot)
@@ -1304,10 +1412,10 @@ create_if_region_on_edge (edge entry, tree condition)
 {
   edge e;
   edge_iterator ei;
-  sese sese_region = GGC_NEW (struct sese_s);
-  sese true_region = GGC_NEW (struct sese_s);
-  sese false_region = GGC_NEW (struct sese_s);
-  ifsese if_region = GGC_NEW (struct ifsese_s);
+  sese sese_region = XNEW (struct sese_s);
+  sese true_region = XNEW (struct sese_s);
+  sese false_region = XNEW (struct sese_s);
+  ifsese if_region = XNEW (struct ifsese_s);
   edge exit = create_empty_if_region_on_edge (entry, condition);
 
   if_region->region = sese_region;
@@ -1344,7 +1452,7 @@ ifsese
 move_sese_in_condition (sese region)
 {
   basic_block pred_block = split_edge (SESE_ENTRY (region));
-  ifsese if_region = NULL;
+  ifsese if_region;
 
   SESE_ENTRY (region) = single_succ_edge (pred_block);
   if_region = create_if_region_on_edge (single_pred_edge (pred_block), integer_one_node);
@@ -1353,18 +1461,6 @@ move_sese_in_condition (sese region)
   return if_region;
 }
 
-/* Reset the loop->aux pointer for all loops in REGION.  */
-
-void
-sese_reset_aux_in_loops (sese region)
-{
-  int i;
-  loop_p loop;
-
-  for (i = 0; VEC_iterate (loop_p, SESE_LOOP_NEST (region), i, loop); i++)
-    loop->aux = NULL;
-}
-
 /* Returns the scalar evolution of T in REGION.  Every variable that
    is not defined in the REGION is considered a parameter.  */