OSDN Git Service

In gcc/objc/:
[pf3gnuchains/gcc-fork.git] / gcc / sese.c
index 583504d..3bf6bea 100644 (file)
@@ -31,7 +31,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "tree-pretty-print.h"
 #include "tree-flow.h"
-#include "toplev.h"
 #include "tree-dump.h"
 #include "timevar.h"
 #include "cfgloop.h"
@@ -181,7 +180,7 @@ build_sese_loop_nests (sese region)
   /* Make sure that the loops in the SESE_LOOP_NEST are ordered.  It
      can be the case that an inner loop is inserted before an outer
      loop.  To avoid this, semi-sort once.  */
-  for (i = 0; VEC_iterate (loop_p, SESE_LOOP_NEST (region), i, loop0); i++)
+  FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop0)
     {
       if (VEC_length (loop_p, SESE_LOOP_NEST (region)) == i + 1)
        break;
@@ -471,14 +470,25 @@ set_rename (htab_t rename_map, tree old_name, tree expr)
    substitution map RENAME_MAP, inserting the gimplification code at
    GSI_TGT, for the translation REGION, with the original copied
    statement in LOOP, and using the induction variable renaming map
-   IV_MAP.  */
+   IV_MAP.  Returns true when something has been renamed.  */
 
-static void
+static bool
 rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
             sese region, loop_p loop, VEC (tree, heap) *iv_map)
 {
   use_operand_p use_p;
   ssa_op_iter op_iter;
+  bool changed = false;
+
+  if (is_gimple_debug (copy))
+    {
+      if (gimple_debug_bind_p (copy))
+       gimple_debug_bind_reset_value (copy);
+      else
+       gcc_unreachable ();
+
+      return false;
+    }
 
   FOR_EACH_SSA_USE_OPERAND (use_p, copy, op_iter, SSA_OP_ALL_USES)
     {
@@ -491,6 +501,7 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
          || SSA_NAME_IS_DEFAULT_DEF (old_name))
        continue;
 
+      changed = true;
       new_expr = get_rename (rename_map, old_name);
       if (new_expr)
        {
@@ -501,19 +512,7 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
              || (TREE_CODE (new_expr) != SSA_NAME
                  && is_gimple_reg (old_name)))
            {
-             tree var;
-
-             if (is_gimple_debug (copy))
-               {
-                 if (gimple_debug_bind_p (copy))
-                   gimple_debug_bind_reset_value (copy);
-                 else
-                   gcc_unreachable ();
-
-                 break;
-               }
-
-             var = create_tmp_var (type_old_name, "var");
+             tree var = create_tmp_var (type_old_name, "var");
 
              if (type_old_name != type_new_expr)
                new_expr = fold_convert (type_old_name, new_expr);
@@ -545,11 +544,24 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
                  && !tree_contains_chrecs (new_expr, NULL));
 
       /* Replace the old_name with the new_expr.  */
-      new_expr = force_gimple_operand (new_expr, &stmts, true, NULL);
+      new_expr = force_gimple_operand (unshare_expr (new_expr), &stmts,
+                                      true, NULL_TREE);
       gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
       replace_exp (use_p, new_expr);
+
+      if (TREE_CODE (new_expr) == INTEGER_CST
+         && is_gimple_assign (copy))
+       {
+         tree rhs = gimple_assign_rhs1 (copy);
+
+         if (TREE_CODE (rhs) == ADDR_EXPR)
+           recompute_tree_invariant_for_addr_expr (rhs);
+       }
+
       set_rename (rename_map, old_name, new_expr);
     }
+
+  return changed;
 }
 
 /* Duplicates the statements of basic block BB into basic block NEW_BB
@@ -603,7 +615,8 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
          set_rename (rename_map, old_name, new_name);
        }
 
-      rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map);
+      if (rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map))
+       fold_stmt_inplace (copy);
 
       update_stmt (copy);
     }