OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / dse.c
index ddabd3d..7d4dbf4 100644 (file)
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -895,7 +895,12 @@ emit_inc_dec_insn_before (rtx mem ATTRIBUTE_UNUSED,
   /* We can reuse all operands without copying, because we are about
      to delete the insn that contained it.  */
   if (srcoff)
-    new_insn = gen_add3_insn (dest, src, srcoff);
+    {
+      start_sequence ();
+      emit_insn (gen_add3_insn (dest, src, srcoff));
+      new_insn = get_insns ();
+      end_sequence ();
+    }
   else
     new_insn = gen_move_insn (dest, src);
   info.first = new_insn;
@@ -991,7 +996,32 @@ delete_dead_store_insn (insn_info_t insn_info)
   insn_info->wild_read = false;
 }
 
-/* Check if EXPR can possibly escape the current function scope.  */
+/* Return whether DECL, a local variable, can possibly escape the current
+   function scope.  */
+
+static bool
+local_variable_can_escape (tree decl)
+{
+  if (TREE_ADDRESSABLE (decl))
+    return true;
+
+  /* If this is a partitioned variable, we need to consider all the variables
+     in the partition.  This is necessary because a store into one of them can
+     be replaced with a store into another and this may not change the outcome
+     of the escape analysis.  */
+  if (cfun->gimple_df->decls_to_pointers != NULL)
+    {
+      void *namep
+       = pointer_map_contains (cfun->gimple_df->decls_to_pointers, decl);
+      if (namep)
+       return TREE_ADDRESSABLE (*(tree *)namep);
+    }
+
+  return false;
+}
+
+/* Return whether EXPR can possibly escape the current function scope.  */
+
 static bool
 can_escape (tree expr)
 {
@@ -1000,7 +1030,11 @@ can_escape (tree expr)
     return true;
   base = get_base_address (expr);
   if (DECL_P (base)
-      && !may_be_aliased (base))
+      && !may_be_aliased (base)
+      && !(TREE_CODE (base) == VAR_DECL
+          && !DECL_EXTERNAL (base)
+          && !TREE_STATIC (base)
+          && local_variable_can_escape (base)))
     return false;
   return true;
 }
@@ -1677,7 +1711,7 @@ record_store (rtx body, bb_info_t bb_info)
          if (canon_true_dependence (s_info->mem,
                                     GET_MODE (s_info->mem),
                                     s_info->mem_addr,
-                                    mem, mem_addr, rtx_varies_p))
+                                    mem, mem_addr))
            {
              s_info->rhs = NULL;
              s_info->const_rhs = NULL;
@@ -1945,7 +1979,7 @@ get_stored_val (store_info_t store_info, enum machine_mode read_mode,
              c |= (c << shift);
              shift <<= 1;
            }
-         read_reg = GEN_INT (trunc_int_for_mode (c, store_mode));
+         read_reg = gen_int_mode (c, store_mode);
          read_reg = extract_low_bits (read_mode, store_mode, read_reg);
        }
     }
@@ -2274,7 +2308,7 @@ check_mem_read_rtx (rtx *loc, void *data)
              = canon_true_dependence (store_info->mem,
                                       GET_MODE (store_info->mem),
                                       store_info->mem_addr,
-                                      mem, mem_addr, rtx_varies_p);
+                                      mem, mem_addr);
 
          else if (group_id == store_info->group_id)
            {
@@ -2285,7 +2319,7 @@ check_mem_read_rtx (rtx *loc, void *data)
                  = canon_true_dependence (store_info->mem,
                                           GET_MODE (store_info->mem),
                                           store_info->mem_addr,
-                                          mem, mem_addr, rtx_varies_p);
+                                          mem, mem_addr);
 
              /* If this read is just reading back something that we just
                 stored, rewrite the read.  */
@@ -2372,7 +2406,7 @@ check_mem_read_rtx (rtx *loc, void *data)
            remove = canon_true_dependence (store_info->mem,
                                            GET_MODE (store_info->mem),
                                            store_info->mem_addr,
-                                           mem, mem_addr, rtx_varies_p);
+                                           mem, mem_addr);
 
          if (remove)
            {
@@ -2454,7 +2488,7 @@ get_call_args (rtx call_insn, tree fn, rtx *args, int nargs)
        {
          if (!tmp || !CONST_INT_P (tmp))
            return false;
-         tmp = GEN_INT (trunc_int_for_mode (INTVAL (tmp), mode));
+         tmp = gen_int_mode (INTVAL (tmp), mode);
        }
       if (tmp)
        args[idx] = tmp;
@@ -3271,8 +3305,7 @@ scan_reads_nospill (insn_info_t insn_info, bitmap gen, bitmap kill)
                      && canon_true_dependence (group->base_mem,
                                                GET_MODE (group->base_mem),
                                                group->canon_base_addr,
-                                               read_info->mem, NULL_RTX,
-                                               rtx_varies_p))
+                                               read_info->mem, NULL_RTX))
                    {
                      if (kill)
                        bitmap_ior_into (kill, group->group_kill);