make avail_stores a vec<rtx_insn *>
authorTrevor Saunders <tbsaunde+gcc@tbsaunde.org>
Sun, 24 Apr 2016 08:45:38 +0000 (08:45 +0000)
committerTrevor Saunders <tbsaunde@gcc.gnu.org>
Sun, 24 Apr 2016 08:45:38 +0000 (08:45 +0000)
gcc/ChangeLog:

2016-04-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

* print-rtl.c (print_rtx_insn_vec): New function.
* print-rtl.h: New prototype.
* store-motion.c (struct st_expr): Make avail_stores a vector.
(st_expr_entry): Adjust.
(free_st_expr_entry): Likewise.
(print_store_motion_mems): Likewise.
(find_moveable_store): Likewise.
(compute_store_table): Likewise.
(delete_store): Likewise.
(build_store_vectors): Likewise.

From-SVN: r235394

gcc/ChangeLog
gcc/print-rtl.c
gcc/print-rtl.h
gcc/store-motion.c

index 8cfccea95ef0332dbaccc2490af906f8e7a18cb1..7b4b9c2f157f5e70131bfad3818fd9257f7cd493 100644 (file)
@@ -1,3 +1,16 @@
+2016-04-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
+
+       * print-rtl.c (print_rtx_insn_vec): New function.
+       * print-rtl.h: New prototype.
+       * store-motion.c (struct st_expr): Make avail_stores a vector.
+       (st_expr_entry): Adjust.
+       (free_st_expr_entry): Likewise.
+       (print_store_motion_mems): Likewise.
+       (find_moveable_store): Likewise.
+       (compute_store_table): Likewise.
+       (delete_store): Likewise.
+       (build_store_vectors): Likewise.
+
 2016-04-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
 
        * reorg.c (try_merge_delay_insns): Make merged_insns a vector.
index 85d9b8d5731507a8c7b20b6302ad505002a57442..a9051279ed7e1bea1fab385d47e2b3bb9ddaa912 100644 (file)
@@ -870,6 +870,24 @@ print_simple_rtl (FILE *outf, const_rtx x)
   flag_simple = 0;
 }
 
+/* Print the elements of VEC to FILE.  */
+
+void
+print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec)
+{
+  fputc('{', file);
+
+  unsigned int len = vec.length ();
+  for (unsigned int i = 0; i < len; i++)
+    {
+      print_rtl (file, vec[i]);
+      if (i < len - 1)
+       fputs (", ", file);
+    }
+
+  fputc ('}', file);
+}
+
 #ifndef GENERATOR_FILE
 /* The functions below  try to print RTL in a form resembling assembler
    mnemonics.  Because this form is more concise than the "traditional" form
index 28b4626c0dcc6782639e743c4387c1941cd05560..e585a639602d1e7ce3729823d06c40210e72695a 100644 (file)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifdef BUFSIZ
 extern void print_rtl (FILE *, const_rtx);
 #endif
+extern void print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec);
 
 extern void dump_value_slim (FILE *, const_rtx, int);
 extern void dump_insn_slim (FILE *, const rtx_insn *);
index fffdffc3c346dc80693148f0250fe4dd77fe06ea..301b69be86d91ee3d85f64fa4d14af8d227d5f30 100644 (file)
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "dbgcnt.h"
 #include "rtl-iter.h"
+#include "print-rtl.h"
 
 /* This pass implements downward store motion.
    As of May 1, 2009, the pass is not enabled by default on any target,
@@ -67,7 +68,7 @@ struct st_expr
   /* INSN list of stores that are locally anticipatable.  */
   rtx_insn_list *antic_stores;
   /* INSN list of stores that are locally available.  */
-  rtx_insn_list *avail_stores;
+  vec<rtx_insn *> avail_stores;
   /* Next in the list.  */
   struct st_expr * next;
   /* Store ID in the dataflow bitmaps.  */
@@ -148,7 +149,7 @@ st_expr_entry (rtx x)
   ptr->pattern      = x;
   ptr->pattern_regs = NULL_RTX;
   ptr->antic_stores = NULL;
-  ptr->avail_stores = NULL;
+  ptr->avail_stores.create (0);
   ptr->reaching_reg = NULL_RTX;
   ptr->index        = 0;
   ptr->hash_index   = hash;
@@ -164,7 +165,7 @@ static void
 free_st_expr_entry (struct st_expr * ptr)
 {
   free_INSN_LIST_list (& ptr->antic_stores);
-  free_INSN_LIST_list (& ptr->avail_stores);
+   ptr->avail_stores.release ();
 
   free (ptr);
 }
@@ -240,10 +241,7 @@ print_store_motion_mems (FILE * file)
 
       fprintf (file, "\n        AVAIL stores : ");
 
-      if (ptr->avail_stores)
-       print_rtl (file, ptr->avail_stores);
-      else
-       fprintf (file, "(nil)");
+       print_rtx_insn_vec (file, ptr->avail_stores);
 
       fprintf (file, "\n\n");
     }
@@ -591,11 +589,11 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
      it successfully before; if we failed before, do not bother to check
      until we reach the insn that caused us to fail.  */
   check_available = 0;
-  if (!ptr->avail_stores)
+  if (ptr->avail_stores.is_empty ())
     check_available = 1;
   else
     {
-      rtx_insn *tmp = ptr->avail_stores->insn ();
+      rtx_insn *tmp = ptr->avail_stores.last ();
       if (BLOCK_FOR_INSN (tmp) != bb)
        check_available = 1;
     }
@@ -619,7 +617,7 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
                                              &LAST_AVAIL_CHECK_FAILURE (ptr));
     }
   if (!check_available)
-    ptr->avail_stores = alloc_INSN_LIST (insn, ptr->avail_stores);
+    ptr->avail_stores.safe_push (insn);
 }
 
 /* Find available and anticipatable stores.  */
@@ -697,7 +695,7 @@ compute_store_table (void)
        ptr != NULL;
        ptr = *prev_next_ptr_ptr)
     {
-      if (! ptr->avail_stores)
+      if (ptr->avail_stores.is_empty ())
        {
          *prev_next_ptr_ptr = ptr->next;
          store_motion_mems_table->remove_elt_with_hash (ptr, ptr->hash_index);
@@ -981,9 +979,10 @@ delete_store (struct st_expr * expr, basic_block bb)
 
   reg = expr->reaching_reg;
 
-  for (rtx_insn_list *i = expr->avail_stores; i; i = i->next ())
+  unsigned int len = expr->avail_stores.length ();
+  for (unsigned int i = len - 1; i < len; i--)
     {
-      rtx_insn *del = i->insn ();
+      rtx_insn *del = expr->avail_stores[i];
       if (BLOCK_FOR_INSN (del) == bb)
        {
          /* We know there is only one since we deleted redundant
@@ -1018,9 +1017,10 @@ build_store_vectors (void)
 
   for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
     {
-      for (st = ptr->avail_stores; st != NULL; st = st->next ())
+      unsigned int len = ptr->avail_stores.length ();
+      for (unsigned int i = len - 1; i < len; i--)
        {
-         insn = st->insn ();
+         insn = ptr->avail_stores[i];
          bb = BLOCK_FOR_INSN (insn);
 
          /* If we've already seen an available expression in this block,
@@ -1032,7 +1032,7 @@ 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, st->insn (), bb, ptr);
+             replace_store_insn (r, insn, bb, ptr);
              continue;
            }
          bitmap_set_bit (st_avloc[bb->index], ptr->index);