]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/store-motion.c
remove need for store_values_directly
[thirdparty/gcc.git] / gcc / store-motion.c
index fdbc6b3631c4c2504a530c573d069774cd5cd1e5..d621ec11b147c60cf0143d3049034cd602ced81e 100644 (file)
@@ -1,5 +1,5 @@
 /* Store motion via Lazy Code Motion on the reverse CFG.
-   Copyright (C) 1997-2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -25,6 +25,15 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 
 #include "rtl.h"
+#include "hash-set.h"
+#include "machmode.h"
+#include "vec.h"
+#include "double-int.h"
+#include "input.h"
+#include "alias.h"
+#include "symtab.h"
+#include "wide-int.h"
+#include "inchash.h"
 #include "tree.h"
 #include "tm_p.h"
 #include "regs.h"
@@ -32,8 +41,26 @@ along with GCC; see the file COPYING3.  If not see
 #include "flags.h"
 #include "insn-config.h"
 #include "recog.h"
-#include "basic-block.h"
+#include "predict.h"
 #include "function.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfgrtl.h"
+#include "cfganal.h"
+#include "lcm.h"
+#include "cfgcleanup.h"
+#include "basic-block.h"
+#include "hashtab.h"
+#include "statistics.h"
+#include "real.h"
+#include "fixed-value.h"
+#include "expmed.h"
+#include "dojump.h"
+#include "explow.h"
+#include "calls.h"
+#include "emit-rtl.h"
+#include "varasm.h"
+#include "stmt.h"
 #include "expr.h"
 #include "except.h"
 #include "ggc.h"
@@ -42,6 +69,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "hash-table.h"
 #include "df.h"
 #include "dbgcnt.h"
+#include "rtl-iter.h"
 
 /* This pass implements downward store motion.
    As of May 1, 2009, the pass is not enabled by default on any target,
@@ -109,21 +137,21 @@ static struct edge_list *edge_list;
 
 struct st_expr_hasher : typed_noop_remove <st_expr>
 {
-  typedef st_expr value_type;
-  typedef st_expr compare_type;
-  static inline hashval_t hash (const value_type *);
-  static inline bool equal (const value_type *, const compare_type *);
+  typedef st_expr *value_type;
+  typedef st_expr *compare_type;
+  static inline hashval_t hash (const st_expr *);
+  static inline bool equal (const st_expr *, const st_expr *);
 };
 
 inline hashval_t
-st_expr_hasher::hash (const value_type *x)
+st_expr_hasher::hash (const st_expr *x)
 {
   int do_not_record_p = 0;
   return hash_rtx (x->pattern, GET_MODE (x->pattern), &do_not_record_p, NULL, false);
 }
 
 inline bool
-st_expr_hasher::equal (const value_type *ptr1, const compare_type *ptr2)
+st_expr_hasher::equal (const st_expr *ptr1, const st_expr *ptr2)
 {
   return exp_equiv_p (ptr1->pattern, ptr2->pattern, 0, true);
 }
@@ -278,19 +306,6 @@ store_ops_ok (const_rtx x, int *regs_set)
   return true;
 }
 
-/* Helper for extract_mentioned_regs.  */
-
-static int
-extract_mentioned_regs_1 (rtx *loc, void *data)
-{
-  rtx *mentioned_regs_p = (rtx *) data;
-
-  if (REG_P (*loc))
-    *mentioned_regs_p = alloc_EXPR_LIST (0, *loc, *mentioned_regs_p);
-
-  return 0;
-}
-
 /* Returns a list of registers mentioned in X.
    FIXME: A regset would be prettier and less expensive.  */
 
@@ -298,7 +313,13 @@ static rtx
 extract_mentioned_regs (rtx x)
 {
   rtx mentioned_regs = NULL;
-  for_each_rtx (&x, extract_mentioned_regs_1, &mentioned_regs);
+  subrtx_var_iterator::array_type array;
+  FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
+    {
+      rtx x = *iter;
+      if (REG_P (x))
+       mentioned_regs = alloc_EXPR_LIST (0, x, mentioned_regs);
+    }
   return mentioned_regs;
 }
 
@@ -926,7 +947,8 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr)
 /* This routine will replace a store with a SET to a specified register.  */
 
 static void
-replace_store_insn (rtx reg, rtx del, basic_block bb, struct st_expr *smexpr)
+replace_store_insn (rtx reg, rtx_insn *del, basic_block bb,
+                   struct st_expr *smexpr)
 {
   rtx_insn *insn;
   rtx mem, note, set, ptr;
@@ -990,16 +1012,16 @@ replace_store_insn (rtx reg, rtx del, basic_block bb, struct st_expr *smexpr)
 static void
 delete_store (struct st_expr * expr, basic_block bb)
 {
-  rtx reg, i, del;
+  rtx reg;
 
   if (expr->reaching_reg == NULL_RTX)
     expr->reaching_reg = gen_reg_rtx_and_attrs (expr->pattern);
 
   reg = expr->reaching_reg;
 
-  for (i = expr->avail_stores; i; i = XEXP (i, 1))
+  for (rtx_insn_list *i = expr->avail_stores; i; i = i->next ())
     {
-      del = XEXP (i, 0);
+      rtx_insn *del = i->insn ();
       if (BLOCK_FOR_INSN (del) == bb)
        {
          /* We know there is only one since we deleted redundant
@@ -1017,7 +1039,8 @@ build_store_vectors (void)
 {
   basic_block bb;
   int *regs_set_in_block;
-  rtx insn, st;
+  rtx_insn *insn;
+  rtx_insn_list *st;
   struct st_expr * ptr;
   unsigned int max_gcse_regno = max_reg_num ();
 
@@ -1033,9 +1056,9 @@ build_store_vectors (void)
 
   for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
     {
-      for (st = ptr->avail_stores; st != NULL; st = XEXP (st, 1))
+      for (st = ptr->avail_stores; st != NULL; st = st->next ())
        {
-         insn = XEXP (st, 0);
+         insn = st->insn ();
          bb = BLOCK_FOR_INSN (insn);
 
          /* If we've already seen an available expression in this block,
@@ -1047,15 +1070,15 @@ build_store_vectors (void)
              rtx r = gen_reg_rtx_and_attrs (ptr->pattern);
              if (dump_file)
                fprintf (dump_file, "Removing redundant store:\n");
-             replace_store_insn (r, XEXP (st, 0), bb, ptr);
+             replace_store_insn (r, st->insn (), bb, ptr);
              continue;
            }
          bitmap_set_bit (st_avloc[bb->index], ptr->index);
        }
 
-      for (st = ptr->antic_stores; st != NULL; st = XEXP (st, 1))
+      for (st = ptr->antic_stores; st != NULL; st = st->next ())
        {
-         insn = XEXP (st, 0);
+         insn = st->insn ();
          bb = BLOCK_FOR_INSN (insn);
          bitmap_set_bit (st_antloc[bb->index], ptr->index);
        }