public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list
@ 2016-04-20  6:17 tbsaunde+gcc
  2016-04-20  6:17 ` [PATCH 01/18] stop using rtx_insn_list in reorg.c tbsaunde+gcc
                   ` (18 more replies)
  0 siblings, 19 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:17 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Hi,

I have some more patches that almost completely eliminate these, but I haven't
tested the rest yet, and this is already a long series so it would be nice to
get some of it out of my tree and reviewed.

patches individually bootstrapped and regtested on x86_64-linux-gnu, ok? I
expect none of this will more than textually conflict with something that may
need backported to gcc-6, but its waited a month already I guess it can wait
longer if people prefer.

Trev


Trevor Saunders (18):
  stop using rtx_insn_list in reorg.c
  make avail_stores a vec<rtx_insn *>
  make antic_stores a vec<rtx_insn *>
  remove unused loads rtx_insn_list
  make stores rtx_insn_list a vec
  move reg_equivs out of gc memory
  loop-iv.c: make cond_list a vec
  make side_effects a vec<rtx>
  make pattern_regs a vec
  merge adjust_cost and adjust_cost_2 target hooks
  add some utility methods to vec
  haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  haifa-sched.c: make twins a auto_vec<rtx_insn *>
  haifa-sched.c: make ready_list an auto_vec<rtx_insn *>
  make nonlocal_goto_handler_labels a vec
  make forced labels a vec
  make pending_{read,write}_insns vec<rtx_insn *>
  make last_pending_memory_flush a vec

 gcc/builtins.c                     |   4 +-
 gcc/cfgbuild.c                     |  17 ++-
 gcc/cfgrtl.c                       |  24 ++--
 gcc/config/alpha/alpha.c           |   5 +-
 gcc/config/arm/arm-protos.h        |   2 +-
 gcc/config/arm/arm.c               |  40 +++---
 gcc/config/bfin/bfin.c             |   5 +-
 gcc/config/c6x/c6x.c               |   5 +-
 gcc/config/epiphany/epiphany.c     |   5 +-
 gcc/config/i386/i386.c             |   5 +-
 gcc/config/ia64/ia64.c             |  10 +-
 gcc/config/m68k/m68k.c             |   7 +-
 gcc/config/mep/mep.c               |   9 +-
 gcc/config/microblaze/microblaze.c |  10 +-
 gcc/config/mips/mips.c             |   8 +-
 gcc/config/mn10300/mn10300.c       |   5 +-
 gcc/config/pa/pa.c                 |   9 +-
 gcc/config/rs6000/rs6000.c         |  16 ++-
 gcc/config/sh/sh.c                 |  14 +-
 gcc/config/sparc/sparc.c           |  23 ++--
 gcc/config/spu/spu.c               |   5 +-
 gcc/config/tilegx/tilegx.c         |   6 +-
 gcc/config/tilepro/tilepro.c       |   6 +-
 gcc/config/visium/visium.c         |  11 +-
 gcc/doc/tm.texi                    |  14 +-
 gcc/dwarf2cfi.c                    |  16 ++-
 gcc/emit-rtl.h                     |   2 +-
 gcc/except.c                       |   3 +-
 gcc/function.h                     |   2 +-
 gcc/gcse.c                         |  35 ++---
 gcc/haifa-sched.c                  | 266 ++++++++++++++++---------------------
 gcc/ira-emit.c                     |   4 +-
 gcc/ira.c                          |  11 +-
 gcc/jump.c                         |  12 +-
 gcc/loop-iv.c                      |  55 +++-----
 gcc/print-rtl.c                    |  15 +++
 gcc/print-rtl.h                    |   1 +
 gcc/recog.c                        |   2 +-
 gcc/reload.c                       |   4 +-
 gcc/reload.h                       |  19 ++-
 gcc/reload1.c                      |  48 +++----
 gcc/reorg.c                        |  23 ++--
 gcc/rtl.h                          |   1 +
 gcc/sched-deps.c                   | 195 ++++++++++++++++-----------
 gcc/sched-int.h                    |   8 +-
 gcc/sched-rgn.c                    |  59 ++++----
 gcc/stmt.c                         |   8 +-
 gcc/store-motion.c                 | 128 +++++++++---------
 gcc/target.def                     |  25 ++--
 gcc/var-tracking.c                 |  30 ++---
 gcc/vec.h                          |  39 +++++-
 51 files changed, 633 insertions(+), 643 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 01/18] stop using rtx_insn_list in reorg.c
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
@ 2016-04-20  6:17 ` tbsaunde+gcc
  2016-04-22  5:03   ` Jeff Law
  2016-04-25  9:35   ` Bernd Schmidt
  2016-04-20  6:18 ` [PATCH 04/18] remove unused loads rtx_insn_list tbsaunde+gcc
                   ` (17 subsequent siblings)
  18 siblings, 2 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:17 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* reorg.c (try_merge_delay_insns): Make merged_insns a vector.
---
 gcc/reorg.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/gcc/reorg.c b/gcc/reorg.c
index 7b28821..8fb912a 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -1259,7 +1259,7 @@ try_merge_delay_insns (rtx_insn *insn, rtx_insn *thread)
   int num_slots = XVECLEN (PATTERN (insn), 0);
   rtx next_to_match = XVECEXP (PATTERN (insn), 0, slot_number);
   struct resources set, needed, modified;
-  rtx_insn_list *merged_insns = 0;
+  auto_vec<std::pair<rtx_insn *, bool>, 10> merged_insns;
   int i, j;
   int flags;
 
@@ -1319,7 +1319,7 @@ try_merge_delay_insns (rtx_insn *insn, rtx_insn *thread)
 	      INSN_FROM_TARGET_P (next_to_match) = 0;
 	    }
 	  else
-	    merged_insns = gen_rtx_INSN_LIST (VOIDmode, trial, merged_insns);
+	    merged_insns.safe_push (std::pair<rtx_insn *, bool> (trial, false));
 
 	  if (++slot_number == num_slots)
 	    break;
@@ -1384,8 +1384,8 @@ try_merge_delay_insns (rtx_insn *insn, rtx_insn *thread)
 		  INSN_FROM_TARGET_P (next_to_match) = 0;
 		}
 	      else
-		merged_insns = gen_rtx_INSN_LIST (SImode, dtrial,
-						  merged_insns);
+		merged_insns.safe_push (std::pair<rtx_insn *, bool> (dtrial,
+								     true));
 
 	      if (++slot_number == num_slots)
 		break;
@@ -1409,21 +1409,20 @@ try_merge_delay_insns (rtx_insn *insn, rtx_insn *thread)
      target.  */
   if (slot_number == num_slots && annul_p)
     {
-      for (; merged_insns; merged_insns = merged_insns->next ())
+      unsigned int len = merged_insns.length ();
+      for (unsigned int i = len - 1; i < len; i--)
 	{
-	  if (GET_MODE (merged_insns) == SImode)
+	  if (merged_insns[i].second)
 	    {
-	      rtx_insn *new_rtx;
-
-	      update_block (merged_insns->insn (), thread);
-	      new_rtx = delete_from_delay_slot (merged_insns->insn ());
+	      update_block (merged_insns[i].first, thread);
+	      rtx_insn *new_rtx = delete_from_delay_slot (merged_insns[i].first);
 	      if (thread->deleted ())
 		thread = new_rtx;
 	    }
 	  else
 	    {
-	      update_block (merged_insns->insn (), thread);
-	      delete_related_insns (merged_insns->insn ());
+	      update_block (merged_insns[i].first, thread);
+	      delete_related_insns (merged_insns[i].first);
 	    }
 	}
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 16/18] make forced labels a vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
  2016-04-20  6:17 ` [PATCH 01/18] stop using rtx_insn_list in reorg.c tbsaunde+gcc
  2016-04-20  6:18 ` [PATCH 04/18] remove unused loads rtx_insn_list tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20 12:41   ` Segher Boessenkool
  2016-04-20  6:18 ` [PATCH 13/18] haifa-sched.c: make twins a auto_vec<rtx_insn *> tbsaunde+gcc
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* cfgbuild.c (make_edges): Adjust.
	* cfgrtl.c (can_delete_label_p): Likewise.
	* dwarf2cfi.c (create_trace_edges): Likewise.
	* except.c (sjlj_emit_dispatch_table): Likewise.
	* function.h (struct expr_status): make x_forced_labels a vector.
	* jump.c (rebuild_jump_labels_1): Adjust.
	* reload1.c (set_initial_label_offsets): Likewise.
	* stmt.c (force_label_rtx): Likewise.
	(expand_label): Likewise.
---
 gcc/cfgbuild.c  |  9 ++++++---
 gcc/cfgrtl.c    |  3 ++-
 gcc/dwarf2cfi.c |  6 ++++--
 gcc/except.c    |  3 +--
 gcc/function.h  |  2 +-
 gcc/jump.c      | 12 +++++++-----
 gcc/reload1.c   |  9 ++++-----
 gcc/stmt.c      |  4 ++--
 8 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index bffb07b..5449a53 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -204,7 +204,8 @@ make_edges (basic_block min, basic_block max, int update_p)
   /* Heavy use of computed goto in machine-generated code can lead to
      nearly fully-connected CFGs.  In that case we spend a significant
      amount of time searching the edge lists for duplicates.  */
-  if (forced_labels || cfun->cfg->max_jumptable_ents > 100)
+  if (!vec_safe_is_empty (forced_labels)
+      || cfun->cfg->max_jumptable_ents > 100)
     edge_cache = sbitmap_alloc (last_basic_block_for_fn (cfun));
 
   /* By nature of the way these get numbered, ENTRY_BLOCK_PTR->next_bb block
@@ -280,8 +281,10 @@ make_edges (basic_block min, basic_block max, int update_p)
 	     everything on the forced_labels list.  */
 	  else if (computed_jump_p (insn))
 	    {
-	      for (rtx_insn_list *x = forced_labels; x; x = x->next ())
-		make_label_edge (edge_cache, bb, x->insn (), EDGE_ABNORMAL);
+	      rtx_insn *insn;
+	      unsigned int i;
+	      FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, insn)
+		make_label_edge (edge_cache, bb, insn, EDGE_ABNORMAL);
 	    }
 
 	  /* Returns create an exit out.  */
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 7cfc634..f4a9244 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -115,7 +115,8 @@ can_delete_label_p (const rtx_code_label *label)
   return (!LABEL_PRESERVE_P (label)
 	  /* User declared labels must be preserved.  */
 	  && LABEL_NAME (label) == 0
-	  && !in_insn_list_p (forced_labels, label));
+	  && !vec_safe_contains<rtx_insn *> (forced_labels,
+					     const_cast<rtx_code_label *> (label)));
 }
 
 /* Delete INSN by patching it out.  */
diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 6180da4..2149c58 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -2354,8 +2354,10 @@ create_trace_edges (rtx_insn *insn)
 	}
       else if (computed_jump_p (insn))
 	{
-	  for (rtx_insn_list *lab = forced_labels; lab; lab = lab->next ())
-	    maybe_record_trace_start (lab->insn (), insn);
+	  rtx_insn *temp;
+	  unsigned int i;
+	  FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, temp)
+	    maybe_record_trace_start (temp, insn);
 	}
       else if (returnjump_p (insn))
 	;
diff --git a/gcc/except.c b/gcc/except.c
index cf1df8c..97f5e6a 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -1278,8 +1278,7 @@ sjlj_emit_dispatch_table (rtx_code_label *dispatch_label, int num_dispatch)
      label on the nonlocal_goto_label list.  Since we're modeling these
      CFG edges more exactly, we can use the forced_labels list instead.  */
   LABEL_PRESERVE_P (dispatch_label) = 1;
-  forced_labels
-    = gen_rtx_INSN_LIST (VOIDmode, dispatch_label, forced_labels);
+  vec_safe_push<rtx_insn *> (forced_labels, dispatch_label);
 #endif
 
   /* Load up exc_ptr and filter values from the function context.  */
diff --git a/gcc/function.h b/gcc/function.h
index 501ef68..590a490 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -126,7 +126,7 @@ struct GTY(()) expr_status {
   rtx x_apply_args_value;
 
   /* List of labels that must never be deleted.  */
-  rtx_insn_list *x_forced_labels;
+  vec<rtx_insn *, va_gc> *x_forced_labels;
 };
 
 typedef struct call_site_record_d *call_site_record;
diff --git a/gcc/jump.c b/gcc/jump.c
index 5b433af..b166926 100644
--- a/gcc/jump.c
+++ b/gcc/jump.c
@@ -68,8 +68,6 @@ static int invert_exp_1 (rtx, rtx);
 static void
 rebuild_jump_labels_1 (rtx_insn *f, bool count_forced)
 {
-  rtx_insn_list *insn;
-
   timevar_push (TV_REBUILD_JUMP);
   init_label_info (f);
   mark_all_labels (f);
@@ -79,9 +77,13 @@ rebuild_jump_labels_1 (rtx_insn *f, bool count_forced)
      count doesn't drop to zero.  */
 
   if (count_forced)
-    for (insn = forced_labels; insn; insn = insn->next ())
-      if (LABEL_P (insn->insn ()))
-	LABEL_NUSES (insn->insn ())++;
+    {
+      rtx_insn *insn;
+      unsigned int i;
+      FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, insn)
+	if (LABEL_P (insn))
+	  LABEL_NUSES (insn)++;
+    }
   timevar_pop (TV_REBUILD_JUMP);
 }
 
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 770bf40..0017eac 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -3873,12 +3873,11 @@ set_initial_label_offsets (void)
 {
   memset (offsets_known_at, 0, num_labels);
 
-  for (rtx_insn_list *x = forced_labels; x; x = x->next ())
-    if (x->insn ())
-      set_label_offsets (x->insn (), NULL, 1);
-
-  rtx_insn *insn;
   unsigned int i;
+  rtx_insn *insn;
+  FOR_EACH_VEC_SAFE_ELT_REVERSE (forced_labels, i, insn)
+    set_label_offsets (insn, NULL, 1);
+
   FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, insn)
       set_label_offsets (insn, NULL, 1);
 
diff --git a/gcc/stmt.c b/gcc/stmt.c
index a6612fc..852cdb5 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -136,7 +136,7 @@ force_label_rtx (tree label)
 
   gcc_assert (function);
 
-  forced_labels = gen_rtx_INSN_LIST (VOIDmode, ref, forced_labels);
+  vec_safe_push (forced_labels, ref);
   return ref;
 }
 
@@ -188,7 +188,7 @@ expand_label (tree label)
     }
 
   if (FORCED_LABEL (label))
-    forced_labels = gen_rtx_INSN_LIST (VOIDmode, label_r, forced_labels);
+    vec_safe_push<rtx_insn *> (forced_labels, label_r);
 
   if (DECL_NONLOCAL (label) || FORCED_LABEL (label))
     maybe_set_first_label_num (label_r);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 03/18] make antic_stores a vec<rtx_insn *>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (7 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 17/18] make pending_{read,write}_insns vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20 11:40   ` Segher Boessenkool
  2016-04-20  6:18 ` [PATCH 07/18] loop-iv.c: make cond_list a vec tbsaunde+gcc
                   ` (9 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* store-motion.c (struct st_expr): Make antic_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.
	(remove_reachable_equiv_notes): Likewise.
	(replace_store_insn): Likewise.
	(build_store_vectors): Likewise.
---
 gcc/store-motion.c | 52 ++++++++++++++++++++++++----------------------------
 1 file changed, 24 insertions(+), 28 deletions(-)

diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index 6646065..a349180 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -45,7 +45,6 @@ along with GCC; see the file COPYING3.  If not see
      a compile time hog that needs a rewrite (maybe cache st_exprs to
      invalidate REG_EQUAL/REG_EQUIV notes for?).
    - pattern_regs in st_expr should be a regset (on its own obstack).
-   - antic_stores and avail_stores should be VECs instead of lists.
    - store_motion_mems should be a vec instead of a list.
    - there should be an alloc pool for struct st_expr objects.
    - investigate whether it is helpful to make the address of an st_expr
@@ -65,7 +64,7 @@ struct st_expr
   /* List of registers mentioned by the mem.  */
   rtx pattern_regs;
   /* INSN list of stores that are locally anticipatable.  */
-  rtx_insn_list *antic_stores;
+  vec<rtx_insn *> antic_stores;
   /* INSN list of stores that are locally available.  */
   vec<rtx_insn *> avail_stores;
   /* Next in the list.  */
@@ -147,7 +146,7 @@ st_expr_entry (rtx x)
   ptr->next         = store_motion_mems;
   ptr->pattern      = x;
   ptr->pattern_regs = NULL_RTX;
-  ptr->antic_stores = NULL;
+  ptr->antic_stores.create (0);
   ptr->avail_stores.create (0);
   ptr->reaching_reg = NULL_RTX;
   ptr->index        = 0;
@@ -163,7 +162,7 @@ st_expr_entry (rtx x)
 static void
 free_st_expr_entry (struct st_expr * ptr)
 {
-  free_INSN_LIST_list (& ptr->antic_stores);
+   ptr->antic_stores.release ();
    ptr->avail_stores.release ();
 
   free (ptr);
@@ -232,11 +231,7 @@ print_store_motion_mems (FILE * file)
       print_rtl (file, ptr->pattern);
 
       fprintf (file, "\n	 ANTIC stores : ");
-
-      if (ptr->antic_stores)
-	print_rtl (file, ptr->antic_stores);
-      else
-	fprintf (file, "(nil)");
+      print_rtx_insn_vec (file, ptr->antic_stores);
 
       fprintf (file, "\n	 AVAIL stores : ");
 
@@ -565,11 +560,11 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
   /* Do not check for anticipatability if we either found one anticipatable
      store already, or tested for one and found out that it was killed.  */
   check_anticipatable = 0;
-  if (!ptr->antic_stores)
+  if (ptr->antic_stores.is_empty ())
     check_anticipatable = 1;
   else
     {
-      rtx_insn *tmp = ptr->antic_stores->insn ();
+      rtx_insn *tmp = ptr->antic_stores.last ();
       if (tmp != NULL_RTX
 	  && BLOCK_FOR_INSN (tmp) != bb)
 	check_anticipatable = 1;
@@ -581,7 +576,7 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
 	tmp = NULL;
       else
 	tmp = insn;
-      ptr->antic_stores = alloc_INSN_LIST (tmp, ptr->antic_stores);
+      ptr->antic_stores.safe_push (tmp);
     }
 
   /* It is not necessary to check whether store is available if we did
@@ -682,9 +677,9 @@ compute_store_table (void)
       for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
 	{
 	  LAST_AVAIL_CHECK_FAILURE (ptr) = NULL_RTX;
-	  if (ptr->antic_stores
-	      && (tmp = ptr->antic_stores->insn ()) == NULL_RTX)
-	    ptr->antic_stores = ptr->antic_stores->next ();
+	  if (!ptr->antic_stores.is_empty ()
+	      && (tmp = ptr->antic_stores.last ()) == NULL)
+	    ptr->antic_stores.pop ();
 	}
     }
 
@@ -830,7 +825,7 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr)
   int sp;
   edge act;
   sbitmap visited = sbitmap_alloc (last_basic_block_for_fn (cfun));
-  rtx last, note;
+  rtx note;
   rtx_insn *insn;
   rtx mem = smexpr->pattern;
 
@@ -865,13 +860,13 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr)
 	}
       bitmap_set_bit (visited, bb->index);
 
+      rtx_insn *last;
       if (bitmap_bit_p (st_antloc[bb->index], smexpr->index))
 	{
-	  for (last = smexpr->antic_stores;
-	       BLOCK_FOR_INSN (XEXP (last, 0)) != bb;
-	       last = XEXP (last, 1))
-	    continue;
-	  last = XEXP (last, 0);
+	  unsigned int i;
+	  FOR_EACH_VEC_ELT_REVERSE (smexpr->antic_stores, i, last)
+	    if (BLOCK_FOR_INSN (last) == bb)
+	      break;
 	}
       else
 	last = NEXT_INSN (BB_END (bb));
@@ -910,15 +905,17 @@ replace_store_insn (rtx reg, rtx_insn *del, basic_block bb,
 		    struct st_expr *smexpr)
 {
   rtx_insn *insn;
-  rtx mem, note, set, ptr;
+  rtx mem, note, set;
 
   mem = smexpr->pattern;
   insn = gen_move_insn (reg, SET_SRC (single_set (del)));
 
-  for (ptr = smexpr->antic_stores; ptr; ptr = XEXP (ptr, 1))
-    if (XEXP (ptr, 0) == del)
+  unsigned int i;
+  rtx_insn *temp;
+  FOR_EACH_VEC_ELT_REVERSE (smexpr->antic_stores, i, temp)
+    if (temp == del)
       {
-	XEXP (ptr, 0) = insn;
+	smexpr->antic_stores[i] = insn;
 	break;
       }
 
@@ -1000,7 +997,6 @@ build_store_vectors (void)
   basic_block bb;
   int *regs_set_in_block;
   rtx_insn *insn;
-  rtx_insn_list *st;
   struct st_expr * ptr;
   unsigned int max_gcse_regno = max_reg_num ();
 
@@ -1037,9 +1033,9 @@ build_store_vectors (void)
 	  bitmap_set_bit (st_avloc[bb->index], ptr->index);
 	}
 
-      for (st = ptr->antic_stores; st != NULL; st = st->next ())
+      unsigned int i;
+      FOR_EACH_VEC_ELT_REVERSE (ptr->antic_stores, i, insn)
 	{
-	  insn = st->insn ();
 	  bb = BLOCK_FOR_INSN (insn);
 	  bitmap_set_bit (st_antloc[bb->index], ptr->index);
 	}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 09/18] make pattern_regs a vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (10 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 02/18] make avail_stores a vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-25 12:56   ` Bernd Schmidt
  2016-04-20  6:19 ` [PATCH 06/18] move reg_equivs out of gc memory tbsaunde+gcc
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* store-motion.c (struct st_expr): Make pattern_regs a vector.
	(st_expr_entry): Adjust.
	(store_ops_ok): Likewise.
	(extract_mentioned_regs): Likewise.
	(store_killed_in_insn): Likewise.
	(find_moveable_store): Likewise.
---
 gcc/store-motion.c | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index a349180..fbc737d 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -62,7 +62,7 @@ struct st_expr
   /* Pattern of this mem.  */
   rtx pattern;
   /* List of registers mentioned by the mem.  */
-  rtx pattern_regs;
+  vec<rtx> pattern_regs;
   /* INSN list of stores that are locally anticipatable.  */
   vec<rtx_insn *> antic_stores;
   /* INSN list of stores that are locally available.  */
@@ -145,7 +145,7 @@ st_expr_entry (rtx x)
 
   ptr->next         = store_motion_mems;
   ptr->pattern      = x;
-  ptr->pattern_regs = NULL_RTX;
+  ptr->pattern_regs.create (0);
   ptr->antic_stores.create (0);
   ptr->avail_stores.create (0);
   ptr->reaching_reg = NULL_RTX;
@@ -247,16 +247,12 @@ print_store_motion_mems (FILE * file)
    due to set of registers in bitmap REGS_SET.  */
 
 static bool
-store_ops_ok (const_rtx x, int *regs_set)
+store_ops_ok (const vec<rtx> &x, int *regs_set)
 {
-  const_rtx reg;
-
-  for (; x; x = XEXP (x, 1))
-    {
-      reg = XEXP (x, 0);
-      if (regs_set[REGNO (reg)])
-	return false;
-    }
+  unsigned int len = x.length ();
+  for (unsigned int i = 0; i < len; i++)
+    if (regs_set[REGNO (x[i])])
+      return false;
 
   return true;
 }
@@ -264,16 +260,16 @@ store_ops_ok (const_rtx x, int *regs_set)
 /* Returns a list of registers mentioned in X.
    FIXME: A regset would be prettier and less expensive.  */
 
-static rtx_expr_list *
+static vec<rtx>
 extract_mentioned_regs (rtx x)
 {
-  rtx_expr_list *mentioned_regs = NULL;
+  vec<rtx> mentioned_regs = vNULL;
   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);
+	mentioned_regs.safe_push (x);
     }
   return mentioned_regs;
 }
@@ -372,9 +368,10 @@ store_killed_in_pat (const_rtx x, const_rtx pat, int after)
    after the insn.  Return true if it does.  */
 
 static bool
-store_killed_in_insn (const_rtx x, const_rtx x_regs, const rtx_insn *insn, int after)
+store_killed_in_insn (const_rtx x, const vec<rtx> &x_regs,
+		      const rtx_insn *insn, int after)
 {
-  const_rtx reg, note, pat;
+  const_rtx note, pat;
 
   if (! NONDEBUG_INSN_P (insn))
     return false;
@@ -388,8 +385,9 @@ store_killed_in_insn (const_rtx x, const_rtx x_regs, const rtx_insn *insn, int a
 
       /* But even a const call reads its parameters.  Check whether the
 	 base of some of registers used in mem is stack pointer.  */
-      for (reg = x_regs; reg; reg = XEXP (reg, 1))
-	if (may_be_sp_based_p (XEXP (reg, 0)))
+      unsigned int len = x_regs.length ();
+      for (unsigned int i = 0; i < len; i++)
+	if (may_be_sp_based_p (x_regs[i]))
 	  return true;
 
       return false;
@@ -434,8 +432,8 @@ store_killed_in_insn (const_rtx x, const_rtx x_regs, const rtx_insn *insn, int a
    is killed, return the last insn in that it occurs in FAIL_INSN.  */
 
 static bool
-store_killed_after (const_rtx x, const_rtx x_regs, const rtx_insn *insn,
-		    const_basic_block bb,
+store_killed_after (const_rtx x, const vec<rtx> &x_regs,
+		    const rtx_insn *insn, const_basic_block bb,
 		    int *regs_set_after, rtx *fail_insn)
 {
   rtx_insn *last = BB_END (bb), *act;
@@ -464,8 +462,9 @@ store_killed_after (const_rtx x, const_rtx x_regs, const rtx_insn *insn,
    within basic block BB. X_REGS is list of registers mentioned in X.
    REGS_SET_BEFORE is bitmap of registers set before or in this insn.  */
 static bool
-store_killed_before (const_rtx x, const_rtx x_regs, const rtx_insn *insn,
-		     const_basic_block bb, int *regs_set_before)
+store_killed_before (const_rtx x, const vec<rtx> &x_regs,
+		     const rtx_insn *insn, const_basic_block bb,
+		     int *regs_set_before)
 {
   rtx_insn *first = BB_HEAD (bb);
 
@@ -554,7 +553,7 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
     return;
 
   ptr = st_expr_entry (dest);
-  if (!ptr->pattern_regs)
+  if (ptr->pattern_regs.is_empty ())
     ptr->pattern_regs = extract_mentioned_regs (dest);
 
   /* Do not check for anticipatability if we either found one anticipatable
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 17/18] make pending_{read,write}_insns vec<rtx_insn *>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (6 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 08/18] make side_effects a vec<rtx> tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20 12:50   ` Segher Boessenkool
  2016-04-20  6:18 ` [PATCH 03/18] make antic_stores a " tbsaunde+gcc
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

The old versions of the functions copied here are removed in later patches in
my queue once all the lists are gone from sched-*.  However they are necessary
temporarily to not have to convert all the lists at once which made writing and
hopefully reviewing these patches much easier.

gcc/ChangeLog:

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

	* sched-deps.c (add_dependence_list): Adjust.
	(add_dependence_list_and_free): Likewise.
	(remove_from_both_dependence_lists): Likewise.
	(add_insn_mem_dependence): Likewise. Likewise.
	(flush_pending_lists): Likewise.
	(sched_analyze_1): Likewise.
	(sched_analyze_2): Likewise.
	(sched_analyze_insn): Likewise.
	(init_deps): Likewise.
	(free_deps): Likewise.
	* sched-int.h (struct deps_desc): Make pending_read_insns and
	pending_write_insns vectors.
	* sched-rgn.c (concat_mem_list): Adjust.
	(deps_join): Likewise.
	(propagate_deps): Likewise.
	(free_pending_lists): Likewise.
---
 gcc/sched-deps.c | 134 ++++++++++++++++++++++++++++++-------------------------
 gcc/sched-int.h  |   4 +-
 gcc/sched-rgn.c  |  41 +++++++----------
 3 files changed, 91 insertions(+), 88 deletions(-)

diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 8f3a124..879c9ca 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -1568,6 +1568,20 @@ add_dependence_list (rtx_insn *insn, rtx_insn_list *list, int uncond,
   mark_as_hard = false;
 }
 
+static void
+add_dependence_list (rtx_insn *insn, const vec<rtx_insn *> &insns, int uncond,
+		     enum reg_note dep_type, bool hard)
+{
+  mark_as_hard = hard;
+  unsigned int len = insns.length ();
+  for (unsigned int i = len - 1; i < len; i--)
+    {
+      if (uncond || ! sched_insns_conditions_mutex_p (insn, insns[i]))
+	add_dependence (insn, insns[i], dep_type);
+    }
+  mark_as_hard = false;
+}
+
 /* Similar, but free *LISTP at the same time, when the context
    is not readonly.  HARD should be true if DEP_NONREG should be set on
    newly created dependencies.  */
@@ -1588,6 +1602,22 @@ add_dependence_list_and_free (struct deps_desc *deps, rtx_insn *insn,
   free_INSN_LIST_list (listp);
 }
 
+static void
+add_dependence_list_and_free (struct deps_desc *deps, rtx_insn *insn,
+			      vec<rtx_insn *> *insns,
+			      int uncond, enum reg_note dep_type, bool hard)
+{
+  add_dependence_list (insn, *insns, uncond, dep_type, hard);
+
+  /* We don't want to short-circuit dependencies involving debug
+     insns, because they may cause actual dependencies to be
+     disregarded.  */
+  if (deps->readonly || DEBUG_INSN_P (insn))
+    return;
+
+  insns->release ();
+}
+
 /* Remove all occurrences of INSN from LIST.  Return the number of
    occurrences removed.  */
 
@@ -1614,22 +1644,22 @@ remove_from_dependence_list (rtx_insn *insn, rtx_insn_list **listp)
 /* Same as above, but process two lists at once.  */
 static int
 remove_from_both_dependence_lists (rtx_insn *insn,
-				   rtx_insn_list **listp,
+				   vec<rtx_insn *> *insns,
 				   rtx_expr_list **exprp)
 {
   int removed = 0;
 
-  while (*listp)
+  unsigned int len = insns->length ();
+  for (unsigned int i = len - 1; i < len; i--)
     {
-      if (XEXP (*listp, 0) == insn)
+      if ((*insns)[i] == insn)
         {
-          remove_free_INSN_LIST_node (listp);
+	  insns->ordered_remove (i);
           remove_free_EXPR_LIST_node (exprp);
           removed++;
           continue;
         }
 
-      listp = (rtx_insn_list **)&XEXP (*listp, 1);
       exprp = (rtx_expr_list **)&XEXP (*exprp, 1);
     }
 
@@ -1710,29 +1740,24 @@ static void
 add_insn_mem_dependence (struct deps_desc *deps, bool read_p,
 			 rtx_insn *insn, rtx mem)
 {
-  rtx_insn_list **insn_list;
-  rtx_insn_list *insn_node;
   rtx_expr_list **mem_list;
   rtx_expr_list *mem_node;
 
   gcc_assert (!deps->readonly);
   if (read_p)
     {
-      insn_list = &deps->pending_read_insns;
+      deps->pending_read_insns.safe_push (insn);
       mem_list = &deps->pending_read_mems;
       if (!DEBUG_INSN_P (insn))
 	deps->pending_read_list_length++;
     }
   else
     {
-      insn_list = &deps->pending_write_insns;
+      deps->pending_write_insns.safe_push (insn);
       mem_list = &deps->pending_write_mems;
       deps->pending_write_list_length++;
     }
 
-  insn_node = alloc_INSN_LIST (insn, *insn_list);
-  *insn_list = insn_node;
-
   if (sched_deps_info->use_cselib)
     {
       mem = shallow_copy_rtx (mem);
@@ -1777,8 +1802,8 @@ flush_pending_lists (struct deps_desc *deps, rtx_insn *insn, int for_read,
   if (DEBUG_INSN_P (insn))
     {
       if (for_write)
-	free_INSN_LIST_list (&deps->pending_read_insns);
-      free_INSN_LIST_list (&deps->pending_write_insns);
+	deps->pending_read_insns.release ();
+      deps->pending_write_insns.release ();
       free_INSN_LIST_list (&deps->last_pending_memory_flush);
       free_INSN_LIST_list (&deps->pending_jump_insns);
     }
@@ -2489,33 +2514,29 @@ sched_analyze_1 (struct deps_desc *deps, rtx x, rtx_insn *insn)
 	}
       else
 	{
-	  rtx_insn_list *pending;
 	  rtx_expr_list *pending_mem;
 
-	  pending = deps->pending_read_insns;
+	  unsigned int len = deps->pending_read_insns.length ();
 	  pending_mem = deps->pending_read_mems;
-	  while (pending)
+	  for (unsigned int i = len - 1; i < len; i--)
 	    {
+	      rtx_insn *temp = deps->pending_read_insns[i];
 	      if (anti_dependence (pending_mem->element (), t)
-		  && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
-		note_mem_dep (t, pending_mem->element (), pending->insn (),
-			      DEP_ANTI);
+		  && ! sched_insns_conditions_mutex_p (insn, temp))
+		note_mem_dep (t, pending_mem->element (), temp, DEP_ANTI);
 
-	      pending = pending->next ();
 	      pending_mem = pending_mem->next ();
 	    }
 
-	  pending = deps->pending_write_insns;
+	  len = deps->pending_write_insns.length ();
 	  pending_mem = deps->pending_write_mems;
-	  while (pending)
+	  for (unsigned int i = len - 1; i < len; i--)
 	    {
+	      rtx_insn *temp = deps->pending_write_insns[i];
 	      if (output_dependence (pending_mem->element (), t)
-		  && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
-		note_mem_dep (t, pending_mem->element (),
-			      pending->insn (),
-			      DEP_OUTPUT);
+		  && ! sched_insns_conditions_mutex_p (insn, temp))
+		note_mem_dep (t, pending_mem->element (), temp, DEP_OUTPUT);
 
-	      pending = pending->next ();
 	      pending_mem = pending_mem-> next ();
 	    }
 
@@ -2620,7 +2641,6 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
       {
 	/* Reading memory.  */
 	rtx_insn_list *u;
-	rtx_insn_list *pending;
 	rtx_expr_list *pending_mem;
 	rtx t = x;
 
@@ -2639,34 +2659,29 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
 	if (!DEBUG_INSN_P (insn))
 	  {
 	    t = canon_rtx (t);
-	    pending = deps->pending_read_insns;
+	    unsigned int len = deps->pending_read_insns.length ();
 	    pending_mem = deps->pending_read_mems;
-	    while (pending)
+	    for (unsigned int i = len - 1; i < len; i--)
 	      {
+		rtx_insn *temp = deps->pending_read_insns[i];
 		if (read_dependence (pending_mem->element (), t)
-		    && ! sched_insns_conditions_mutex_p (insn,
-							 pending->insn ()))
-		  note_mem_dep (t, pending_mem->element (),
-				pending->insn (),
-				DEP_ANTI);
+		    && ! sched_insns_conditions_mutex_p (insn, temp))
+		  note_mem_dep (t, pending_mem->element (), temp, DEP_ANTI);
 
-		pending = pending->next ();
 		pending_mem = pending_mem->next ();
 	      }
 
-	    pending = deps->pending_write_insns;
+	    len = deps->pending_write_insns.length ();
 	    pending_mem = deps->pending_write_mems;
-	    while (pending)
+	    for (unsigned int i = len - 1; i < len; i--)
 	      {
+		rtx_insn *temp = deps->pending_write_insns[i];
 		if (true_dependence (pending_mem->element (), VOIDmode, t)
-		    && ! sched_insns_conditions_mutex_p (insn,
-							 pending->insn ()))
-		  note_mem_dep (t, pending_mem->element (),
-				pending->insn (),
+		    && ! sched_insns_conditions_mutex_p (insn, temp))
+		  note_mem_dep (t, pending_mem->element (), temp,
 				sched_deps_info->generate_spec_deps
 				? BEGIN_DATA | DEP_TRUE : DEP_TRUE);
 
-		pending = pending->next ();
 		pending_mem = pending_mem->next ();
 	      }
 
@@ -2987,7 +3002,6 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
 	reg_pending_barrier = MOVE_BARRIER;
       else
 	{
-	  rtx_insn_list *pending;
 	  rtx_expr_list *pending_mem;
 
           if (sched_deps_info->compute_jump_reg_dependencies)
@@ -3012,26 +3026,24 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
 	     jump.  Non-volatile reads must happen before the jump iff
 	     the result is needed by the above register used mask.  */
 
-	  pending = deps->pending_write_insns;
+	  unsigned int len = deps->pending_write_insns.length ();
 	  pending_mem = deps->pending_write_mems;
-	  while (pending)
+	  for (unsigned int i = len - 1; i < len; i--)
 	    {
-	      if (! sched_insns_conditions_mutex_p (insn, pending->insn ()))
-		add_dependence (insn, pending->insn (),
-				REG_DEP_OUTPUT);
-	      pending = pending->next ();
+	      rtx_insn *temp = deps->pending_write_insns[i];
+	      if (! sched_insns_conditions_mutex_p (insn, temp))
+		add_dependence (insn, temp, REG_DEP_OUTPUT);
 	      pending_mem = pending_mem->next ();
 	    }
 
-	  pending = deps->pending_read_insns;
+	  len = deps->pending_read_insns.length ();
 	  pending_mem = deps->pending_read_mems;
-	  while (pending)
+	  for (unsigned int i = len - 1; i < len; i--)
 	    {
+	      rtx_insn *temp = deps->pending_read_insns[i];
 	      if (MEM_VOLATILE_P (pending_mem->element ())
-		  && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
-		add_dependence (insn, pending->insn (),
-				REG_DEP_OUTPUT);
-	      pending = pending->next ();
+		  && ! sched_insns_conditions_mutex_p (insn, temp))
+		add_dependence (insn, temp, REG_DEP_OUTPUT);
 	      pending_mem = pending_mem->next ();
 	    }
 
@@ -3887,9 +3899,9 @@ init_deps (struct deps_desc *deps, bool lazy_reg_last)
     deps->reg_last = XCNEWVEC (struct deps_reg, max_reg);
   INIT_REG_SET (&deps->reg_last_in_use);
 
-  deps->pending_read_insns = 0;
+  deps->pending_read_insns.create (0);
   deps->pending_read_mems = 0;
-  deps->pending_write_insns = 0;
+  deps->pending_write_insns.create (0);
   deps->pending_write_mems = 0;
   deps->pending_jump_insns = 0;
   deps->pending_read_list_length = 0;
@@ -3935,9 +3947,9 @@ free_deps (struct deps_desc *deps)
     }
   deps->max_reg = 0;
 
-  free_INSN_LIST_list (&deps->pending_read_insns);
+  deps->pending_read_insns.release ();
   free_EXPR_LIST_list (&deps->pending_read_mems);
-  free_INSN_LIST_list (&deps->pending_write_insns);
+  deps->pending_write_insns.release ();
   free_EXPR_LIST_list (&deps->pending_write_mems);
   free_INSN_LIST_list (&deps->last_pending_memory_flush);
 
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index de5d326..45890b8 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -466,13 +466,13 @@ struct deps_desc
      to a list more than once.  */
 
   /* An INSN_LIST containing all insns with pending read operations.  */
-  rtx_insn_list *pending_read_insns;
+  vec<rtx_insn *> pending_read_insns;
 
   /* An EXPR_LIST containing all MEM rtx's which are pending reads.  */
   rtx_expr_list *pending_read_mems;
 
   /* An INSN_LIST containing all insns with pending write operations.  */
-  rtx_insn_list *pending_write_insns;
+  vec<rtx_insn *> pending_write_insns;
 
   /* An EXPR_LIST containing all MEM rtx's which are pending writes.  */
   rtx_expr_list *pending_write_mems;
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index d4b71a1..9e807a1 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -238,8 +238,7 @@ static void add_branch_dependences (rtx_insn *, rtx_insn *);
 static void compute_block_dependences (int);
 
 static void schedule_region (int);
-static void concat_insn_mem_list (rtx_insn_list *, rtx_expr_list *,
-				  rtx_insn_list **, rtx_expr_list **);
+static void concat_mem_list (rtx_expr_list *, rtx_expr_list **);
 static void propagate_deps (int, struct deps_desc *);
 static void free_pending_lists (void);
 
@@ -2576,23 +2575,16 @@ add_branch_dependences (rtx_insn *head, rtx_insn *tail)
 static struct deps_desc *bb_deps;
 
 static void
-concat_insn_mem_list (rtx_insn_list *copy_insns,
-		      rtx_expr_list *copy_mems,
-		      rtx_insn_list **old_insns_p,
-		      rtx_expr_list **old_mems_p)
+concat_mem_list (rtx_expr_list *copy_mems, rtx_expr_list **old_mems_p)
 {
-  rtx_insn_list *new_insns = *old_insns_p;
   rtx_expr_list *new_mems = *old_mems_p;
 
-  while (copy_insns)
+  while (copy_mems)
     {
-      new_insns = alloc_INSN_LIST (copy_insns->insn (), new_insns);
       new_mems = alloc_EXPR_LIST (VOIDmode, copy_mems->element (), new_mems);
-      copy_insns = copy_insns->next ();
       copy_mems = copy_mems->next ();
     }
 
-  *old_insns_p = new_insns;
   *old_mems_p = new_mems;
 }
 
@@ -2621,14 +2613,12 @@ deps_join (struct deps_desc *succ_deps, struct deps_desc *pred_deps)
   IOR_REG_SET (&succ_deps->reg_last_in_use, &pred_deps->reg_last_in_use);
 
   /* Mem read/write lists are inherited by successor.  */
-  concat_insn_mem_list (pred_deps->pending_read_insns,
-                        pred_deps->pending_read_mems,
-                        &succ_deps->pending_read_insns,
-                        &succ_deps->pending_read_mems);
-  concat_insn_mem_list (pred_deps->pending_write_insns,
-                        pred_deps->pending_write_mems,
-                        &succ_deps->pending_write_insns,
-                        &succ_deps->pending_write_mems);
+  succ_deps->pending_read_insns.safe_splice (pred_deps->pending_read_insns);
+  succ_deps->pending_write_insns.safe_splice (pred_deps->pending_write_insns);
+  concat_mem_list (pred_deps->pending_read_mems,
+		   &succ_deps->pending_read_mems);
+  concat_mem_list (pred_deps->pending_write_mems,
+		   &succ_deps->pending_write_mems);
 
   succ_deps->pending_jump_insns
     = concat_INSN_LIST (pred_deps->pending_jump_insns,
@@ -2678,18 +2668,19 @@ propagate_deps (int bb, struct deps_desc *pred_deps)
       deps_join (bb_deps + BLOCK_TO_BB (e->dest->index), pred_deps);
     }
 
+  bb_deps[bb].pending_read_insns = pred_deps->pending_read_insns;
+  pred_deps->pending_read_insns = vNULL;
+  bb_deps[bb].pending_write_insns = pred_deps->pending_write_insns;
+  pred_deps->pending_write_insns = vNULL;
+
   /* These lists should point to the right place, for correct
      freeing later.  */
-  bb_deps[bb].pending_read_insns = pred_deps->pending_read_insns;
   bb_deps[bb].pending_read_mems = pred_deps->pending_read_mems;
-  bb_deps[bb].pending_write_insns = pred_deps->pending_write_insns;
   bb_deps[bb].pending_write_mems = pred_deps->pending_write_mems;
   bb_deps[bb].pending_jump_insns = pred_deps->pending_jump_insns;
 
   /* Can't allow these to be freed twice.  */
-  pred_deps->pending_read_insns = 0;
   pred_deps->pending_read_mems = 0;
-  pred_deps->pending_write_insns = 0;
   pred_deps->pending_write_mems = 0;
   pred_deps->pending_jump_insns = 0;
 }
@@ -2766,8 +2757,8 @@ free_pending_lists (void)
 
   for (bb = 0; bb < current_nr_blocks; bb++)
     {
-      free_INSN_LIST_list (&bb_deps[bb].pending_read_insns);
-      free_INSN_LIST_list (&bb_deps[bb].pending_write_insns);
+      bb_deps[bb].pending_read_insns.release ();
+      bb_deps[bb].pending_write_insns.release ();
       free_EXPR_LIST_list (&bb_deps[bb].pending_read_mems);
       free_EXPR_LIST_list (&bb_deps[bb].pending_write_mems);
       free_INSN_LIST_list (&bb_deps[bb].pending_jump_insns);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 08/18] make side_effects a vec<rtx>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (5 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 05/18] make stores rtx_insn_list " tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-22  5:18   ` Jeff Law
  2016-04-20  6:18 ` [PATCH 17/18] make pending_{read,write}_insns vec<rtx_insn *> tbsaunde+gcc
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* var-tracking.c (struct adjust_mem_data): Make side_effects a vector.
	(adjust_mems): Adjust.
	(adjust_insn): Likewise.
	(prepare_call_arguments): Likewise.
---
 gcc/var-tracking.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 9f09d30..7fc6ed3 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -926,7 +926,7 @@ struct adjust_mem_data
   bool store;
   machine_mode mem_mode;
   HOST_WIDE_INT stack_adjust;
-  rtx_expr_list *side_effects;
+  auto_vec<rtx> side_effects;
 };
 
 /* Helper for adjust_mems.  Return true if X is suitable for
@@ -1072,9 +1072,7 @@ adjust_mems (rtx loc, const_rtx old_rtx, void *data)
       amd->store = false;
       tem = simplify_replace_fn_rtx (tem, old_rtx, adjust_mems, data);
       amd->store = store_save;
-      amd->side_effects = alloc_EXPR_LIST (0,
-					   gen_rtx_SET (XEXP (loc, 0), tem),
-					   amd->side_effects);
+      amd->side_effects.safe_push (gen_rtx_SET (XEXP (loc, 0), tem));
       return addr;
     case PRE_MODIFY:
       addr = XEXP (loc, 1);
@@ -1088,9 +1086,7 @@ adjust_mems (rtx loc, const_rtx old_rtx, void *data)
       tem = simplify_replace_fn_rtx (XEXP (loc, 1), old_rtx,
 				     adjust_mems, data);
       amd->store = store_save;
-      amd->side_effects = alloc_EXPR_LIST (0,
-					   gen_rtx_SET (XEXP (loc, 0), tem),
-					   amd->side_effects);
+      amd->side_effects.safe_push (gen_rtx_SET (XEXP (loc, 0), tem));
       return addr;
     case SUBREG:
       /* First try without delegitimization of whole MEMs and
@@ -1184,7 +1180,6 @@ adjust_mem_stores (rtx loc, const_rtx expr, void *data)
 static void
 adjust_insn (basic_block bb, rtx_insn *insn)
 {
-  struct adjust_mem_data amd;
   rtx set;
 
 #ifdef HAVE_window_save
@@ -1213,9 +1208,9 @@ adjust_insn (basic_block bb, rtx_insn *insn)
     }
 #endif
 
+  adjust_mem_data amd;
   amd.mem_mode = VOIDmode;
   amd.stack_adjust = -VTI (bb)->out.stack_adjust;
-  amd.side_effects = NULL;
 
   amd.store = true;
   note_stores (PATTERN (insn), adjust_mem_stores, &amd);
@@ -1281,10 +1276,10 @@ adjust_insn (basic_block bb, rtx_insn *insn)
 	validate_change (NULL_RTX, &SET_SRC (set), XEXP (note, 0), true);
     }
 
-  if (amd.side_effects)
+  if (!amd.side_effects.is_empty ())
     {
-      rtx *pat, new_pat, s;
-      int i, oldn, newn;
+      rtx *pat, new_pat;
+      int i, oldn;
 
       pat = &PATTERN (insn);
       if (GET_CODE (*pat) == COND_EXEC)
@@ -1293,17 +1288,15 @@ adjust_insn (basic_block bb, rtx_insn *insn)
 	oldn = XVECLEN (*pat, 0);
       else
 	oldn = 1;
-      for (s = amd.side_effects, newn = 0; s; newn++)
-	s = XEXP (s, 1);
+      unsigned int newn = amd.side_effects.length ();
       new_pat = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (oldn + newn));
       if (GET_CODE (*pat) == PARALLEL)
 	for (i = 0; i < oldn; i++)
 	  XVECEXP (new_pat, 0, i) = XVECEXP (*pat, 0, i);
       else
 	XVECEXP (new_pat, 0, 0) = *pat;
-      for (s = amd.side_effects, i = oldn; i < oldn + newn; i++, s = XEXP (s, 1))
-	XVECEXP (new_pat, 0, i) = XEXP (s, 0);
-      free_EXPR_LIST_list (&amd.side_effects);
+      for (unsigned int j = newn - 1; j < newn; j--)
+	XVECEXP (new_pat, 0, j + oldn) = amd.side_effects[j];
       validate_change (NULL_RTX, pat, new_pat, true);
     }
 }
@@ -6335,11 +6328,10 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
 		struct adjust_mem_data amd;
 		amd.mem_mode = VOIDmode;
 		amd.stack_adjust = -VTI (bb)->out.stack_adjust;
-		amd.side_effects = NULL;
 		amd.store = true;
 		mem = simplify_replace_fn_rtx (mem, NULL_RTX, adjust_mems,
 					       &amd);
-		gcc_assert (amd.side_effects == NULL_RTX);
+		gcc_assert (amd.side_effects.is_empty ());
 	      }
 	    val = cselib_lookup (mem, GET_MODE (mem), 0, VOIDmode);
 	    if (val && cselib_preserved_value_p (val))
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 07/18] loop-iv.c: make cond_list a vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (8 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 03/18] make antic_stores a " tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-25 12:29   ` Bernd Schmidt
  2016-04-20  6:18 ` [PATCH 02/18] make avail_stores a vec<rtx_insn *> tbsaunde+gcc
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* loop-iv.c (simplify_using_initial_values): Make cond_list a vector.
---
 gcc/loop-iv.c | 55 ++++++++++++++++++-------------------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)

diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index fecaf8f..7f000c7 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -1860,7 +1860,6 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 {
   bool expression_valid;
   rtx head, tail, last_valid_expr;
-  rtx_expr_list *cond_list;
   rtx_insn *insn;
   rtx neutral, aggr;
   regset altered, this_altered;
@@ -1936,7 +1935,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 
   expression_valid = true;
   last_valid_expr = *expr;
-  cond_list = NULL;
+  auto_vec<rtx> cond_list;
   while (1)
     {
       insn = BB_END (e->src);
@@ -1952,17 +1951,18 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 	      simplify_using_condition (cond, expr, altered);
 	      if (old != *expr)
 		{
-		  rtx note;
 		  if (CONSTANT_P (*expr))
 		    goto out;
-		  for (note = cond_list; note; note = XEXP (note, 1))
+
+		  unsigned int len = cond_list.length ();
+		  for (unsigned int i = len - 1; i < len; i--)
 		    {
-		      simplify_using_condition (XEXP (note, 0), expr, altered);
+		      simplify_using_condition (cond_list[i], expr, altered);
 		      if (CONSTANT_P (*expr))
 			goto out;
 		    }
 		}
-	      cond_list = alloc_EXPR_LIST (0, cond, cond_list);
+	      cond_list.safe_push (cond);
 	    }
 	}
 
@@ -1988,39 +1988,30 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 
 	  if (suitable_set_for_replacement (insn, &dest, &src))
 	    {
-	      rtx_expr_list **pnote, **pnote_next;
-
 	      replace_in_expr (expr, dest, src);
 	      if (CONSTANT_P (*expr))
 		goto out;
 
-	      for (pnote = &cond_list; *pnote; pnote = pnote_next)
+	      unsigned int len = cond_list.length ();
+	      for (unsigned int i = len - 1; i < len; i--)
 		{
-		  rtx_expr_list *note = *pnote;
-		  rtx old_cond = XEXP (note, 0);
+		  rtx old_cond = cond_list[i];
 
-		  pnote_next = (rtx_expr_list **)&XEXP (note, 1);
-		  replace_in_expr (&XEXP (note, 0), dest, src);
+		  replace_in_expr (&cond_list[i], dest, src);
 
 		  /* We can no longer use a condition that has been simplified
 		     to a constant, and simplify_using_condition will abort if
 		     we try.  */
-		  if (CONSTANT_P (XEXP (note, 0)))
-		    {
-		      *pnote = *pnote_next;
-		      pnote_next = pnote;
-		      free_EXPR_LIST_node (note);
-		    }
+		  if (CONSTANT_P (cond_list[i]))
+		    cond_list.ordered_remove (i);
 		  /* Retry simplifications with this condition if either the
 		     expression or the condition changed.  */
-		  else if (old_cond != XEXP (note, 0) || old != *expr)
-		    simplify_using_condition (XEXP (note, 0), expr, altered);
+		  else if (old_cond != cond_list[i] || old != *expr)
+		    simplify_using_condition (cond_list[i], expr, altered);
 		}
 	    }
 	  else
 	    {
-	      rtx_expr_list **pnote, **pnote_next;
-
 	      /* If we did not use this insn to make a replacement, any overlap
 		 between stores in this insn and our expression will cause the
 		 expression to become invalid.  */
@@ -2028,19 +2019,10 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 		goto out;
 
 	      /* Likewise for the conditions.  */
-	      for (pnote = &cond_list; *pnote; pnote = pnote_next)
-		{
-		  rtx_expr_list *note = *pnote;
-		  rtx old_cond = XEXP (note, 0);
-
-		  pnote_next = (rtx_expr_list **)&XEXP (note, 1);
-		  if (altered_reg_used (old_cond, this_altered))
-		    {
-		      *pnote = *pnote_next;
-		      pnote_next = pnote;
-		      free_EXPR_LIST_node (note);
-		    }
-		}
+	      unsigned int len = cond_list.length ();
+	      for (unsigned int i = len - 1; i < len; i--)
+		if (altered_reg_used (cond_list[i], this_altered))
+		  cond_list.ordered_remove (i);
 	    }
 
 	  if (CONSTANT_P (*expr))
@@ -2065,7 +2047,6 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
     }
 
  out:
-  free_EXPR_LIST_list (&cond_list);
   if (!CONSTANT_P (*expr))
     *expr = last_valid_expr;
   FREE_REG_SET (altered);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 04/18] remove unused loads rtx_insn_list
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
  2016-04-20  6:17 ` [PATCH 01/18] stop using rtx_insn_list in reorg.c tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-22  5:05   ` Jeff Law
  2016-04-20  6:18 ` [PATCH 16/18] make forced labels a vec tbsaunde+gcc
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* gcse.c (struct ls_expr): Remove loads field.
	(ldst_entry): Adjust.
	(free_ldst_entry): Likewise.
	(print_ldst_list): Likewise.
	(compute_ld_motion_mems): Likewise.
---
 gcc/gcse.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/gcc/gcse.c b/gcc/gcse.c
index a3a7dc3..127a65a 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -342,7 +342,6 @@ struct ls_expr
   struct gcse_expr * expr;	/* Gcse expression reference for LM.  */
   rtx pattern;			/* Pattern of this mem.  */
   rtx pattern_regs;		/* List of registers mentioned by the mem.  */
-  rtx_insn_list *loads;		/* INSN list of loads seen.  */
   rtx_insn_list *stores;	/* INSN list of stores seen.  */
   struct ls_expr * next;	/* Next in the list.  */
   int invalid;			/* Invalid for some reason.  */
@@ -3605,7 +3604,6 @@ ldst_entry (rtx x)
   ptr->expr         = NULL;
   ptr->pattern      = x;
   ptr->pattern_regs = NULL_RTX;
-  ptr->loads        = NULL;
   ptr->stores       = NULL;
   ptr->reaching_reg = NULL_RTX;
   ptr->invalid      = 0;
@@ -3622,7 +3620,6 @@ ldst_entry (rtx x)
 static void
 free_ldst_entry (struct ls_expr * ptr)
 {
-  free_INSN_LIST_list (& ptr->loads);
   free_INSN_LIST_list (& ptr->stores);
 
   free (ptr);
@@ -3663,13 +3660,6 @@ print_ldst_list (FILE * file)
 
       print_rtl (file, ptr->pattern);
 
-      fprintf (file, "\n	 Loads : ");
-
-      if (ptr->loads)
-	print_rtl (file, ptr->loads);
-      else
-	fprintf (file, "(nil)");
-
       fprintf (file, "\n	Stores : ");
 
       if (ptr->stores)
@@ -3801,9 +3791,7 @@ compute_ld_motion_mems (void)
 		  if (MEM_P (src) && simple_mem (src))
 		    {
 		      ptr = ldst_entry (src);
-		      if (REG_P (dest))
-			ptr->loads = alloc_INSN_LIST (insn, ptr->loads);
-		      else
+		      if (!REG_P (dest))
 			ptr->invalid = 1;
 		    }
 		  else
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 13/18] haifa-sched.c: make twins a auto_vec<rtx_insn *>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (2 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 16/18] make forced labels a vec tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20  6:18 ` [PATCH 15/18] make nonlocal_goto_handler_labels a vec tbsaunde+gcc
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* haifa-sched.c (add_to_speculative_block): Make twins a vector.
---
 gcc/haifa-sched.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 0721ec5..34c5cc5 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -7973,7 +7973,7 @@ add_to_speculative_block (rtx_insn *insn)
   ds_t ts;
   sd_iterator_def sd_it;
   dep_t dep;
-  rtx_insn_list *twins = NULL;
+  auto_vec<rtx_insn *, 10> twins;
   rtx_vec_t priorities_roots;
 
   ts = TODO_SPEC (insn);
@@ -8043,7 +8043,7 @@ add_to_speculative_block (rtx_insn *insn)
         fprintf (spec_info->dump, ";;\t\tGenerated twin insn : %d/rec%d\n",
                  INSN_UID (twin), rec->index);
 
-      twins = alloc_INSN_LIST (twin, twins);
+      twins.safe_push (twin);
 
       /* Add dependences between TWIN and all appropriate
 	 instructions from REC.  */
@@ -8082,23 +8082,14 @@ add_to_speculative_block (rtx_insn *insn)
 
   /* We couldn't have added the dependencies between INSN and TWINS earlier
      because that would make TWINS appear in the INSN_BACK_DEPS (INSN).  */
-  while (twins)
+  unsigned int len = twins.length ();
+  for (unsigned int i = len - 1; i < len; i--)
     {
-      rtx_insn *twin;
-      rtx_insn_list *next_node;
-
-      twin = twins->insn ();
-
-      {
-	dep_def _new_dep, *new_dep = &_new_dep;
+      rtx_insn *twin = twins[i];
+      dep_def _new_dep, *new_dep = &_new_dep;
 
-	init_dep (new_dep, insn, twin, REG_DEP_OUTPUT);
-	sd_add_dep (new_dep, false);
-      }
-
-      next_node = twins->next ();
-      free_INSN_LIST_node (twins);
-      twins = next_node;
+      init_dep (new_dep, insn, twin, REG_DEP_OUTPUT);
+      sd_add_dep (new_dep, false);
     }
 
   calc_priorities (priorities_roots);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 15/18] make nonlocal_goto_handler_labels a vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (3 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 13/18] haifa-sched.c: make twins a auto_vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20 12:36   ` Segher Boessenkool
  2016-04-25 12:43   ` Bernd Schmidt
  2016-04-20  6:18 ` [PATCH 05/18] make stores rtx_insn_list " tbsaunde+gcc
                   ` (13 subsequent siblings)
  18 siblings, 2 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* builtins.c (expand_builtin): Adjust.
	* cfgbuild.c (make_edges): Likewise.
	* cfgrtl.c (delete_insn): Likewise.
	(cfg_layout_initialize): Likewise.
	* dwarf2cfi.c (create_trace_edges): Likewise.
	* emit-rtl.h (struct GTY): Make nonlocal_goto_handler_labels a
	vector.
	* recog.c (peep2_attempt): Adjust.
	* reload1.c (set_initial_label_offsets): Likewise.
	* sched-rgn.c (is_cfg_nonregular): Likewise.
	* stmt.c (expand_label): Likewise.
---
 gcc/builtins.c  |  4 +---
 gcc/cfgbuild.c  |  8 ++++----
 gcc/cfgrtl.c    | 21 ++++++++++++---------
 gcc/dwarf2cfi.c | 10 ++++++----
 gcc/emit-rtl.h  |  2 +-
 gcc/recog.c     |  2 +-
 gcc/reload1.c   |  7 ++++---
 gcc/sched-rgn.c |  2 +-
 gcc/stmt.c      |  4 +---
 9 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 3d89baf..9e6c08d 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -6018,9 +6018,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
 
 	  /* This is copied from the handling of non-local gotos.  */
 	  expand_builtin_setjmp_setup (buf_addr, label_r);
-	  nonlocal_goto_handler_labels
-	    = gen_rtx_INSN_LIST (VOIDmode, label_r,
-				 nonlocal_goto_handler_labels);
+	  vec_safe_push (nonlocal_goto_handler_labels, label_r);
 	  /* ??? Do not let expand_label treat us as such since we would
 	     not want to be both on the list of non-local labels and on
 	     the list of forced labels.  */
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index c1ec46a..bffb07b 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -333,10 +333,10 @@ make_edges (basic_block min, basic_block max, int update_p)
 		     taken, then only calls to those functions or to other
 		     nested functions that use them could possibly do
 		     nonlocal gotos.  */
-		  for (rtx_insn_list *x = nonlocal_goto_handler_labels;
-		       x;
-		       x = x->next ())
-		    make_label_edge (edge_cache, bb, x->insn (),
+		  rtx_insn *insn;
+		  unsigned int i;
+		  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, insn)
+		    make_label_edge (edge_cache, bb, insn,
 				     EDGE_ABNORMAL | EDGE_ABNORMAL_CALL);
 		}
 
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 62b0596..7cfc634 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -157,7 +157,14 @@ delete_insn (rtx uncast_insn)
 	    }
 	}
 
-      remove_node_from_insn_list (insn, &nonlocal_goto_handler_labels);
+
+      unsigned int len = vec_safe_length (nonlocal_goto_handler_labels);
+      for (unsigned int i = 0; i < len; i++)
+	if ((*nonlocal_goto_handler_labels)[i] == insn)
+	  {
+	    nonlocal_goto_handler_labels->ordered_remove (i);
+	    break;
+	  }
     }
 
   if (really_delete)
@@ -4236,9 +4243,6 @@ cfg_layout_duplicate_bb (basic_block bb)
 void
 cfg_layout_initialize (unsigned int flags)
 {
-  rtx_insn_list *x;
-  basic_block bb;
-
   /* Once bb partitioning is complete, cfg layout mode should not be
      re-entered.  Entering cfg layout mode may require fixups.  As an
      example, if edge forwarding performed when optimizing the cfg
@@ -4255,11 +4259,10 @@ cfg_layout_initialize (unsigned int flags)
   record_effective_endpoints ();
 
   /* Make sure that the targets of non local gotos are marked.  */
-  for (x = nonlocal_goto_handler_labels; x; x = x->next ())
-    {
-      bb = BLOCK_FOR_INSN (x->insn ());
-      bb->flags |= BB_NON_LOCAL_GOTO_TARGET;
-    }
+  rtx_insn *temp;
+  unsigned int i;
+  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, temp)
+      BLOCK_FOR_INSN (temp)->flags |= BB_NON_LOCAL_GOTO_TARGET;
 
   cleanup_cfg (CLEANUP_CFGLAYOUT | flags);
 }
diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index bcf79f5..6180da4 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -2384,10 +2384,12 @@ create_trace_edges (rtx_insn *insn)
 
       /* Process non-local goto edges.  */
       if (can_nonlocal_goto (insn))
-	for (rtx_insn_list *lab = nonlocal_goto_handler_labels;
-	     lab;
-	     lab = lab->next ())
-	  maybe_record_trace_start_abnormal (lab->insn (), insn);
+	{
+	  rtx_insn *temp;
+	  unsigned int i;
+	  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, temp)
+	    maybe_record_trace_start_abnormal (temp, insn);
+	}
     }
   else if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (PATTERN (insn)))
     {
diff --git a/gcc/emit-rtl.h b/gcc/emit-rtl.h
index 39dfce9..745e25e 100644
--- a/gcc/emit-rtl.h
+++ b/gcc/emit-rtl.h
@@ -90,7 +90,7 @@ struct GTY(()) rtl_data {
 
   /* List (chain of INSN_LIST) of labels heading the current handlers for
      nonlocal gotos.  */
-  rtx_insn_list *x_nonlocal_goto_handler_labels;
+  vec<rtx_insn *, va_gc> *x_nonlocal_goto_handler_labels;
 
   /* Label that will go on function epilogue.
      Jumping to this label serves as a "return" instruction
diff --git a/gcc/recog.c b/gcc/recog.c
index 92b2aa3..587b3e4 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -3409,7 +3409,7 @@ peep2_attempt (basic_block bb, rtx_insn *insn, int match_len, rtx_insn *attempt)
   delete_insn_chain (insn, peep2_insn_data[i].insn, false);
 
   /* Re-insert the EH_REGION notes.  */
-  if (eh_note || (was_call && nonlocal_goto_handler_labels))
+  if (eh_note || (was_call && vec_safe_length (nonlocal_goto_handler_labels)))
     {
       edge eh_edge;
       edge_iterator ei;
diff --git a/gcc/reload1.c b/gcc/reload1.c
index d0084ac..770bf40 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -3877,9 +3877,10 @@ set_initial_label_offsets (void)
     if (x->insn ())
       set_label_offsets (x->insn (), NULL, 1);
 
-  for (rtx_insn_list *x = nonlocal_goto_handler_labels; x; x = x->next ())
-    if (x->insn ())
-      set_label_offsets (x->insn (), NULL, 1);
+  rtx_insn *insn;
+  unsigned int i;
+  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, insn)
+      set_label_offsets (insn, NULL, 1);
 
   for_each_eh_label (set_initial_eh_label_offset);
 }
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index fa662ff..d4b71a1 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -259,7 +259,7 @@ is_cfg_nonregular (void)
 
   /* If we have a label that could be the target of a nonlocal goto, then
      the cfg is not well structured.  */
-  if (nonlocal_goto_handler_labels)
+  if (vec_safe_length (nonlocal_goto_handler_labels))
     return 1;
 
   /* If we have any forced labels, then the cfg is not well structured.  */
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 2e9072f..a6612fc 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -184,9 +184,7 @@ expand_label (tree label)
   if (DECL_NONLOCAL (label))
     {
       expand_builtin_setjmp_receiver (NULL);
-      nonlocal_goto_handler_labels
-	= gen_rtx_INSN_LIST (VOIDmode, label_r,
-			     nonlocal_goto_handler_labels);
+      vec_safe_push<rtx_insn *> (nonlocal_goto_handler_labels, label_r);
     }
 
   if (FORCED_LABEL (label))
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 02/18] make avail_stores a vec<rtx_insn *>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (9 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 07/18] loop-iv.c: make cond_list a vec tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20 11:32   ` Segher Boessenkool
                     ` (2 more replies)
  2016-04-20  6:18 ` [PATCH 09/18] make pattern_regs a vec tbsaunde+gcc
                   ` (7 subsequent siblings)
  18 siblings, 3 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* print-rtl.c (print_rtx_insn_vec): New function.
	* print-rtl.h: New prototype.
	* rtl.h: Likewise.
	* 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.
---
 gcc/print-rtl.c    | 15 +++++++++++++++
 gcc/print-rtl.h    |  1 +
 gcc/rtl.h          |  1 +
 gcc/store-motion.c | 31 +++++++++++++++----------------
 4 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 85d9b8d..cf4922f 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -870,6 +870,21 @@ print_simple_rtl (FILE *outf, const_rtx x)
   flag_simple = 0;
 }
 
+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
diff --git a/gcc/print-rtl.h b/gcc/print-rtl.h
index 28b4626..e585a63 100644
--- a/gcc/print-rtl.h
+++ b/gcc/print-rtl.h
@@ -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 *);
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 8267252..167c090 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3572,6 +3572,7 @@ extern void print_simple_rtl (FILE *, const_rtx);
 extern int print_rtl_single (FILE *, const_rtx);
 extern int print_rtl_single_with_indent (FILE *, const_rtx, int);
 extern void print_inline_rtx (FILE *, const_rtx, int);
+extern void print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec);
 
 /* In stmt.c */
 extern void expand_null_return (void);
diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index fffdffc..6646065 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -67,7 +67,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 +148,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 +164,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 +240,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 +588,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 +616,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 +694,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 +978,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 +1016,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 +1031,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);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 05/18] make stores rtx_insn_list a vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (4 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 15/18] make nonlocal_goto_handler_labels a vec tbsaunde+gcc
@ 2016-04-20  6:18 ` tbsaunde+gcc
  2016-04-20 11:45   ` Segher Boessenkool
  2016-04-20  6:18 ` [PATCH 08/18] make side_effects a vec<rtx> tbsaunde+gcc
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:18 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* gcse.c (struct ls_expr): make stores field a vector.
	(ldst_entry): Adjust.
	(free_ldst_entry): Likewise.
	(print_ldst_list): Likewise.
	(compute_ld_motion_mems): Likewise.
	(update_ld_motion_stores): Likewise.
---
 gcc/gcse.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/gcc/gcse.c b/gcc/gcse.c
index 127a65a..e7ffa8b 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -342,7 +342,7 @@ struct ls_expr
   struct gcse_expr * expr;	/* Gcse expression reference for LM.  */
   rtx pattern;			/* Pattern of this mem.  */
   rtx pattern_regs;		/* List of registers mentioned by the mem.  */
-  rtx_insn_list *stores;	/* INSN list of stores seen.  */
+  vec<rtx_insn *> stores;	/* INSN list of stores seen.  */
   struct ls_expr * next;	/* Next in the list.  */
   int invalid;			/* Invalid for some reason.  */
   int index;			/* If it maps to a bitmap index.  */
@@ -3604,7 +3604,7 @@ ldst_entry (rtx x)
   ptr->expr         = NULL;
   ptr->pattern      = x;
   ptr->pattern_regs = NULL_RTX;
-  ptr->stores       = NULL;
+  ptr->stores      .create (0);
   ptr->reaching_reg = NULL_RTX;
   ptr->invalid      = 0;
   ptr->index        = 0;
@@ -3620,7 +3620,7 @@ ldst_entry (rtx x)
 static void
 free_ldst_entry (struct ls_expr * ptr)
 {
-  free_INSN_LIST_list (& ptr->stores);
+   ptr->stores.release ();
 
   free (ptr);
 }
@@ -3661,11 +3661,7 @@ print_ldst_list (FILE * file)
       print_rtl (file, ptr->pattern);
 
       fprintf (file, "\n	Stores : ");
-
-      if (ptr->stores)
-	print_rtl (file, ptr->stores);
-      else
-	fprintf (file, "(nil)");
+      print_rtx_insn_vec (file, ptr->stores);
 
       fprintf (file, "\n\n");
     }
@@ -3822,7 +3818,7 @@ compute_ld_motion_mems (void)
 			     returns 0 for all REGs.  */
 			  && can_assign_to_reg_without_clobbers_p (src,
 								    src_mode))
-			ptr->stores = alloc_INSN_LIST (insn, ptr->stores);
+			ptr->stores.safe_push (insn);
 		      else
 			ptr->invalid = 1;
 		    }
@@ -3915,11 +3911,10 @@ update_ld_motion_stores (struct gcse_expr * expr)
 	 where reg is the reaching reg used in the load.  We checked in
 	 compute_ld_motion_mems that we can replace (set mem expr) with
 	 (set reg expr) in that insn.  */
-      rtx list = mem_ptr->stores;
-
-      for ( ; list != NULL_RTX; list = XEXP (list, 1))
+      rtx_insn *insn;
+      unsigned int i;
+      FOR_EACH_VEC_ELT_REVERSE (mem_ptr->stores, i, insn)
 	{
-	  rtx_insn *insn = as_a <rtx_insn *> (XEXP (list, 0));
 	  rtx pat = PATTERN (insn);
 	  rtx src = SET_SRC (pat);
 	  rtx reg = expr->reaching_reg;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (12 preceding siblings ...)
  2016-04-20  6:19 ` [PATCH 06/18] move reg_equivs out of gc memory tbsaunde+gcc
@ 2016-04-20  6:19 ` tbsaunde+gcc
  2016-04-20 12:17   ` Segher Boessenkool
  2016-04-20  6:19 ` [PATCH 11/18] add some utility methods to vec tbsaunde+gcc
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* config/alpha/alpha.c (alpha_adjust_cost): Adjust.
	* config/arm/arm-protos.h (struct tune_params): Likewise.
	* config/arm/arm.c (xscale_sched_adjust_cost): Likewise.
	(cortex_a9_sched_adjust_cost): Likewise.
	(fa726te_sched_adjust_cost): Likewise.
	(arm_adjust_cost): Likewise.
	* config/bfin/bfin.c (bfin_adjust_cost): Likewise.
	* config/c6x/c6x.c (c6x_adjust_cost): Likewise.
	* config/epiphany/epiphany.c (epiphany_adjust_cost): Likewise.
	* config/i386/i386.c (ix86_adjust_cost): Likewise.
	* config/ia64/ia64.c: Likewise.
	* config/m68k/m68k.c: Likewise.
	* config/mep/mep.c (mep_adjust_cost): Likewise.
	* config/microblaze/microblaze.c (microblaze_adjust_cost):
	* Likewise.
	* config/mips/mips.c (mips_adjust_cost): Likewise.
	* config/mn10300/mn10300.c (mn10300_adjust_sched_cost):
	* Likewise.
	* config/pa/pa.c (pa_adjust_cost): Likewise.
	* config/rs6000/rs6000.c (rs6000_adjust_cost): Likewise.
	(rs6000_debug_adjust_cost): Likewise.
	* config/sh/sh.c (sh_adjust_cost): Likewise.
	* config/sparc/sparc.c (supersparc_adjust_cost): Likewise.
	(hypersparc_adjust_cost): Likewise.
	(sparc_adjust_cost): Likewise.
	* config/spu/spu.c (spu_sched_adjust_cost): Likewise.
	* config/tilegx/tilegx.c (tilegx_sched_adjust_cost): Likewise.
	* config/tilepro/tilepro.c (tilepro_sched_adjust_cost):
	* Likewise.
	* config/visium/visium.c (visium_adjust_cost): Likewise.
	* doc/tm.texi: Regenerate.
	* haifa-sched.c (dep_cost_1): Adjust.
	* target.def: Merge adjust_cost and adjust_cost_2.
---
 gcc/config/alpha/alpha.c           |  5 +++--
 gcc/config/arm/arm-protos.h        |  2 +-
 gcc/config/arm/arm.c               | 40 +++++++++++++++++++++-----------------
 gcc/config/bfin/bfin.c             |  5 +++--
 gcc/config/c6x/c6x.c               |  5 +++--
 gcc/config/epiphany/epiphany.c     |  5 +++--
 gcc/config/i386/i386.c             |  5 +++--
 gcc/config/ia64/ia64.c             | 10 +++++-----
 gcc/config/m68k/m68k.c             |  7 ++++---
 gcc/config/mep/mep.c               |  9 +++++----
 gcc/config/microblaze/microblaze.c | 10 ++++------
 gcc/config/mips/mips.c             |  8 ++------
 gcc/config/mn10300/mn10300.c       |  5 +++--
 gcc/config/pa/pa.c                 |  9 +++++----
 gcc/config/rs6000/rs6000.c         | 16 ++++++++-------
 gcc/config/sh/sh.c                 | 14 ++++++-------
 gcc/config/sparc/sparc.c           | 23 ++++++++++++----------
 gcc/config/spu/spu.c               |  5 +++--
 gcc/config/tilegx/tilegx.c         |  6 +++---
 gcc/config/tilepro/tilepro.c       |  6 +++---
 gcc/config/visium/visium.c         | 11 ++++++-----
 gcc/doc/tm.texi                    | 14 ++++++-------
 gcc/haifa-sched.c                  | 25 +++---------------------
 gcc/target.def                     | 25 +++++++++---------------
 24 files changed, 129 insertions(+), 141 deletions(-)

diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index e023d3b..09c6ac7 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -4758,14 +4758,15 @@ alpha_split_atomic_exchange_12 (rtx operands[])
    a dependency LINK or INSN on DEP_INSN.  COST is the current cost.  */
 
 static int
-alpha_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+alpha_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		   unsigned int)
 {
   enum attr_type dep_insn_type;
 
   /* If the dependence is an anti-dependence, there is no cost.  For an
      output dependence, there is sometimes a cost, but it doesn't seem
      worth handling those few cases.  */
-  if (REG_NOTE_KIND (link) != 0)
+  if (dep_type != 0)
     return cost;
 
   /* If we can't recognize the insns, we can't really do anything.  */
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 0083673..31c9d0e 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -258,7 +258,7 @@ struct tune_params
 {
   bool (*rtx_costs) (rtx, RTX_CODE, RTX_CODE, int *, bool);
   const struct cpu_cost_table *insn_extra_cost;
-  bool (*sched_adjust_cost) (rtx_insn *, rtx, rtx_insn *, int *);
+  bool (*sched_adjust_cost) (rtx_insn *, int, rtx_insn *, int *);
   int (*branch_cost) (bool, bool);
   /* Vectorizer costs.  */
   const struct cpu_vec_costs* vec_costs;
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4d9f6f1..0a14ca1 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -139,7 +139,7 @@ static void arm_output_function_epilogue (FILE *, HOST_WIDE_INT);
 static void arm_output_function_prologue (FILE *, HOST_WIDE_INT);
 static int arm_comp_type_attributes (const_tree, const_tree);
 static void arm_set_default_type_attributes (tree);
-static int arm_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int arm_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int);
 static int arm_sched_reorder (FILE *, int, rtx_insn **, int *, int);
 static int optimal_immediate_sequence (enum rtx_code code,
 				       unsigned HOST_WIDE_INT val,
@@ -260,9 +260,9 @@ static void arm_asm_trampoline_template (FILE *);
 static void arm_trampoline_init (rtx, tree, rtx);
 static rtx arm_trampoline_adjust_address (rtx);
 static rtx arm_pic_static_addr (rtx orig, rtx reg);
-static bool cortex_a9_sched_adjust_cost (rtx_insn *, rtx, rtx_insn *, int *);
-static bool xscale_sched_adjust_cost (rtx_insn *, rtx, rtx_insn *, int *);
-static bool fa726te_sched_adjust_cost (rtx_insn *, rtx, rtx_insn *, int *);
+static bool cortex_a9_sched_adjust_cost (rtx_insn *, int, rtx_insn *, int *);
+static bool xscale_sched_adjust_cost (rtx_insn *, int, rtx_insn *, int *);
+static bool fa726te_sched_adjust_cost (rtx_insn *, int, rtx_insn *, int *);
 static bool arm_array_mode_supported_p (machine_mode,
 					unsigned HOST_WIDE_INT);
 static machine_mode arm_preferred_simd_mode (machine_mode);
@@ -11588,11 +11588,12 @@ arm_address_cost (rtx x, machine_mode mode ATTRIBUTE_UNUSED,
 
 /* Adjust cost hook for XScale.  */
 static bool
-xscale_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost)
+xscale_sched_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep,
+			  int * cost)
 {
   /* Some true dependencies can have a higher cost depending
      on precisely how certain input operands are used.  */
-  if (REG_NOTE_KIND(link) == 0
+  if (dep_type == 0
       && recog_memoized (insn) >= 0
       && recog_memoized (dep) >= 0)
     {
@@ -11649,9 +11650,10 @@ xscale_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost)
 
 /* Adjust cost hook for Cortex A9.  */
 static bool
-cortex_a9_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost)
+cortex_a9_sched_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep,
+			     int * cost)
 {
-  switch (REG_NOTE_KIND (link))
+  switch (dep_type)
     {
     case REG_DEP_ANTI:
       *cost = 0;
@@ -11691,7 +11693,7 @@ cortex_a9_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost
 			    && (attr_type_dep == TYPE_FMACS
 				|| attr_type_dep == TYPE_FMACD))
 			  {
-			    if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT)
+			    if (dep_type == REG_DEP_OUTPUT)
 			      *cost = insn_default_latency (dep) - 3;
 			    else
 			      *cost = insn_default_latency (dep);
@@ -11699,7 +11701,7 @@ cortex_a9_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost
 			  }
 			else
 			  {
-			    if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT)
+			    if (dep_type == REG_DEP_OUTPUT)
 			      *cost = insn_default_latency (dep) + 1;
 			    else
 			      *cost = insn_default_latency (dep);
@@ -11720,11 +11722,12 @@ cortex_a9_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost
 
 /* Adjust cost hook for FA726TE.  */
 static bool
-fa726te_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int * cost)
+fa726te_sched_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep,
+			   int * cost)
 {
   /* For FA726TE, true dependency on CPSR (i.e. set cond followed by predicated)
      have penalty of 3.  */
-  if (REG_NOTE_KIND (link) == REG_DEP_TRUE
+  if (dep_type == REG_DEP_TRUE
       && recog_memoized (insn) >= 0
       && recog_memoized (dep) >= 0
       && get_attr_conds (dep) == CONDS_SET)
@@ -12068,7 +12071,8 @@ arm_sched_reorder (FILE *file, int verbose, rtx_insn **ready, int *n_readyp,
    adjust_cost function. Only put bits of code into arm_adjust_cost that
    are common across all cores.  */
 static int
-arm_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int cost)
+arm_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep, int cost,
+		 unsigned int)
 {
   rtx i_pat, d_pat;
 
@@ -12076,7 +12080,7 @@ arm_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int cost)
     close to a conditional branch which depends on them, so that we can
     omit the comparison. */
   if (TARGET_THUMB1
-      && REG_NOTE_KIND (link) == 0
+      && dep_type == 0
       && recog_memoized (insn) == CODE_FOR_cbranchsi4_insn
       && recog_memoized (dep) >= 0
       && get_attr_conds (dep) == CONDS_SET)
@@ -12084,17 +12088,17 @@ arm_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int cost)
 
   if (current_tune->sched_adjust_cost != NULL)
     {
-      if (!current_tune->sched_adjust_cost (insn, link, dep, &cost))
+      if (!current_tune->sched_adjust_cost (insn, dep_type, dep, &cost))
 	return cost;
     }
 
   /* XXX Is this strictly true?  */
-  if (REG_NOTE_KIND (link) == REG_DEP_ANTI
-      || REG_NOTE_KIND (link) == REG_DEP_OUTPUT)
+  if (dep_type == REG_DEP_ANTI
+      || dep_type == REG_DEP_OUTPUT)
     return 0;
 
   /* Call insns don't incur a stall, even if they follow a load.  */
-  if (REG_NOTE_KIND (link) == 0
+  if (dep_type == 0
       && CALL_P (insn))
     return 1;
 
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 75ddcf0..51a53dd 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3301,13 +3301,14 @@ bfin_issue_rate (void)
 }
 
 static int
-bfin_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+bfin_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		  unsigned int)
 {
   enum attr_type dep_insn_type;
   int dep_insn_code_number;
 
   /* Anti and output dependencies have zero cost.  */
-  if (REG_NOTE_KIND (link) != 0)
+  if (dep_type != 0)
     return 0;
 
   dep_insn_code_number = recog_memoized (dep_insn);
diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index 4cbe63c..d759482 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -4471,7 +4471,8 @@ c6x_variable_issue (FILE *dump ATTRIBUTE_UNUSED,
    anti- and output dependencies.  */
 
 static int
-c6x_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+c6x_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		 unsigned int)
 {
   enum attr_type insn_type = TYPE_UNKNOWN, dep_insn_type = TYPE_UNKNOWN;
   int dep_insn_code_number, insn_code_number;
@@ -4486,7 +4487,7 @@ c6x_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
   if (insn_code_number >= 0)
     insn_type = get_attr_type (insn);
 
-  kind = REG_NOTE_KIND (link);
+  kind = (reg_note) dep_type;
   if (kind == 0)
     {
       /* If we have a dependency on a load, and it's not for the result of
diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c
index f09a657..25cbdfc 100644
--- a/gcc/config/epiphany/epiphany.c
+++ b/gcc/config/epiphany/epiphany.c
@@ -1983,9 +1983,10 @@ epiphany_issue_rate (void)
    the same cost as a data-dependence.  The return value should be
    the new value for COST.  */
 static int
-epiphany_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+epiphany_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn,
+		      int cost, unsigned int)
 {
-  if (REG_NOTE_KIND (link) == 0)
+  if (dep_type == 0)
     {
       rtx dep_set;
 
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 0687701..a81f15a 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -27924,7 +27924,8 @@ exact_store_load_dependency (rtx_insn *store, rtx_insn *load)
 }
 
 static int
-ix86_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+ix86_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		  unsigned int)
 {
   enum attr_type insn_type, dep_insn_type;
   enum attr_memory memory;
@@ -27932,7 +27933,7 @@ ix86_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
   int dep_insn_code_number;
 
   /* Anti and output dependencies have zero cost on all CPUs.  */
-  if (REG_NOTE_KIND (link) != 0)
+  if (dep_type != 0)
     return 0;
 
   dep_insn_code_number = recog_memoized (dep_insn);
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 3fcc3b5..ea6309b 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -240,7 +240,7 @@ static void ia64_print_operand_address (FILE *, machine_mode, rtx);
 static bool ia64_print_operand_punct_valid_p (unsigned char code);
 
 static int ia64_issue_rate (void);
-static int ia64_adjust_cost_2 (rtx_insn *, int, rtx_insn *, int, dw_t);
+static int ia64_adjust_cost (rtx_insn *, int, rtx_insn *, int, dw_t);
 static void ia64_sched_init (FILE *, int, int);
 static void ia64_sched_init_global (FILE *, int, int);
 static void ia64_sched_finish_global (FILE *, int);
@@ -415,8 +415,8 @@ static const struct attribute_spec ia64_attribute_table[] =
 #undef TARGET_IN_SMALL_DATA_P
 #define TARGET_IN_SMALL_DATA_P  ia64_in_small_data_p
 
-#undef TARGET_SCHED_ADJUST_COST_2
-#define TARGET_SCHED_ADJUST_COST_2 ia64_adjust_cost_2
+#undef TARGET_SCHED_ADJUST_COST
+#define TARGET_SCHED_ADJUST_COST ia64_adjust_cost
 #undef TARGET_SCHED_ISSUE_RATE
 #define TARGET_SCHED_ISSUE_RATE ia64_issue_rate
 #undef TARGET_SCHED_VARIABLE_ISSUE
@@ -7185,8 +7185,8 @@ ia64_single_set (rtx_insn *insn)
    Return the new cost of a dependency of type DEP_TYPE or INSN on DEP_INSN.
    COST is the current cost, DW is dependency weakness.  */
 static int
-ia64_adjust_cost_2 (rtx_insn *insn, int dep_type1, rtx_insn *dep_insn,
-		    int cost, dw_t dw)
+ia64_adjust_cost (rtx_insn *insn, int dep_type1, rtx_insn *dep_insn,
+		  int cost, dw_t dw)
 {
   enum reg_note dep_type = (enum reg_note) dep_type1;
   enum attr_itanium_class dep_class;
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index 03f474e..7cee0f5 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -138,7 +138,8 @@ struct m68k_address {
   int scale;
 };
 
-static int m68k_sched_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int m68k_sched_adjust_cost (rtx_insn *, int, rtx_insn *, int,
+				   unsigned int);
 static int m68k_sched_issue_rate (void);
 static int m68k_sched_variable_issue (FILE *, int, rtx_insn *, int);
 static void m68k_sched_md_init_global (FILE *, int, int);
@@ -5917,8 +5918,8 @@ static state_t sched_adjust_cost_state;
 /* Implement adjust_cost scheduler hook.
    Return adjusted COST of dependency LINK between DEF_INSN and INSN.  */
 static int
-m68k_sched_adjust_cost (rtx_insn *insn, rtx link ATTRIBUTE_UNUSED,
-			rtx_insn *def_insn, int cost)
+m68k_sched_adjust_cost (rtx_insn *insn, int, rtx_insn *def_insn, int cost,
+			unsigned int)
 {
   int delay;
 
diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c
index 9c4cd86..fad8397 100644
--- a/gcc/config/mep/mep.c
+++ b/gcc/config/mep/mep.c
@@ -205,7 +205,7 @@ static rtx mep_convert_regnum (const struct cgen_regnum_operand *, rtx);
 static rtx mep_legitimize_arg (const struct insn_operand_data *, rtx, int);
 static void mep_incompatible_arg (const struct insn_operand_data *, rtx, int, tree);
 static rtx mep_expand_builtin (tree, rtx, rtx, machine_mode, int);
-static int mep_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int mep_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int);
 static int mep_issue_rate (void);
 static rtx_insn *mep_find_ready_insn (rtx_insn **, int, enum attr_slot, int);
 static void mep_move_ready_insn (rtx_insn **, int, rtx_insn *);
@@ -6418,11 +6418,12 @@ global_reg_mentioned_p (rtx x)
    insns.  Not implemented.  */
 
 static int
-mep_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+mep_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		 unsigned int)
 {
   int cost_specified;
 
-  if (REG_NOTE_KIND (link) != 0)
+  if (dep_type != 0)
     {
       /* See whether INSN and DEP_INSN are intrinsics that set the same
 	 hard register.  If so, it is more important to free up DEP_INSN
@@ -6438,7 +6439,7 @@ mep_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 	 In contrast, mep_mulr() sets both $lo and $hi to specific values,
 	 so any pair of mep_mulr()s will be inter-dependent.   We should
 	 therefore give the first mep_mulr() a higher priority.  */
-      if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT
+      if (dep_type == REG_DEP_OUTPUT
 	  && global_reg_mentioned_p (PATTERN (insn))
 	  && global_reg_mentioned_p (PATTERN (dep_insn)))
 	return 1;
diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index baff67a..2ee61e3 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -3561,14 +3561,12 @@ microblaze_function_value (const_tree valtype,
 
 /* Implement TARGET_SCHED_ADJUST_COST.  */
 static int
-microblaze_adjust_cost (rtx_insn *insn ATTRIBUTE_UNUSED, rtx link,
-			rtx_insn *dep ATTRIBUTE_UNUSED, int cost)
+microblaze_adjust_cost (rtx_insn *, int dep_type, rtx_insn *, int cost,
+			unsigned int)
 {
-  if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT)
+  if (dep_type == REG_DEP_OUTPUT || dep_type == 0)
     return cost;
-  if (REG_NOTE_KIND (link) != 0)
-    return 0;
-  return cost;
+  return 0;
 }
 
 /* Implement TARGET_LEGITIMATE_CONSTANT_P.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 399f231..d70b7e7 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -13834,13 +13834,9 @@ static struct
    is treated like input-dependence.  */
 
 static int
-mips_adjust_cost (rtx_insn *insn ATTRIBUTE_UNUSED, rtx link,
-		  rtx_insn *dep ATTRIBUTE_UNUSED, int cost)
+mips_adjust_cost (rtx_insn *, int dep_type, rtx_insn *, int cost, unsigned int)
 {
-  if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT
-      && TUNE_20KC)
-    return cost;
-  if (REG_NOTE_KIND (link) != 0)
+  if (dep_type != 0 && (dep_type != REG_DEP_OUTPUT || !TUNE_20KC))
     return 0;
   return cost;
 }
diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c
index 71815d6..6e590cd 100644
--- a/gcc/config/mn10300/mn10300.c
+++ b/gcc/config/mn10300/mn10300.c
@@ -2758,7 +2758,8 @@ set_is_store_p (rtx set)
    COST is the current cycle cost for DEP.  */
 
 static int
-mn10300_adjust_sched_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int cost)
+mn10300_adjust_sched_cost (rtx_insn *insn, int dep_type, rtx_insn *dep,
+			   int cost, unsigned int)
 {
   rtx insn_set;
   rtx dep_set;
@@ -2807,7 +2808,7 @@ mn10300_adjust_sched_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int cost)
     return cost;
 
   /* If a data dependence already exists then the cost is correct.  */
-  if (REG_NOTE_KIND (link) == 0)
+  if (dep_type == 0)
     return cost;
 
   /* Check that the instruction about to scheduled is an FPU instruction.  */
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index 8b1c832..d59c8db 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -117,7 +117,7 @@ static bool pa_function_value_regno_p (const unsigned int);
 static void pa_output_function_prologue (FILE *, HOST_WIDE_INT);
 static void update_total_code_bytes (unsigned int);
 static void pa_output_function_epilogue (FILE *, HOST_WIDE_INT);
-static int pa_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int pa_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int);
 static int pa_adjust_priority (rtx_insn *, int);
 static int pa_issue_rate (void);
 static int pa_reloc_rw_mask (void);
@@ -4749,13 +4749,14 @@ pa_emit_bcond_fp (rtx operands[])
    a dependency LINK or INSN on DEP_INSN.  COST is the current cost.  */
 
 static int
-pa_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+pa_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		unsigned int)
 {
   enum attr_type attr_type;
 
   /* Don't adjust costs for a pa8000 chip, also do not adjust any
      true dependencies as they are described with bypasses now.  */
-  if (pa_cpu >= PROCESSOR_8000 || REG_NOTE_KIND (link) == 0)
+  if (pa_cpu >= PROCESSOR_8000 || dep_type == 0)
     return cost;
 
   if (! recog_memoized (insn))
@@ -4763,7 +4764,7 @@ pa_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 
   attr_type = get_attr_type (insn);
 
-  switch (REG_NOTE_KIND (link))
+  switch (dep_type)
     {
     case REG_DEP_ANTI:
       /* Anti dependency; DEP_INSN reads a register that INSN writes some
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1d0076c..653865b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1214,7 +1214,8 @@ static int rs6000_memory_move_cost (machine_mode, reg_class_t, bool);
 static bool rs6000_debug_rtx_costs (rtx, machine_mode, int, int, int *, bool);
 static int rs6000_debug_address_cost (rtx, machine_mode, addr_space_t,
 				      bool);
-static int rs6000_debug_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int rs6000_debug_adjust_cost (rtx_insn *, int, rtx_insn *, int,
+				     unsigned int);
 static bool is_microcoded_insn (rtx_insn *);
 static bool is_nonpipeline_insn (rtx_insn *);
 static bool is_cracked_insn (rtx_insn *);
@@ -28829,14 +28830,15 @@ rs6000_variable_issue (FILE *stream, int verbose, rtx_insn *insn, int more)
    a dependency LINK or INSN on DEP_INSN.  COST is the current cost.  */
 
 static int
-rs6000_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+rs6000_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		    unsigned int)
 {
   enum attr_type attr_type;
 
   if (recog_memoized (insn) < 0 || recog_memoized (dep_insn) < 0)
     return cost;
 
-  switch (REG_NOTE_KIND (link))
+  switch (dep_type)
     {
     case REG_DEP_TRUE:
       {
@@ -29097,16 +29099,16 @@ rs6000_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 /* Debug version of rs6000_adjust_cost.  */
 
 static int
-rs6000_debug_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn,
-			  int cost)
+rs6000_debug_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn,
+			  int cost, unsigned int dw)
 {
-  int ret = rs6000_adjust_cost (insn, link, dep_insn, cost);
+  int ret = rs6000_adjust_cost (insn, dep_type, dep_insn, cost, dw);
 
   if (ret != cost)
     {
       const char *dep;
 
-      switch (REG_NOTE_KIND (link))
+      switch (dep_type)
 	{
 	default:	     dep = "unknown depencency"; break;
 	case REG_DEP_TRUE:   dep = "data dependency";	 break;
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 8c8fe3c..93fb4ae 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -219,7 +219,7 @@ static void sh_output_function_epilogue (FILE *, HOST_WIDE_INT);
 static void sh_insert_attributes (tree, tree *);
 static const char *sh_check_pch_target_flags (int);
 static int sh_register_move_cost (machine_mode, reg_class_t, reg_class_t);
-static int sh_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int sh_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int);
 static int sh_issue_rate (void);
 static int sh_dfa_new_cycle (FILE *, int, rtx_insn *, int, int, int *sort_p);
 static short find_set_regmode_weight (rtx, machine_mode);
@@ -10969,8 +10969,8 @@ sh_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED,
    the same cost as a data-dependence.  The return value should be
    the new value for COST.  */
 static int
-sh_adjust_cost (rtx_insn *insn, rtx link ATTRIBUTE_UNUSED,
-		rtx_insn *dep_insn, int cost)
+sh_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		unsigned int)
 {
   rtx reg, use_pat;
 
@@ -10978,14 +10978,14 @@ sh_adjust_cost (rtx_insn *insn, rtx link ATTRIBUTE_UNUSED,
     {
       /* On SHmedia, if the dependence is an anti-dependence or
          output-dependence, there is no cost.  */
-      if (REG_NOTE_KIND (link) != 0)
+      if (dep_type != 0)
 	{
 	  /* However, dependencies between target register loads and
 	     uses of the register in a subsequent block that are separated
 	     by a conditional branch are not modelled - we have to do with
 	     the anti-dependency between the target register load and the
 	     conditional branch that ends the current block.  */
-	  if (REG_NOTE_KIND (link) == REG_DEP_ANTI
+	  if (dep_type == REG_DEP_ANTI
 	      && GET_CODE (PATTERN (dep_insn)) == SET
 	      && (get_attr_type (dep_insn) == TYPE_PT_MEDIA
 		  || get_attr_type (dep_insn) == TYPE_PTABS_MEDIA)
@@ -11031,7 +11031,7 @@ sh_adjust_cost (rtx_insn *insn, rtx link ATTRIBUTE_UNUSED,
 	       && ! flow_dependent_p (insn, dep_insn))
 	cost--;
     }
-  else if (REG_NOTE_KIND (link) == 0)
+  else if (dep_type == 0)
     {
       enum attr_type type;
       rtx dep_set;
@@ -11150,7 +11150,7 @@ sh_adjust_cost (rtx_insn *insn, rtx link ATTRIBUTE_UNUSED,
   /* An anti-dependence penalty of two applies if the first insn is a double
      precision fadd / fsub / fmul.  */
   else if (!TARGET_SH4_300
-	   && REG_NOTE_KIND (link) == REG_DEP_ANTI
+	   && dep_type == REG_DEP_ANTI
 	   && recog_memoized (dep_insn) >= 0
 	   && (get_attr_type (dep_insn) == TYPE_DFP_ARITH
 	       || get_attr_type (dep_insn) == TYPE_DFP_MUL)
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 082af3c..5be9e16 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -521,8 +521,8 @@ static void sparc_init_modes (void);
 static int function_arg_slotno (const CUMULATIVE_ARGS *, machine_mode,
 				const_tree, bool, bool, int *, int *);
 
-static int supersparc_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
-static int hypersparc_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int supersparc_adjust_cost (rtx_insn *, int, rtx_insn *, int);
+static int hypersparc_adjust_cost (rtx_insn *, int, rtx_insn *, int);
 
 static void sparc_emit_set_const32 (rtx, rtx);
 static void sparc_emit_set_const64 (rtx, rtx);
@@ -541,7 +541,7 @@ static void sparc_asm_function_epilogue (FILE *, HOST_WIDE_INT);
 static void sparc_solaris_elf_asm_named_section (const char *, unsigned int,
 						 tree) ATTRIBUTE_UNUSED;
 #endif
-static int sparc_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int sparc_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int);
 static int sparc_issue_rate (void);
 static void sparc_sched_init (FILE *, int, int);
 static int sparc_use_sched_lookahead (void);
@@ -9251,7 +9251,8 @@ sparc_trampoline_init (rtx m_tramp, tree fndecl, rtx cxt)
    a dependency LINK or INSN on DEP_INSN.  COST is the current cost.  */
 
 static int
-supersparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+supersparc_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn,
+			int cost)
 {
   enum attr_type insn_type;
 
@@ -9260,7 +9261,7 @@ supersparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 
   insn_type = get_attr_type (insn);
 
-  if (REG_NOTE_KIND (link) == 0)
+  if (dep_type == 0)
     {
       /* Data dependency; DEP_INSN writes a register that INSN reads some
 	 cycles later.  */
@@ -9312,7 +9313,8 @@ supersparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 }
 
 static int
-hypersparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+hypersparc_adjust_cost (rtx_insn *insn, int dtype, rtx_insn *dep_insn,
+			int cost)
 {
   enum attr_type insn_type, dep_type;
   rtx pat = PATTERN(insn);
@@ -9324,7 +9326,7 @@ hypersparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
   insn_type = get_attr_type (insn);
   dep_type = get_attr_type (dep_insn);
 
-  switch (REG_NOTE_KIND (link))
+  switch (dtype)
     {
     case 0:
       /* Data dependency; DEP_INSN writes a register that INSN reads some
@@ -9389,16 +9391,17 @@ hypersparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 }
 
 static int
-sparc_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep, int cost)
+sparc_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep, int cost,
+		   unsigned int)
 {
   switch (sparc_cpu)
     {
     case PROCESSOR_SUPERSPARC:
-      cost = supersparc_adjust_cost (insn, link, dep, cost);
+      cost = supersparc_adjust_cost (insn, dep_type, dep, cost);
       break;
     case PROCESSOR_HYPERSPARC:
     case PROCESSOR_SPARCLITE86X:
-      cost = hypersparc_adjust_cost (insn, link, dep, cost);
+      cost = hypersparc_adjust_cost (insn, dep_type, dep, cost);
       break;
     default:
       break;
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index c3757eb..fc791f5 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -2983,7 +2983,8 @@ spu_sched_reorder (FILE *file ATTRIBUTE_UNUSED, int verbose ATTRIBUTE_UNUSED,
 
 /* INSN is dependent on DEP_INSN. */
 static int
-spu_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+spu_sched_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn,
+		       int cost, unsigned int)
 {
   rtx set;
 
@@ -3044,7 +3045,7 @@ spu_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
      scheduler makes every insn in a block anti-dependent on the final
      jump_insn.  We adjust here so higher cost insns will get scheduled
      earlier. */
-  if (JUMP_P (insn) && REG_NOTE_KIND (link) == REG_DEP_ANTI)
+  if (JUMP_P (insn) && dep_type == REG_DEP_ANTI)
     return insn_cost (dep_insn) - 3;
 
   return cost;
diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index 06c832c..5508ed8 100644
--- a/gcc/config/tilegx/tilegx.c
+++ b/gcc/config/tilegx/tilegx.c
@@ -4419,15 +4419,15 @@ get_jump_target (rtx branch)
 
 /* Implement TARGET_SCHED_ADJUST_COST.  */
 static int
-tilegx_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn,
-			  int cost)
+tilegx_sched_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn,
+			  int cost, unsigned int)
 {
   /* If we have a true dependence, INSN is a call, and DEP_INSN
      defines a register that is needed by the call (argument or stack
      pointer) , set its latency to 0 so that it can be bundled with
      the call.  Explicitly check for and exclude the case when
      DEP_INSN defines the target of the jump.  */
-  if (CALL_P (insn) && REG_NOTE_KIND (link) == REG_DEP_TRUE)
+  if (CALL_P (insn) && dep_type == REG_DEP_TRUE)
     {
       rtx target = get_jump_target (insn);
       if (!REG_P (target) || !set_of (target, dep_insn))
diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c
index 628cd04..7237a60 100644
--- a/gcc/config/tilepro/tilepro.c
+++ b/gcc/config/tilepro/tilepro.c
@@ -3944,15 +3944,15 @@ get_jump_target (rtx branch)
 
 /* Implement TARGET_SCHED_ADJUST_COST.  */
 static int
-tilepro_sched_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn,
-			   int cost)
+tilepro_sched_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn,
+			   int cost, unsigned int)
 {
   /* If we have a true dependence, INSN is a call, and DEP_INSN
      defines a register that is needed by the call (argument or stack
      pointer), set its latency to 0 so that it can be bundled with
      the call.  Explicitly check for and exclude the case when
      DEP_INSN defines the target of the jump.  */
-  if (CALL_P (insn) && REG_NOTE_KIND (link) == REG_DEP_TRUE)
+  if (CALL_P (insn) && dep_type == REG_DEP_TRUE)
     {
       rtx target = get_jump_target (insn);
       if (!REG_P (target) || !set_of (target, dep_insn))
diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c
index cd28f9b..bf3d03c 100644
--- a/gcc/config/visium/visium.c
+++ b/gcc/config/visium/visium.c
@@ -211,7 +211,7 @@ static int visium_issue_rate (void);
 
 static int visium_adjust_priority (rtx_insn *, int);
 
-static int visium_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
+static int visium_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int);
 
 static int visium_register_move_cost (enum machine_mode, reg_class_t,
 				      reg_class_t);
@@ -528,14 +528,15 @@ visium_adjust_priority (rtx_insn *insn, int priority)
    a dependency LINK of INSN on DEP_INSN.  COST is the current cost.  */
 
 static int
-visium_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
+visium_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
+		    unsigned int)
 {
   enum attr_type attr_type;
 
   /* Don't adjust costs for true dependencies as they are described with
      bypasses.  But we make an exception for the first scheduling pass to
      help the subsequent postreload compare elimination pass.  */
-  if (REG_NOTE_KIND (link) == REG_DEP_TRUE)
+  if (dep_type == REG_DEP_TRUE)
     {
       if (!reload_completed
 	  && recog_memoized (insn) >= 0
@@ -576,7 +577,7 @@ visium_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 
   /* Anti dependency: DEP_INSN reads a register that INSN writes some
      cycles later.  */
-  if (REG_NOTE_KIND (link) == REG_DEP_ANTI)
+  if (dep_type == REG_DEP_ANTI)
     {
       /* On the GR5, the latency of FP instructions needs to be taken into
 	 account for every dependency involving a write.  */
@@ -637,7 +638,7 @@ visium_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
 
   /* Output dependency: DEP_INSN writes a register that INSN writes some
      cycles later.  */
-  else if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT)
+  else if (dep_type == REG_DEP_OUTPUT)
     {
       /* On the GR5, the latency of FP instructions needs to be taken into
 	 account for every dependency involving a write.  */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 745910f..ce396cc 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6543,14 +6543,14 @@ debug output to.  @var{verbose} is the verbose level provided by
 was scheduled.
 @end deftypefn
 
-@deftypefn {Target Hook} int TARGET_SCHED_ADJUST_COST (rtx_insn *@var{insn}, rtx @var{link}, rtx_insn *@var{dep_insn}, int @var{cost})
+@deftypefn {Target Hook} int TARGET_SCHED_ADJUST_COST (rtx_insn *@var{insn}, int @var{dep_type1}, rtx_insn *@var{dep_insn}, int @var{cost}, unsigned int @var{dw})
 This function corrects the value of @var{cost} based on the
-relationship between @var{insn} and @var{dep_insn} through the
-dependence @var{link}.  It should return the new value.  The default
-is to make no adjustment to @var{cost}.  This can be used for example
-to specify to the scheduler using the traditional pipeline description
-that an output- or anti-dependence does not incur the same cost as a
-data-dependence.  If the scheduler using the automaton based pipeline
+relationship between @var{insn} and @var{dep_insn} through a
+dependence of type dep_type, and strength @var{dw}.  It should return the new
+value.  The default is to make no adjustment to @var{cost}.  This can be
+used for example to specify to the scheduler using the traditional pipeline
+description that an output- or anti-dependence does not incur the same cost
+as a data-dependence.  If the scheduler using the automaton based pipeline
 description, the cost of anti-dependence is zero and the cost of
 output-dependence is maximum of one and the difference of latency
 times of the first and the second insns.  If these values are not
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 1f1e763..e972531 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -1483,28 +1483,9 @@ dep_cost_1 (dep_t link, dw_t dw)
 	}
 
 
-      if (targetm.sched.adjust_cost_2)
-	cost = targetm.sched.adjust_cost_2 (used, (int) dep_type, insn, cost,
-					    dw);
-      else if (targetm.sched.adjust_cost != NULL)
-	{
-	  /* This variable is used for backward compatibility with the
-	     targets.  */
-	  rtx_insn_list *dep_cost_rtx_link =
-	    alloc_INSN_LIST (NULL_RTX, NULL);
-
-	  /* Make it self-cycled, so that if some tries to walk over this
-	     incomplete list he/she will be caught in an endless loop.  */
-	  XEXP (dep_cost_rtx_link, 1) = dep_cost_rtx_link;
-
-	  /* Targets use only REG_NOTE_KIND of the link.  */
-	  PUT_REG_NOTE_KIND (dep_cost_rtx_link, DEP_TYPE (link));
-
-	  cost = targetm.sched.adjust_cost (used, dep_cost_rtx_link,
-					    insn, cost);
-
-	  free_INSN_LIST_node (dep_cost_rtx_link);
-	}
+      if (targetm.sched.adjust_cost)
+	cost = targetm.sched.adjust_cost (used, (int) dep_type, insn, cost,
+					  dw);
 
       if (cost < 0)
 	cost = 0;
diff --git a/gcc/target.def b/gcc/target.def
index 20f2b32..bf011b2 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -932,18 +932,20 @@ HOOK_VECTOR (TARGET_SCHED, sched)
 DEFHOOK
 (adjust_cost,
  "This function corrects the value of @var{cost} based on the\n\
-relationship between @var{insn} and @var{dep_insn} through the\n\
-dependence @var{link}.  It should return the new value.  The default\n\
-is to make no adjustment to @var{cost}.  This can be used for example\n\
-to specify to the scheduler using the traditional pipeline description\n\
-that an output- or anti-dependence does not incur the same cost as a\n\
-data-dependence.  If the scheduler using the automaton based pipeline\n\
+relationship between @var{insn} and @var{dep_insn} through a\n\
+dependence of type dep_type, and strength @var{dw}.  It should return the new\n\
+value.  The default is to make no adjustment to @var{cost}.  This can be\n\
+used for example to specify to the scheduler using the traditional pipeline\n\
+description that an output- or anti-dependence does not incur the same cost\n\
+as a data-dependence.  If the scheduler using the automaton based pipeline\n\
 description, the cost of anti-dependence is zero and the cost of\n\
 output-dependence is maximum of one and the difference of latency\n\
 times of the first and the second insns.  If these values are not\n\
 acceptable, you could use the hook to modify them too.  See also\n\
 @pxref{Processor pipeline description}.",
- int, (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost), NULL)
+ int, (rtx_insn *insn, int dep_type1, rtx_insn *dep_insn, int cost,
+       unsigned int dw),
+ NULL)
 
 /* Adjust the priority of an insn as you see fit.  Returns the new priority.  */
 DEFHOOK
@@ -1346,15 +1348,6 @@ closer to one another---i.e., closer than the dependence distance;  however,\n\
 not in cases of ``costly dependences'', which this hooks allows to define.",
  bool, (struct _dep *_dep, int cost, int distance), NULL)
 
-DEFHOOK_UNDOC
-(adjust_cost_2,
- "Given the current cost, @var{cost}, of an insn, @var{insn}, calculate and\
- return a new cost based on its relationship to @var{dep_insn} through the\
- dependence of weakness @var{dw}.  The default is to make no adjustment.",
- int, (rtx_insn *insn, int dep_type1, rtx_insn *dep_insn, int cost,
-       unsigned int dw),
- NULL)
-
 /* The following member value is a pointer to a function called
    by the insn scheduler. This hook is called to notify the backend
    that new instructions were emitted.  */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 06/18] move reg_equivs out of gc memory
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (11 preceding siblings ...)
  2016-04-20  6:18 ` [PATCH 09/18] make pattern_regs a vec tbsaunde+gcc
@ 2016-04-20  6:19 ` tbsaunde+gcc
  2016-04-25 14:22   ` Bernd Schmidt
  2016-04-20  6:19 ` [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks tbsaunde+gcc
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

It used the gc vector type, but isn't marked as a gc route, and appears
to be manually managed, so it should be safe to use the normal heap
vector.

gcc/ChangeLog:

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

	* ira-emit.c (emit_move_list): Adjust.
	* ira.c (fix_reg_equiv_init): Likewise.
	(update_equiv_regs): Likewise.
	(ira): Likewise.
	(do_reload): Likewise.
	* reload.c (subst_reloads): Likewise.
	* reload.h (reg_equivs): Move to the normal heap.
	* reload1.c (grow_reg_equivs): Adjust.
	(reload): Likewise.
	(eliminate_regs_1): Likewise.
	(elimination_effects): Likewise.
	(init_eliminable_invariants): Likewise.
	(free_reg_equiv): Likewise.
---
 gcc/ira-emit.c |  4 ++--
 gcc/ira.c      | 11 +++++------
 gcc/reload.c   |  4 ++--
 gcc/reload.h   | 19 ++++++++-----------
 gcc/reload1.c  | 36 +++++++++---------------------------
 5 files changed, 26 insertions(+), 48 deletions(-)

diff --git a/gcc/ira-emit.c b/gcc/ira-emit.c
index 691bd1d..3fc29f1 100644
--- a/gcc/ira-emit.c
+++ b/gcc/ira-emit.c
@@ -914,7 +914,7 @@ emit_move_list (move_t list, int freq)
   machine_mode mode;
   enum reg_class aclass;
 
-  grow_reg_equivs ();
+  reg_equivs.safe_grow_cleared (max_reg_num ());
   start_sequence ();
   for (; list != NULL; list = list->next)
     {
@@ -948,7 +948,7 @@ emit_move_list (move_t list, int freq)
 		  || (ira_reg_equiv[regno].invariant == NULL_RTX
 		      && ira_reg_equiv[regno].constant == NULL_RTX))
 		continue; /* regno has no equivalence.  */
-	      ira_assert ((int) reg_equivs->length () > regno);
+	      ira_assert ((int) reg_equivs.length () > regno);
 	      reg_equiv_init (regno)
 		= gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv_init (regno));
 	    }
diff --git a/gcc/ira.c b/gcc/ira.c
index 8ac153b..e3e4969 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -2685,8 +2685,8 @@ fix_reg_equiv_init (void)
 
   if (max_regno_before_ira < max_regno)
     {
-      max = vec_safe_length (reg_equivs);
-      grow_reg_equivs ();
+      max = reg_equivs.length ();
+      reg_equivs.safe_grow_cleared (max_reg_num ());
       for (i = FIRST_PSEUDO_REGISTER; i < max; i++)
 	for (prev = NULL, x = reg_equiv_init (i);
 	     x != NULL_RTX;
@@ -3350,7 +3350,7 @@ update_equiv_regs (void)
   pdx_subregs = XCNEWVEC (bool, max_regno);
 
   reg_equiv = XCNEWVEC (struct equivalence, max_regno);
-  grow_reg_equivs ();
+  reg_equivs.safe_grow_cleared (max_reg_num ());
 
   init_alias_analysis ();
 
@@ -5358,7 +5358,7 @@ ira (FILE *f)
 
   overall_cost_before = ira_overall_cost;
   if (! ira_conflicts_p)
-    grow_reg_equivs ();
+    reg_equivs.safe_grow_cleared (max_reg_num ());
   else
     {
       fix_reg_equiv_init ();
@@ -5425,8 +5425,7 @@ do_reload (void)
       lra (ira_dump_file);
       /* ???!!! Move it before lra () when we use ira_reg_equiv in
 	 LRA.  */
-      vec_free (reg_equivs);
-      reg_equivs = NULL;
+      reg_equivs.release ();
       need_dce = false;
     }
   else
diff --git a/gcc/reload.c b/gcc/reload.c
index 06426d9..91d0b4d 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -6267,9 +6267,9 @@ subst_reloads (rtx_insn *insn)
 	  for (check_regno = 0; check_regno < max_regno; check_regno++)
 	    {
 #define CHECK_MODF(ARRAY)						\
-	      gcc_assert (!(*reg_equivs)[check_regno].ARRAY		\
+	      gcc_assert (!reg_equivs[check_regno].ARRAY		\
 			  || !loc_mentioned_in_p (r->where,		\
-						  (*reg_equivs)[check_regno].ARRAY))
+						  reg_equivs[check_regno].ARRAY))
 
 	      CHECK_MODF (constant);
 	      CHECK_MODF (memory_loc);
diff --git a/gcc/reload.h b/gcc/reload.h
index 98b75e3..7bf9e6d 100644
--- a/gcc/reload.h
+++ b/gcc/reload.h
@@ -243,21 +243,21 @@ struct reg_equivs_t
 };
 
 #define reg_equiv_constant(ELT) \
-  (*reg_equivs)[(ELT)].constant
+  reg_equivs[(ELT)].constant
 #define reg_equiv_invariant(ELT) \
-  (*reg_equivs)[(ELT)].invariant
+  reg_equivs[(ELT)].invariant
 #define reg_equiv_memory_loc(ELT) \
-  (*reg_equivs)[(ELT)].memory_loc
+  reg_equivs[(ELT)].memory_loc
 #define reg_equiv_address(ELT) \
-  (*reg_equivs)[(ELT)].address
+  reg_equivs[(ELT)].address
 #define reg_equiv_mem(ELT) \
-  (*reg_equivs)[(ELT)].mem
+  reg_equivs[(ELT)].mem
 #define reg_equiv_alt_mem_list(ELT) \
-  (*reg_equivs)[(ELT)].alt_mem_list
+  reg_equivs[(ELT)].alt_mem_list
 #define reg_equiv_init(ELT) \
-  (*reg_equivs)[(ELT)].init
+  reg_equivs[(ELT)].init
 
-extern vec<reg_equivs_t, va_gc> *reg_equivs;
+extern vec<reg_equivs_t> reg_equivs;
 
 /* All the "earlyclobber" operands of the current insn
    are recorded here.  */
@@ -458,7 +458,4 @@ extern void debug_reload (void);
    reloading to/from a register that is wider than a word.  */
 extern rtx reload_adjust_reg_for_mode (rtx, machine_mode);
 
-/* Allocate or grow the reg_equiv tables, initializing new entries to 0.  */
-extern void grow_reg_equivs (void);
-
 #endif /* GCC_RELOAD_H */
diff --git a/gcc/reload1.c b/gcc/reload1.c
index c2800f8..d0084ac 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -322,7 +322,7 @@ static int first_label_num;
 static char *offsets_known_at;
 static HOST_WIDE_INT (*offsets_at)[NUM_ELIMINABLE_REGS];
 
-vec<reg_equivs_t, va_gc> *reg_equivs;
+vec<reg_equivs_t> reg_equivs;
 
 /* Stack of addresses where an rtx has been changed.  We can undo the 
    changes by popping items off the stack and restoring the original
@@ -643,24 +643,6 @@ has_nonexceptional_receiver (void)
   return false;
 }
 
-/* Grow (or allocate) the REG_EQUIVS array from its current size (which may be
-   zero elements) to MAX_REG_NUM elements.
-
-   Initialize all new fields to NULL and update REG_EQUIVS_SIZE.  */
-void
-grow_reg_equivs (void)
-{
-  int old_size = vec_safe_length (reg_equivs);
-  int max_regno = max_reg_num ();
-  int i;
-  reg_equivs_t ze;
-
-  memset (&ze, 0, sizeof (reg_equivs_t));
-  vec_safe_reserve (reg_equivs, max_regno);
-  for (i = old_size; i < max_regno; i++)
-    reg_equivs->quick_insert (i, ze);
-}
-
 \f
 /* Global variables used by reload and its subroutines.  */
 
@@ -818,7 +800,7 @@ reload (rtx_insn *first, int global)
      Record memory equivalents in reg_mem_equiv so they can
      be substituted eventually by altering the REG-rtx's.  */
 
-  grow_reg_equivs ();
+  reg_equivs.safe_grow_cleared (max_reg_num ());
   reg_old_renumber = XCNEWVEC (short, max_regno);
   memcpy (reg_old_renumber, reg_renumber, max_regno * sizeof (short));
   pseudo_forbidden_regs = XNEWVEC (HARD_REG_SET, max_regno);
@@ -2559,7 +2541,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
 
 	}
       else if (reg_renumber && reg_renumber[regno] < 0
-	       && reg_equivs
+	       && !reg_equivs.is_empty ()
 	       && reg_equiv_invariant (regno))
 	{
 	  if (may_use_invariant || (insn && DEBUG_INSN_P (insn)))
@@ -2644,7 +2626,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
 	    if (GET_CODE (new0) == PLUS && REG_P (new1)
 		&& REGNO (new1) >= FIRST_PSEUDO_REGISTER
 		&& reg_renumber[REGNO (new1)] < 0
-		&& reg_equivs
+		&& !reg_equivs.is_empty ()
 		&& reg_equiv_constant (REGNO (new1)) != 0)
 	      new1 = reg_equiv_constant (REGNO (new1));
 	    else if (GET_CODE (new1) == PLUS && REG_P (new0)
@@ -2814,7 +2796,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
 	 may do the replacement in certain circumstances.  */
       if (REG_P (SUBREG_REG (x))
 	  && !paradoxical_subreg_p (x)
-	  && reg_equivs
+	  && !reg_equivs.is_empty ()
 	  && reg_equiv_memory_loc (REGNO (SUBREG_REG (x))) != 0)
 	{
 	  new_rtx = SUBREG_REG (x);
@@ -2983,7 +2965,7 @@ elimination_effects (rtx x, machine_mode mem_mode)
 
 	}
       else if (reg_renumber[regno] < 0
-	       && reg_equivs
+	       && !reg_equivs.is_empty ()
 	       && reg_equiv_constant (regno)
 	       && ! function_invariant_p (reg_equiv_constant (regno)))
 	elimination_effects (reg_equiv_constant (regno), mem_mode);
@@ -3054,7 +3036,7 @@ elimination_effects (rtx x, machine_mode mem_mode)
       if (REG_P (SUBREG_REG (x))
 	  && (GET_MODE_SIZE (GET_MODE (x))
 	      <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
-	  && reg_equivs
+	  && !reg_equivs.is_empty ()
 	  && reg_equiv_memory_loc (REGNO (SUBREG_REG (x))) != 0)
 	return;
 
@@ -4117,7 +4099,7 @@ init_eliminable_invariants (rtx_insn *first, bool do_subregs)
   int i;
   rtx_insn *insn;
 
-  grow_reg_equivs ();
+  reg_equivs.safe_grow_cleared (max_reg_num ());
   if (do_subregs)
     reg_max_ref_width = XCNEWVEC (unsigned int, max_regno);
   else
@@ -4244,7 +4226,7 @@ free_reg_equiv (void)
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     if (reg_equiv_alt_mem_list (i))
       free_EXPR_LIST_list (&reg_equiv_alt_mem_list (i));
-  vec_free (reg_equivs);
+  reg_equivs.release ();
 }
 \f
 /* Kick all pseudos out of hard register REGNO.
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 11/18] add some utility methods to vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (13 preceding siblings ...)
  2016-04-20  6:19 ` [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks tbsaunde+gcc
@ 2016-04-20  6:19 ` tbsaunde+gcc
  2016-04-20  9:13   ` Richard Biener
  2016-04-20 12:29   ` Segher Boessenkool
  2016-04-20  6:37 ` [PATCH 18/18] make last_pending_memory_flush a vec tbsaunde+gcc
                   ` (3 subsequent siblings)
  18 siblings, 2 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Later patches use these functions, and I believe Mikhail has mentioned before
he'd like to have begin / end () on vec before.

gcc/ChangeLog:

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

	* vec.h (vec_safe_contains): New function.
	(vec::contains): Likewise.
	(vec::begin): Likewise.
	(vec::end): Likewise.
---
 gcc/vec.h | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/vec.h b/gcc/vec.h
index ff57528..3c16e83 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -454,6 +454,10 @@ public:
   bool is_empty (void) const { return m_vecpfx.m_num == 0; }
   T *address (void) { return m_vecdata; }
   const T *address (void) const { return m_vecdata; }
+  T *begin () { return address (); }
+  const T *begin () const { return address (); }
+  T *end () { return address () + length (); }
+  const T *end () const { return address () + length (); }
   const T &operator[] (unsigned) const;
   T &operator[] (unsigned);
   T &last (void);
@@ -473,6 +477,7 @@ public:
   void qsort (int (*) (const void *, const void *));
   T *bsearch (const void *key, int (*compar)(const void *, const void *));
   unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
+  bool contains (const T &search) const;
   static size_t embedded_size (unsigned);
   void embedded_init (unsigned, unsigned = 0, unsigned = 0);
   void quick_grow (unsigned len);
@@ -542,7 +547,6 @@ vec_safe_is_empty (vec<T, A, vl_embed> *v)
   return v ? v->is_empty () : true;
 }
 
-
 /* If V does not have space for NELEMS elements, call
    V->reserve(NELEMS, EXACT).  */
 template<typename T, typename A>
@@ -695,6 +699,12 @@ vec_safe_splice (vec<T, A, vl_embed> *&dst, const vec<T, A, vl_embed> *src
     }
 }
 
+template<typename T, typename A>
+inline bool
+vec_safe_contains (vec<T, A, vl_embed> *v, const T &search)
+{
+  return v? v->contains (search) : false;
+}
 
 /* Index into vector.  Return the IX'th element.  IX must be in the
    domain of the vector.  */
@@ -973,6 +983,19 @@ vec<T, A, vl_embed>::bsearch (const void *key,
   return NULL;
 }
 
+/* Return true if the vector contains search.  */
+
+template<typename T, typename A>
+inline bool
+vec<T, A, vl_embed>::contains (const T &search) const
+{
+  unsigned int len = length ();
+  for (unsigned int i = 0; i < len; i++)
+    if ((*this)[i] == search)
+      return true;
+
+  return false;
+}
 
 /* Find and return the first position in which OBJ could be inserted
    without changing the ordering of this vector.  LESSTHAN is a
@@ -1167,6 +1190,10 @@ public:
   const T *address (void) const
   { return m_vec ? m_vec->m_vecdata : NULL; }
 
+  T *begin () { return address (); }
+  const T *begin () const { return address (); }
+  T *end () { return begin () + length (); }
+  const T *end () const { return begin () + length (); }
   const T &operator[] (unsigned ix) const
   { return (*m_vec)[ix]; }
 
@@ -1208,6 +1235,7 @@ public:
   void qsort (int (*) (const void *, const void *));
   T *bsearch (const void *key, int (*compar)(const void *, const void *));
   unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
+  bool contains (const T &search) const;
 
   bool using_auto_storage () const;
 
@@ -1695,6 +1723,15 @@ vec<T, va_heap, vl_ptr>::lower_bound (T obj,
   return m_vec ? m_vec->lower_bound (obj, lessthan) : 0;
 }
 
+/* Return true if the vector contains search.  */
+
+template<typename T>
+inline bool
+vec<T, va_heap, vl_ptr>::contains (const T &search) const
+{
+  return m_vec ? m_vec->contains (search) : false;
+}
+
 template<typename T>
 inline bool
 vec<T, va_heap, vl_ptr>::using_auto_storage () const
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 18/18] make last_pending_memory_flush a vec
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (14 preceding siblings ...)
  2016-04-20  6:19 ` [PATCH 11/18] add some utility methods to vec tbsaunde+gcc
@ 2016-04-20  6:37 ` tbsaunde+gcc
  2016-04-20 12:53   ` Segher Boessenkool
  2016-04-20  6:41 ` [PATCH 14/18] haifa-sched.c: make ready_list an auto_vec<rtx_insn *> tbsaunde+gcc
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:37 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Same story for the new functions here as for the previous patch.

gcc/ChangeLog:

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

	* sched-deps.c (remove_from_dependence_list): Adjust.
	(flush_pending_lists): Likewise.
	(sched_analyze_2): Likewise.
	(sched_analyze_insn): Likewise.
	(deps_analyze_insn): Likewise.
	(init_deps): Likewise.
	(free_deps): Likewise.
	* sched-int.h (struct deps_desc): Make last_pending_memory_flush
	a vector.
	* sched-rgn.c (deps_join): Adjust.
	(propagate_deps): Likewise.
	(free_pending_lists): Likewise.
---
 gcc/sched-deps.c | 61 ++++++++++++++++++++++++++++++++++++++++----------------
 gcc/sched-int.h  |  4 ++--
 gcc/sched-rgn.c  | 14 +++++--------
 3 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 879c9ca..1361967 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -1641,6 +1641,27 @@ remove_from_dependence_list (rtx_insn *insn, rtx_insn_list **listp)
   return removed;
 }
 
+/* Similar but operate on a vec<rtx_insn *>.  */
+
+static int
+remove_from_dependence_list (rtx_insn *insn, vec<rtx_insn *> *insns)
+{
+  int removed = 0;
+
+  unsigned int len = insns->length ();
+  for (unsigned int i = len - 1; i < len; i--)
+    {
+      if ((*insns)[i] == insn)
+	{
+	  insns->ordered_remove (i);
+	  removed++;
+	  continue;
+	}
+    }
+
+  return removed;
+}
+
 /* Same as above, but process two lists at once.  */
 static int
 remove_from_both_dependence_lists (rtx_insn *insn,
@@ -1804,8 +1825,8 @@ flush_pending_lists (struct deps_desc *deps, rtx_insn *insn, int for_read,
       if (for_write)
 	deps->pending_read_insns.release ();
       deps->pending_write_insns.release ();
-      free_INSN_LIST_list (&deps->last_pending_memory_flush);
-      free_INSN_LIST_list (&deps->pending_jump_insns);
+      deps->last_pending_memory_flush.release ();
+      deps->pending_jump_insns.release ();
     }
 
   if (!deps->readonly)
@@ -1813,7 +1834,8 @@ flush_pending_lists (struct deps_desc *deps, rtx_insn *insn, int for_read,
       free_EXPR_LIST_list (&deps->pending_write_mems);
       deps->pending_write_list_length = 0;
 
-      deps->last_pending_memory_flush = alloc_INSN_LIST (insn, NULL_RTX);
+      deps->last_pending_memory_flush.truncate (0);
+      deps->last_pending_memory_flush.safe_push (insn);
       deps->pending_flush_length = 1;
     }
   mark_as_hard = false;
@@ -2640,7 +2662,6 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
     case MEM:
       {
 	/* Reading memory.  */
-	rtx_insn_list *u;
 	rtx_expr_list *pending_mem;
 	rtx t = x;
 
@@ -2685,22 +2706,26 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
 		pending_mem = pending_mem->next ();
 	      }
 
-	    for (u = deps->last_pending_memory_flush; u; u = u->next ())
-	      add_dependence (insn, u->insn (), REG_DEP_ANTI);
+	    len = deps->last_pending_memory_flush.length ();
+	    for (unsigned int i = len - 1; i < len; i--)
+	      add_dependence (insn, deps->last_pending_memory_flush[i],
+			      REG_DEP_ANTI);
 
-	    for (u = deps->pending_jump_insns; u; u = u->next ())
+	    len = deps->pending_jump_insns.length ();
+	    for (unsigned int i = len - 1; i < len; i--)
 	      if (deps_may_trap_p (x))
 		{
+		  rtx_insn *temp = deps->pending_jump_insns[i];
 		  if ((sched_deps_info->generate_spec_deps)
 		      && sel_sched_p () && (spec_info->mask & BEGIN_CONTROL))
 		    {
 		      ds_t ds = set_dep_weak (DEP_ANTI, BEGIN_CONTROL,
 					      MAX_DEP_WEAK);
 		      
-		      note_dep (u->insn (), ds);
+		      note_dep (temp, ds);
 		    }
 		  else
-		    add_dependence (insn, u->insn (), REG_DEP_CONTROL);
+		    add_dependence (insn, temp, REG_DEP_CONTROL);
 		}
 	  }
 
@@ -3074,7 +3099,6 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
   if (DEBUG_INSN_P (insn))
     {
       rtx_insn *prev = deps->last_debug_insn;
-      rtx_insn_list *u;
 
       if (!deps->readonly)
 	deps->last_debug_insn = insn;
@@ -3086,8 +3110,12 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
 			   REG_DEP_ANTI, false);
 
       if (!sel_sched_p ())
-	for (u = deps->last_pending_memory_flush; u; u = u->next ())
-	  add_dependence (insn, u->insn (), REG_DEP_ANTI);
+	{
+	  unsigned int len = deps->last_pending_memory_flush.length ();
+	  for (unsigned int i = len - 1; i < len; i--)
+	    add_dependence (insn, deps->last_pending_memory_flush[i],
+			    REG_DEP_ANTI);
+	}
 
       EXECUTE_IF_SET_IN_REG_SET (reg_pending_uses, 0, i, rsi)
 	{
@@ -3653,8 +3681,7 @@ deps_analyze_insn (struct deps_desc *deps, rtx_insn *insn)
           if (deps->pending_flush_length++ >= MAX_PENDING_LIST_LENGTH)
             flush_pending_lists (deps, insn, true, true);
           else
-	    deps->pending_jump_insns
-              = alloc_INSN_LIST (insn, deps->pending_jump_insns);
+	    deps->pending_jump_insns.safe_push (insn);
         }
 
       /* For each insn which shouldn't cross a jump, add a dependence.  */
@@ -3903,11 +3930,11 @@ init_deps (struct deps_desc *deps, bool lazy_reg_last)
   deps->pending_read_mems = 0;
   deps->pending_write_insns.create (0);
   deps->pending_write_mems = 0;
-  deps->pending_jump_insns = 0;
+  deps->pending_jump_insns.create (0);
   deps->pending_read_list_length = 0;
   deps->pending_write_list_length = 0;
   deps->pending_flush_length = 0;
-  deps->last_pending_memory_flush = 0;
+  deps->last_pending_memory_flush.create (0);
   deps->last_function_call = 0;
   deps->last_function_call_may_noreturn = 0;
   deps->sched_before_next_call = 0;
@@ -3951,7 +3978,7 @@ free_deps (struct deps_desc *deps)
   free_EXPR_LIST_list (&deps->pending_read_mems);
   deps->pending_write_insns.release ();
   free_EXPR_LIST_list (&deps->pending_write_mems);
-  free_INSN_LIST_list (&deps->last_pending_memory_flush);
+  deps->last_pending_memory_flush.release ();
 
   /* Without the EXECUTE_IF_SET, this loop is executed max_reg * nr_regions
      times.  For a testcase with 42000 regs and 8000 small basic blocks,
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index 45890b8..d75a85c 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -478,7 +478,7 @@ struct deps_desc
   rtx_expr_list *pending_write_mems;
 
   /* An INSN_LIST containing all jump insns.  */
-  rtx_insn_list *pending_jump_insns;
+  vec<rtx_insn *> pending_jump_insns;
 
   /* We must prevent the above lists from ever growing too large since
      the number of dependencies produced is at least O(N*N),
@@ -505,7 +505,7 @@ struct deps_desc
      alias analysis, this restriction can be relaxed.
      This may also be an INSN that writes memory if the pending lists grow
      too large.  */
-  rtx_insn_list *last_pending_memory_flush;
+  vec<rtx_insn *> last_pending_memory_flush;
 
   /* A list of the last function calls we have seen.  We use a list to
      represent last function calls from multiple predecessor blocks.
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 9e807a1..6ba4757 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -2620,12 +2620,8 @@ deps_join (struct deps_desc *succ_deps, struct deps_desc *pred_deps)
   concat_mem_list (pred_deps->pending_write_mems,
 		   &succ_deps->pending_write_mems);
 
-  succ_deps->pending_jump_insns
-    = concat_INSN_LIST (pred_deps->pending_jump_insns,
-                        succ_deps->pending_jump_insns);
-  succ_deps->last_pending_memory_flush
-    = concat_INSN_LIST (pred_deps->last_pending_memory_flush,
-                        succ_deps->last_pending_memory_flush);
+  succ_deps->pending_jump_insns.safe_splice (pred_deps->pending_jump_insns);
+  succ_deps->last_pending_memory_flush.safe_splice (pred_deps->last_pending_memory_flush);
 
   succ_deps->pending_read_list_length += pred_deps->pending_read_list_length;
   succ_deps->pending_write_list_length += pred_deps->pending_write_list_length;
@@ -2672,17 +2668,17 @@ propagate_deps (int bb, struct deps_desc *pred_deps)
   pred_deps->pending_read_insns = vNULL;
   bb_deps[bb].pending_write_insns = pred_deps->pending_write_insns;
   pred_deps->pending_write_insns = vNULL;
+  bb_deps[bb].pending_jump_insns = pred_deps->pending_jump_insns;
+  pred_deps->pending_jump_insns = vNULL;
 
   /* These lists should point to the right place, for correct
      freeing later.  */
   bb_deps[bb].pending_read_mems = pred_deps->pending_read_mems;
   bb_deps[bb].pending_write_mems = pred_deps->pending_write_mems;
-  bb_deps[bb].pending_jump_insns = pred_deps->pending_jump_insns;
 
   /* Can't allow these to be freed twice.  */
   pred_deps->pending_read_mems = 0;
   pred_deps->pending_write_mems = 0;
-  pred_deps->pending_jump_insns = 0;
 }
 
 /* Compute dependences inside bb.  In a multiple blocks region:
@@ -2761,7 +2757,7 @@ free_pending_lists (void)
       bb_deps[bb].pending_write_insns.release ();
       free_EXPR_LIST_list (&bb_deps[bb].pending_read_mems);
       free_EXPR_LIST_list (&bb_deps[bb].pending_write_mems);
-      free_INSN_LIST_list (&bb_deps[bb].pending_jump_insns);
+      bb_deps[bb].pending_jump_insns.release ();
     }
 }
 \f
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 14/18] haifa-sched.c: make ready_list an auto_vec<rtx_insn *>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (15 preceding siblings ...)
  2016-04-20  6:37 ` [PATCH 18/18] make last_pending_memory_flush a vec tbsaunde+gcc
@ 2016-04-20  6:41 ` tbsaunde+gcc
  2016-04-20  6:41 ` [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *> tbsaunde+gcc
  2016-04-20 13:03 ` [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list Andi Kleen
  18 siblings, 0 replies; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:41 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* haifa-sched.c (fix_recovery_deps): Make ready_list a vector.
---
 gcc/haifa-sched.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 34c5cc5..800a8f7 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -8604,9 +8604,8 @@ static void
 fix_recovery_deps (basic_block rec)
 {
   rtx_insn *note, *insn, *jump;
-  rtx_insn_list *ready_list = 0;
+  auto_vec<rtx_insn *, 10> ready_list;
   bitmap_head in_ready;
-  rtx_insn_list *link;
 
   bitmap_initialize (&in_ready, 0);
 
@@ -8632,7 +8631,7 @@ fix_recovery_deps (basic_block rec)
 	      sd_delete_dep (sd_it);
 
 	      if (bitmap_set_bit (&in_ready, INSN_LUID (consumer)))
-		ready_list = alloc_INSN_LIST (consumer, ready_list);
+		ready_list.safe_push (consumer);
 	    }
 	  else
 	    {
@@ -8649,9 +8648,9 @@ fix_recovery_deps (basic_block rec)
   bitmap_clear (&in_ready);
 
   /* Try to add instructions to the ready or queue list.  */
-  for (link = ready_list; link; link = link->next ())
-    try_ready (link->insn ());
-  free_INSN_LIST_list (&ready_list);
+  unsigned int len = ready_list.length ();
+  for (unsigned int i = len - 1; i < len; i--)
+    try_ready (ready_list[i]);
 
   /* Fixing jump's dependences.  */
   insn = BB_HEAD (rec);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (16 preceding siblings ...)
  2016-04-20  6:41 ` [PATCH 14/18] haifa-sched.c: make ready_list an auto_vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20  6:41 ` tbsaunde+gcc
  2016-04-25 13:55   ` Bernd Schmidt
  2016-04-20 13:03 ` [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list Andi Kleen
  18 siblings, 1 reply; 60+ messages in thread
From: tbsaunde+gcc @ 2016-04-20  6:41 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

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

	* haifa-sched.c (queue_insn): Adjust.
	(queue_remove): Likewise.
	(check_clobbered_conditions): Likewise.
	(struct haifa_saved_data): Make insn_queue a vector.
	(save_backtrack_point): Adjust.
	(toggle_cancelled_flags): Likewise.
	(restore_last_backtrack_point): Likewise.
	(free_topmost_backtrack_point): Likewise.
	(queue_to_ready): Likewise.
	(early_queue_to_ready): Likewise.
	(autopref_multipass_dfa_lookahead_guard): Likewise.
	(schedule_block): Likewise.
---
 gcc/haifa-sched.c | 205 +++++++++++++++++++++++++++---------------------------
 1 file changed, 101 insertions(+), 104 deletions(-)

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index e972531..0721ec5 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -122,6 +122,7 @@ along with GCC; see the file COPYING3.  If not see
    other NOTE insns are grouped in their same relative order at the
    beginning of basic blocks and regions that have been scheduled.  */
 \f
+#define INCLUDE_ALGORITHM
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -320,7 +321,7 @@ bool adding_bb_to_current_region_p = true;
    the base maximal time of functional unit reservations and getting a
    result.  This is the longest time an insn may be queued.  */
 
-static rtx_insn_list **insn_queue;
+static vec<rtx_insn *> *insn_queue;
 static int q_ptr = 0;
 static int q_size = 0;
 #define NEXT_Q(X) (((X)+1) & max_insn_queue_index)
@@ -2826,13 +2827,12 @@ HAIFA_INLINE static void
 queue_insn (rtx_insn *insn, int n_cycles, const char *reason)
 {
   int next_q = NEXT_Q_AFTER (q_ptr, n_cycles);
-  rtx_insn_list *link = alloc_INSN_LIST (insn, insn_queue[next_q]);
   int new_tick;
 
   gcc_assert (n_cycles <= max_insn_queue_index);
   gcc_assert (!DEBUG_INSN_P (insn));
 
-  insn_queue[next_q] = link;
+  insn_queue[next_q].safe_push (insn);
   q_size += 1;
 
   if (sched_verbose >= 2)
@@ -2861,14 +2861,26 @@ queue_insn (rtx_insn *insn, int n_cycles, const char *reason)
     }
 }
 
-/* Remove INSN from queue.  */
+/* Remove INSN at idx from queue.  */
+static void
+queue_remove (unsigned int q, unsigned int idx)
+{
+  QUEUE_INDEX (insn_queue[q][idx]) = QUEUE_NOWHERE;
+  insn_queue[q].ordered_remove (idx);
+  q_size--;
+}
+
+/* Remove insn from the queue.  */
+
 static void
 queue_remove (rtx_insn *insn)
 {
   gcc_assert (QUEUE_INDEX (insn) >= 0);
-  remove_free_INSN_LIST_elem (insn, &insn_queue[QUEUE_INDEX (insn)]);
-  q_size--;
-  QUEUE_INDEX (insn) = QUEUE_NOWHERE;
+
+  unsigned int q = QUEUE_INDEX (insn);
+  unsigned int idx = std::find (insn_queue[q].begin (), insn_queue[q].end (),
+				insn) - insn_queue[q].begin ();
+  queue_remove (q, idx);
 }
 
 /* Return a pointer to the bottom of the ready list, i.e. the insn
@@ -3267,17 +3279,16 @@ check_clobbered_conditions (rtx_insn *insn)
     }
   for (i = 0; i <= max_insn_queue_index; i++)
     {
-      rtx_insn_list *link;
       int q = NEXT_Q_AFTER (q_ptr, i);
 
-    restart_queue:
-      for (link = insn_queue[q]; link; link = link->next ())
+      unsigned int len = insn_queue[q].length ();
+      for (unsigned int i = len - 1; i < len; i--)
 	{
-	  rtx_insn *x = link->insn ();
+	  rtx_insn *x = insn_queue[q][i];
 	  if (TODO_SPEC (x) == DEP_CONTROL && cond_clobbered_p (x, t))
 	    {
 	      queue_remove (x);
-	      goto restart_queue;
+	      i = insn_queue[q].length ();
 	    }
 	}
     }
@@ -4277,7 +4288,7 @@ struct haifa_saved_data
   /* We don't need to save q_ptr, as its value is arbitrary and we can set it
      to 0 when restoring.  */
   int q_size;
-  rtx_insn_list **insn_queue;
+  vec<rtx_insn *> *insn_queue;
 
   /* Describe pattern replacements that occurred since this backtrack point
      was queued.  */
@@ -4328,12 +4339,12 @@ save_backtrack_point (struct delay_pair *pair,
   save->ready.vec = XNEWVEC (rtx_insn *, ready.veclen);
   memcpy (save->ready.vec, ready.vec, ready.veclen * sizeof (rtx));
 
-  save->insn_queue = XNEWVEC (rtx_insn_list *, max_insn_queue_index + 1);
+  save->insn_queue = XNEWVEC (vec<rtx_insn *>, max_insn_queue_index + 1);
   save->q_size = q_size;
   for (i = 0; i <= max_insn_queue_index; i++)
     {
       int q = NEXT_Q_AFTER (q_ptr, i);
-      save->insn_queue[i] = copy_INSN_LIST (insn_queue[q]);
+      save->insn_queue[i] = insn_queue[q].copy ();
     }
 
   save->clock_var = clock_var;
@@ -4403,10 +4414,10 @@ toggle_cancelled_flags (bool set)
   for (i = 0; i <= max_insn_queue_index; i++)
     {
       int q = NEXT_Q_AFTER (q_ptr, i);
-      rtx_insn_list *link;
-      for (link = insn_queue[q]; link; link = link->next ())
+      unsigned int len = insn_queue[q].length ();
+      for (unsigned int i = len - 1; i < len; i--)
 	{
-	  rtx_insn *insn = link->insn ();
+	  rtx_insn *insn = insn_queue[q][i];
 	  FOR_EACH_DEP (insn, SD_LIST_BACK, sd_it, dep)
 	    if (!DEBUG_INSN_P (DEP_PRO (dep)))
 	      {
@@ -4546,14 +4557,14 @@ restore_last_backtrack_point (struct sched_block_state *psched_block)
   for (i = 0; i <= max_insn_queue_index; i++)
     {
       int q = NEXT_Q_AFTER (q_ptr, i);
-
-      for (rtx_insn_list *link = insn_queue[q]; link; link = link->next ())
+      unsigned int len = insn_queue[q].length ();
+      for (unsigned int i = len - 1; i < len; i--)
 	{
-	  rtx_insn *x = link->insn ();
+	  rtx_insn *x = insn_queue[q][i];
 	  QUEUE_INDEX (x) = QUEUE_NOWHERE;
 	  INSN_TICK (x) = INVALID_TICK;
 	}
-      free_INSN_LIST_list (&insn_queue[q]);
+      insn_queue[q].release ();
     }
 
   free (ready.vec);
@@ -4577,11 +4588,13 @@ restore_last_backtrack_point (struct sched_block_state *psched_block)
     {
       int q = NEXT_Q_AFTER (q_ptr, i);
 
+      insn_queue[q].release ();
       insn_queue[q] = save->insn_queue[q];
 
-      for (rtx_insn_list *link = insn_queue[q]; link; link = link->next ())
+      unsigned int len = insn_queue[q].length ();
+      for (unsigned int j = len - 1; j < len; j--)
 	{
-	  rtx_insn *x = link->insn ();
+	  rtx_insn *x = insn_queue[q][j];
 	  QUEUE_INDEX (x) = i;
 	  TODO_SPEC (x) = recompute_todo_spec (x, true);
 	  INSN_TICK (x) = save->clock_var + i;
@@ -4651,7 +4664,7 @@ free_topmost_backtrack_point (bool reset_tick)
   if (current_sched_info->restore_state)
     free (save->fe_saved_data);
   for (i = 0; i <= max_insn_queue_index; i++)
-    free_INSN_LIST_list (&save->insn_queue[i]);
+    save->insn_queue[i].release ();
   free (save->insn_queue);
   free (save->curr_state);
   free (save->ready.vec);
@@ -5090,7 +5103,6 @@ static void
 queue_to_ready (struct ready_list *ready)
 {
   rtx_insn *insn;
-  rtx_insn_list *link;
   rtx_insn *skip_insn;
 
   q_ptr = NEXT_Q (q_ptr);
@@ -5104,9 +5116,10 @@ queue_to_ready (struct ready_list *ready)
 
   /* Add all pending insns that can be scheduled without stalls to the
      ready list.  */
-  for (link = insn_queue[q_ptr]; link; link = link->next ())
+  unsigned int len = insn_queue[q_ptr].length ();
+  for (unsigned int i = len - 1; i < len; i--)
     {
-      insn = link->insn ();
+      insn = insn_queue[q_ptr][i];
       q_size -= 1;
 
       if (sched_verbose >= 2)
@@ -5140,7 +5153,7 @@ queue_to_ready (struct ready_list *ready)
 	    fprintf (sched_dump, "moving to ready without stalls\n");
         }
     }
-  free_INSN_LIST_list (&insn_queue[q_ptr]);
+  insn_queue[q_ptr].release ();
 
   /* If there are no ready insns, stall until one is ready and add all
      of the pending insns at that point to the ready list.  */
@@ -5150,11 +5163,13 @@ queue_to_ready (struct ready_list *ready)
 
       for (stalls = 1; stalls <= max_insn_queue_index; stalls++)
 	{
-	  if ((link = insn_queue[NEXT_Q_AFTER (q_ptr, stalls)]))
+	  int q = NEXT_Q_AFTER (q_ptr, stalls);
+	  if (!insn_queue[q].is_empty ())
 	    {
-	      for (; link; link = link->next ())
+	      unsigned int len = insn_queue[q].length ();
+	      for (unsigned int i = len - 1; i < len; i--)
 		{
-		  insn = link->insn ();
+		  insn = insn_queue[q][i];
 		  q_size -= 1;
 
 		  if (sched_verbose >= 2)
@@ -5165,7 +5180,7 @@ queue_to_ready (struct ready_list *ready)
 		  if (sched_verbose >= 2)
 		    fprintf (sched_dump, "moving to ready with %d stalls\n", stalls);
 		}
-	      free_INSN_LIST_list (&insn_queue[NEXT_Q_AFTER (q_ptr, stalls)]);
+	      insn_queue[q].release ();
 
 	      advance_one_cycle ();
 
@@ -5245,9 +5260,6 @@ static int
 early_queue_to_ready (state_t state, struct ready_list *ready)
 {
   rtx_insn *insn;
-  rtx_insn_list *link;
-  rtx_insn_list *next_link;
-  rtx_insn_list *prev_link;
   bool move_to_ready;
   int cost;
   state_t temp_state = alloca (dfa_state_size);
@@ -5273,66 +5285,54 @@ early_queue_to_ready (state_t state, struct ready_list *ready)
 
   for (stalls = 0; stalls <= max_insn_queue_index; stalls++)
     {
-      if ((link = insn_queue[NEXT_Q_AFTER (q_ptr, stalls)]))
-	{
-	  if (sched_verbose > 6)
-	    fprintf (sched_dump, ";; look at index %d + %d\n", q_ptr, stalls);
+      if (insn_queue[NEXT_Q_AFTER (q_ptr, stalls)].is_empty ())
+	continue;
 
-	  prev_link = 0;
-	  while (link)
-	    {
-	      next_link = link->next ();
-	      insn = link->insn ();
-	      if (insn && sched_verbose > 6)
-		print_rtl_single (sched_dump, insn);
-
-	      memcpy (temp_state, state, dfa_state_size);
-	      if (recog_memoized (insn) < 0)
-		/* non-negative to indicate that it's not ready
-		   to avoid infinite Q->R->Q->R... */
-		cost = 0;
-	      else
-		cost = state_transition (temp_state, insn);
+      if (sched_verbose > 6)
+	fprintf (sched_dump, ";; look at index %d + %d\n", q_ptr, stalls);
 
-	      if (sched_verbose >= 6)
-		fprintf (sched_dump, "transition cost = %d\n", cost);
+      unsigned int len = insn_queue[NEXT_Q_AFTER (q_ptr, stalls)].length ();
+      for (unsigned int i = len - 1; i < len; i--)
+	{
+	  insn = insn_queue[NEXT_Q_AFTER (q_ptr, stalls)][i];
+	  if (insn && sched_verbose > 6)
+	    print_rtl_single (sched_dump, insn);
+
+	  memcpy (temp_state, state, dfa_state_size);
+	  if (recog_memoized (insn) < 0)
+	    /* non-negative to indicate that it's not ready
+	       to avoid infinite Q->R->Q->R... */
+	    cost = 0;
+	  else
+	    cost = state_transition (temp_state, insn);
 
-	      move_to_ready = false;
-	      if (cost < 0)
-		{
-		  move_to_ready = ok_for_early_queue_removal (insn);
-		  if (move_to_ready == true)
-		    {
-		      /* move from Q to R */
-		      q_size -= 1;
-		      ready_add (ready, insn, false);
+	  if (sched_verbose >= 6)
+	    fprintf (sched_dump, "transition cost = %d\n", cost);
 
-		      if (prev_link)
-			XEXP (prev_link, 1) = next_link;
-		      else
-			insn_queue[NEXT_Q_AFTER (q_ptr, stalls)] = next_link;
+	  move_to_ready = false;
+	  if (cost < 0)
+	    {
+	      move_to_ready = ok_for_early_queue_removal (insn);
+	      if (move_to_ready == true)
+		{
+		  /* move from Q to R */
+		  q_size -= 1;
+		  ready_add (ready, insn, false);
 
-		      free_INSN_LIST_node (link);
+		  insn_queue[NEXT_Q_AFTER (q_ptr, stalls)].ordered_remove (i);
 
-		      if (sched_verbose >= 2)
-			fprintf (sched_dump, ";;\t\tEarly Q-->Ready: insn %s\n",
-				 (*current_sched_info->print_insn) (insn, 0));
+		  if (sched_verbose >= 2)
+		    fprintf (sched_dump, ";;\t\tEarly Q-->Ready: insn %s\n",
+			     (*current_sched_info->print_insn) (insn, 0));
 
-		      insns_removed++;
-		      if (insns_removed == flag_sched_stalled_insns)
-			/* Remove no more than flag_sched_stalled_insns insns
-			   from Q at a time.  */
-			return insns_removed;
-		    }
+		  insns_removed++;
+		  if (insns_removed == flag_sched_stalled_insns)
+		    /* Remove no more than flag_sched_stalled_insns insns
+		       from Q at a time.  */
+		    return insns_removed;
 		}
-
-	      if (move_to_ready == false)
-		prev_link = link;
-
-	      link = next_link;
-	    } /* while link */
-	} /* if link */
-
+	    }
+	} /* while link */
     } /* for stalls.. */
 
   return insns_removed;
@@ -5845,7 +5845,7 @@ autopref_multipass_dfa_lookahead_guard (rtx_insn *insn1, int ready_index)
 
       /* Everything from the current queue slot should have been moved to
 	 the ready list.  */
-      gcc_assert (insn_queue[NEXT_Q_AFTER (q_ptr, 0)] == NULL_RTX);
+      gcc_assert (insn_queue[NEXT_Q_AFTER (q_ptr, 0)].is_empty ());
 
       int n_stalls = PARAM_VALUE (PARAM_SCHED_AUTOPREF_QUEUE_DEPTH) - 1;
       if (n_stalls > max_insn_queue_index)
@@ -5853,11 +5853,12 @@ autopref_multipass_dfa_lookahead_guard (rtx_insn *insn1, int ready_index)
 
       for (int stalls = 1; stalls <= n_stalls; ++stalls)
 	{
-	  for (rtx_insn_list *link = insn_queue[NEXT_Q_AFTER (q_ptr, stalls)];
-	       link != NULL_RTX;
-	       link = link->next ())
+	  const vec<rtx_insn *> &insns =
+	    insn_queue[NEXT_Q_AFTER (q_ptr, stalls)];
+	  unsigned int len = insns.length ();
+	  for (unsigned int j = len - 1; j < len; j--)
 	    {
-	      rtx_insn *insn2 = link->insn ();
+	      rtx_insn *insn2 = insns[j];
 	      r = autopref_multipass_dfa_lookahead_guard_1 (insn1, insn2,
 							    write);
 	      if (r)
@@ -6578,7 +6579,7 @@ schedule_block (basic_block *target_bb, state_t init_state)
   q_ptr = 0;
   q_size = 0;
 
-  insn_queue = XALLOCAVEC (rtx_insn_list *, max_insn_queue_index + 1);
+  insn_queue = XALLOCAVEC (vec<rtx_insn *>, max_insn_queue_index + 1);
   memset (insn_queue, 0, (max_insn_queue_index + 1) * sizeof (rtx));
 
   /* Start just before the beginning of time.  */
@@ -7045,13 +7046,10 @@ schedule_block (basic_block *target_bb, state_t init_state)
 	}
       for (i = 0; i <= max_insn_queue_index; i++)
 	{
-	  rtx_insn_list *link;
-	  while ((link = insn_queue[i]) != NULL)
+	  rtx_insn *x;
+	  while ((x = insn_queue[i].pop ()))
 	    {
-	      rtx_insn *x = link->insn ();
-	      insn_queue[i] = link->next ();
 	      QUEUE_INDEX (x) = QUEUE_NOWHERE;
-	      free_INSN_LIST_node (link);
 	      resolve_dependencies (x);
 	    }
 	}
@@ -7086,16 +7084,15 @@ schedule_block (basic_block *target_bb, state_t init_state)
       if (q_size)
 	for (i = 0; i <= max_insn_queue_index; i++)
 	  {
-	    rtx_insn_list *link;
-	    for (link = insn_queue[i]; link; link = link->next ())
+	    unsigned int len = insn_queue[i].length ();
+	    for (unsigned int j = len - 1; j < len; j--)
 	      {
-		rtx_insn *x;
+		rtx_insn *x = insn_queue[i][j];
 
-		x = link->insn ();
 		QUEUE_INDEX (x) = QUEUE_NOWHERE;
 		TODO_SPEC (x) = HARD_DEP;
 	      }
-	    free_INSN_LIST_list (&insn_queue[i]);
+	    insn_queue[i].release ();
 	  }
     }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/18] add some utility methods to vec
  2016-04-20  6:19 ` [PATCH 11/18] add some utility methods to vec tbsaunde+gcc
@ 2016-04-20  9:13   ` Richard Biener
  2016-04-21  4:20     ` Trevor Saunders
  2016-04-20 12:29   ` Segher Boessenkool
  1 sibling, 1 reply; 60+ messages in thread
From: Richard Biener @ 2016-04-20  9:13 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: GCC Patches

On Wed, Apr 20, 2016 at 8:22 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> Later patches use these functions, and I believe Mikhail has mentioned before
> he'd like to have begin / end () on vec before.

begin() / end () is fine.  But contains ()?  That makes using a O(n) algorithm
too easy I think (we have qsort + bsearch for a more efficient way).

I suppose you are replacing linear list walks with contains () so it
might be ok...

At least stick some comment on contains () mentioning qsort / bsearch.

Ok with that change.

Richard.

> gcc/ChangeLog:
>
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
>         * vec.h (vec_safe_contains): New function.
>         (vec::contains): Likewise.
>         (vec::begin): Likewise.
>         (vec::end): Likewise.
> ---
>  gcc/vec.h | 39 ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/vec.h b/gcc/vec.h
> index ff57528..3c16e83 100644
> --- a/gcc/vec.h
> +++ b/gcc/vec.h
> @@ -454,6 +454,10 @@ public:
>    bool is_empty (void) const { return m_vecpfx.m_num == 0; }
>    T *address (void) { return m_vecdata; }
>    const T *address (void) const { return m_vecdata; }
> +  T *begin () { return address (); }
> +  const T *begin () const { return address (); }
> +  T *end () { return address () + length (); }
> +  const T *end () const { return address () + length (); }
>    const T &operator[] (unsigned) const;
>    T &operator[] (unsigned);
>    T &last (void);
> @@ -473,6 +477,7 @@ public:
>    void qsort (int (*) (const void *, const void *));
>    T *bsearch (const void *key, int (*compar)(const void *, const void *));
>    unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
> +  bool contains (const T &search) const;
>    static size_t embedded_size (unsigned);
>    void embedded_init (unsigned, unsigned = 0, unsigned = 0);
>    void quick_grow (unsigned len);
> @@ -542,7 +547,6 @@ vec_safe_is_empty (vec<T, A, vl_embed> *v)
>    return v ? v->is_empty () : true;
>  }
>
> -
>  /* If V does not have space for NELEMS elements, call
>     V->reserve(NELEMS, EXACT).  */
>  template<typename T, typename A>
> @@ -695,6 +699,12 @@ vec_safe_splice (vec<T, A, vl_embed> *&dst, const vec<T, A, vl_embed> *src
>      }
>  }
>
> +template<typename T, typename A>
> +inline bool
> +vec_safe_contains (vec<T, A, vl_embed> *v, const T &search)
> +{
> +  return v? v->contains (search) : false;
> +}
>
>  /* Index into vector.  Return the IX'th element.  IX must be in the
>     domain of the vector.  */
> @@ -973,6 +983,19 @@ vec<T, A, vl_embed>::bsearch (const void *key,
>    return NULL;
>  }
>
> +/* Return true if the vector contains search.  */
> +
> +template<typename T, typename A>
> +inline bool
> +vec<T, A, vl_embed>::contains (const T &search) const
> +{
> +  unsigned int len = length ();
> +  for (unsigned int i = 0; i < len; i++)
> +    if ((*this)[i] == search)
> +      return true;
> +
> +  return false;
> +}
>
>  /* Find and return the first position in which OBJ could be inserted
>     without changing the ordering of this vector.  LESSTHAN is a
> @@ -1167,6 +1190,10 @@ public:
>    const T *address (void) const
>    { return m_vec ? m_vec->m_vecdata : NULL; }
>
> +  T *begin () { return address (); }
> +  const T *begin () const { return address (); }
> +  T *end () { return begin () + length (); }
> +  const T *end () const { return begin () + length (); }
>    const T &operator[] (unsigned ix) const
>    { return (*m_vec)[ix]; }
>
> @@ -1208,6 +1235,7 @@ public:
>    void qsort (int (*) (const void *, const void *));
>    T *bsearch (const void *key, int (*compar)(const void *, const void *));
>    unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
> +  bool contains (const T &search) const;
>
>    bool using_auto_storage () const;
>
> @@ -1695,6 +1723,15 @@ vec<T, va_heap, vl_ptr>::lower_bound (T obj,
>    return m_vec ? m_vec->lower_bound (obj, lessthan) : 0;
>  }
>
> +/* Return true if the vector contains search.  */
> +
> +template<typename T>
> +inline bool
> +vec<T, va_heap, vl_ptr>::contains (const T &search) const
> +{
> +  return m_vec ? m_vec->contains (search) : false;
> +}
> +
>  template<typename T>
>  inline bool
>  vec<T, va_heap, vl_ptr>::using_auto_storage () const
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/18] make avail_stores a vec<rtx_insn *>
  2016-04-20  6:18 ` [PATCH 02/18] make avail_stores a vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20 11:32   ` Segher Boessenkool
  2016-04-22  5:19   ` Jeff Law
  2016-04-26 18:34   ` Richard Sandiford
  2 siblings, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 11:32 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:06AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> +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))

Useless parens.

> +	fputs (", ", file);
> +    }
> +  fputc ('}', file);
> +}

OCD wants a blank line before that closing brace print, just like the
one after the opening one, heh.

> @@ -697,7 +694,7 @@ compute_store_table (void)
>         ptr != NULL;
>         ptr = *prev_next_ptr_ptr)
>      {
> -      if (! ptr->avail_stores)
> +      if ( ptr->avail_stores.is_empty ())

Stray space char.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 03/18] make antic_stores a vec<rtx_insn *>
  2016-04-20  6:18 ` [PATCH 03/18] make antic_stores a " tbsaunde+gcc
@ 2016-04-20 11:40   ` Segher Boessenkool
  0 siblings, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 11:40 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:07AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> @@ -163,7 +162,7 @@ st_expr_entry (rtx x)
>  static void
>  free_st_expr_entry (struct st_expr * ptr)
>  {
> -  free_INSN_LIST_list (& ptr->antic_stores);
> +   ptr->antic_stores.release ();
>     ptr->avail_stores.release ();

It looks like indent went wrong, in a previous patch as well.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 05/18] make stores rtx_insn_list a vec
  2016-04-20  6:18 ` [PATCH 05/18] make stores rtx_insn_list " tbsaunde+gcc
@ 2016-04-20 11:45   ` Segher Boessenkool
  2016-04-22  5:08     ` Jeff Law
  0 siblings, 1 reply; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 11:45 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:09AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
> 
> 	* gcse.c (struct ls_expr): make stores field a vector.

Capital M.

> @@ -3604,7 +3604,7 @@ ldst_entry (rtx x)
>    ptr->expr         = NULL;
>    ptr->pattern      = x;
>    ptr->pattern_regs = NULL_RTX;
> -  ptr->stores       = NULL;
> +  ptr->stores      .create (0);

Spaces.

> @@ -3620,7 +3620,7 @@ ldst_entry (rtx x)
>  static void
>  free_ldst_entry (struct ls_expr * ptr)
>  {
> -  free_INSN_LIST_list (& ptr->stores);
> +   ptr->stores.release ();

Wrong indent.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks
  2016-04-20  6:19 ` [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks tbsaunde+gcc
@ 2016-04-20 12:17   ` Segher Boessenkool
  2016-04-20 20:21     ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 12:17 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:14AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> 	* config/microblaze/microblaze.c (microblaze_adjust_cost):
> 	* Likewise.

Stray * (here and elsewhere).

> --- a/gcc/config/alpha/alpha.c
> +++ b/gcc/config/alpha/alpha.c
> @@ -4758,14 +4758,15 @@ alpha_split_atomic_exchange_12 (rtx operands[])
>     a dependency LINK or INSN on DEP_INSN.  COST is the current cost.  */
>  
>  static int
> -alpha_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
> +alpha_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,

Why an int and not enum reg_note?

> +		   unsigned int)
>  {
>    enum attr_type dep_insn_type;
>  
>    /* If the dependence is an anti-dependence, there is no cost.  For an
>       output dependence, there is sometimes a cost, but it doesn't seem
>       worth handling those few cases.  */
> -  if (REG_NOTE_KIND (link) != 0)
> +  if (dep_type != 0)
>      return cost;

From reg-notes.def:

/* REG_DEP_TRUE is used in scheduler dependencies lists to represent a
   read-after-write dependency (i.e. a true data dependency).  This is
   here, not grouped with REG_DEP_ANTI and REG_DEP_OUTPUT, because some
   passes use a literal 0 for it.  */
REG_NOTE (DEP_TRUE)

Get rid of the literal 0 while you're at it?  Some places already have
REG_DEP_TRUE.

> @@ -4486,7 +4487,7 @@ c6x_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
>    if (insn_code_number >= 0)
>      insn_type = get_attr_type (insn);
>  
> -  kind = REG_NOTE_KIND (link);
> +  kind = (reg_note) dep_type;

Maybe it's just me, but it would look a lot less confusing with "enum".

>  static int
> -mips_adjust_cost (rtx_insn *insn ATTRIBUTE_UNUSED, rtx link,
> -		  rtx_insn *dep ATTRIBUTE_UNUSED, int cost)
> +mips_adjust_cost (rtx_insn *, int dep_type, rtx_insn *, int cost, unsigned int)
>  {
> -  if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT
> -      && TUNE_20KC)
> -    return cost;
> -  if (REG_NOTE_KIND (link) != 0)
> +  if (dep_type != 0 && (dep_type != REG_DEP_OUTPUT || !TUNE_20KC))
>      return 0;
>    return cost;
>  }

The original logic was a lot more readable (test positives, not negatives).

> +as a data-dependence.  If the scheduler using the automaton based pipeline
>  description, the cost of anti-dependence is zero and the cost of
>  output-dependence is maximum of one and the difference of latency
>  times of the first and the second insns.  If these values are not

"is using" (pre-existing, but hey).


So I wonder how much is gained by adding an extra unused argument to so
many places.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/18] add some utility methods to vec
  2016-04-20  6:19 ` [PATCH 11/18] add some utility methods to vec tbsaunde+gcc
  2016-04-20  9:13   ` Richard Biener
@ 2016-04-20 12:29   ` Segher Boessenkool
  1 sibling, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 12:29 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:15AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> +template<typename T, typename A>
> +inline bool
> +vec_safe_contains (vec<T, A, vl_embed> *v, const T &search)
> +{
> +  return v? v->contains (search) : false;
> +}

Missing space.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/18] make nonlocal_goto_handler_labels a vec
  2016-04-20  6:18 ` [PATCH 15/18] make nonlocal_goto_handler_labels a vec tbsaunde+gcc
@ 2016-04-20 12:36   ` Segher Boessenkool
  2016-04-25 12:43   ` Bernd Schmidt
  1 sibling, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 12:36 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:19AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> --- a/gcc/cfgrtl.c
> +++ b/gcc/cfgrtl.c
> @@ -157,7 +157,14 @@ delete_insn (rtx uncast_insn)
>  	    }
>  	}
>  
> -      remove_node_from_insn_list (insn, &nonlocal_goto_handler_labels);
> +
> +      unsigned int len = vec_safe_length (nonlocal_goto_handler_labels);
> +      for (unsigned int i = 0; i < len; i++)
> +	if ((*nonlocal_goto_handler_labels)[i] == insn)
> +	  {
> +	    nonlocal_goto_handler_labels->ordered_remove (i);
> +	    break;
> +	  }
>      }

Maybe you want a new helper function for this?

> @@ -4255,11 +4259,10 @@ cfg_layout_initialize (unsigned int flags)
>    record_effective_endpoints ();
>  
>    /* Make sure that the targets of non local gotos are marked.  */
> -  for (x = nonlocal_goto_handler_labels; x; x = x->next ())
> -    {
> -      bb = BLOCK_FOR_INSN (x->insn ());
> -      bb->flags |= BB_NON_LOCAL_GOTO_TARGET;
> -    }
> +  rtx_insn *temp;
> +  unsigned int i;
> +  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, temp)
> +      BLOCK_FOR_INSN (temp)->flags |= BB_NON_LOCAL_GOTO_TARGET;

Bad indent.

> @@ -3877,9 +3877,10 @@ set_initial_label_offsets (void)
>      if (x->insn ())
>        set_label_offsets (x->insn (), NULL, 1);
>  
> -  for (rtx_insn_list *x = nonlocal_goto_handler_labels; x; x = x->next ())
> -    if (x->insn ())
> -      set_label_offsets (x->insn (), NULL, 1);
> +  rtx_insn *insn;
> +  unsigned int i;
> +  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, insn)
> +      set_label_offsets (insn, NULL, 1);

Bad indent.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 16/18] make forced labels a vec
  2016-04-20  6:18 ` [PATCH 16/18] make forced labels a vec tbsaunde+gcc
@ 2016-04-20 12:41   ` Segher Boessenkool
  0 siblings, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 12:41 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:20AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> 	* function.h (struct expr_status): make x_forced_labels a vector.

Capital M.

> --- a/gcc/cfgrtl.c
> +++ b/gcc/cfgrtl.c
> @@ -115,7 +115,8 @@ can_delete_label_p (const rtx_code_label *label)
>    return (!LABEL_PRESERVE_P (label)
>  	  /* User declared labels must be preserved.  */
>  	  && LABEL_NAME (label) == 0
> -	  && !in_insn_list_p (forced_labels, label));
> +	  && !vec_safe_contains<rtx_insn *> (forced_labels,
> +					     const_cast<rtx_code_label *> (label)));
>  }

Line too long.  Rewrite this with a conditional, maybe?


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 17/18] make pending_{read,write}_insns vec<rtx_insn *>
  2016-04-20  6:18 ` [PATCH 17/18] make pending_{read,write}_insns vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20 12:50   ` Segher Boessenkool
  0 siblings, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 12:50 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:21AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> 	(add_insn_mem_dependence): Likewise. Likewise.

Likewise!

> @@ -1614,22 +1644,22 @@ remove_from_dependence_list (rtx_insn *insn, rtx_insn_list **listp)
>  /* Same as above, but process two lists at once.  */
>  static int
>  remove_from_both_dependence_lists (rtx_insn *insn,
> -				   rtx_insn_list **listp,
> +				   vec<rtx_insn *> *insns,
>  				   rtx_expr_list **exprp)
>  {
>    int removed = 0;
>  
> -  while (*listp)
> +  unsigned int len = insns->length ();
> +  for (unsigned int i = len - 1; i < len; i--)
>      {
> -      if (XEXP (*listp, 0) == insn)
> +      if ((*insns)[i] == insn)
>          {
> -          remove_free_INSN_LIST_node (listp);
> +	  insns->ordered_remove (i);
>            remove_free_EXPR_LIST_node (exprp);
>            removed++;
>            continue;
>          }
>  
> -      listp = (rtx_insn_list **)&XEXP (*listp, 1);
>        exprp = (rtx_expr_list **)&XEXP (*exprp, 1);
>      }

Tab-ify it all, not just the line you edit?

> @@ -2489,33 +2514,29 @@ sched_analyze_1 (struct deps_desc *deps, rtx x, rtx_insn *insn)
>  	}
>        else
>  	{
> -	  rtx_insn_list *pending;
>  	  rtx_expr_list *pending_mem;
>  
> -	  pending = deps->pending_read_insns;
> +	  unsigned int len = deps->pending_read_insns.length ();
>  	  pending_mem = deps->pending_read_mems;
> -	  while (pending)
> +	  for (unsigned int i = len - 1; i < len; i--)
>  	    {
> +	      rtx_insn *temp = deps->pending_read_insns[i];
>  	      if (anti_dependence (pending_mem->element (), t)
> -		  && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
> -		note_mem_dep (t, pending_mem->element (), pending->insn (),
> -			      DEP_ANTI);
> +		  && ! sched_insns_conditions_mutex_p (insn, temp))
> +		note_mem_dep (t, pending_mem->element (), temp, DEP_ANTI);

No space after "!" (yeah, pre-existing).  More of that later in the file.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 18/18] make last_pending_memory_flush a vec
  2016-04-20  6:37 ` [PATCH 18/18] make last_pending_memory_flush a vec tbsaunde+gcc
@ 2016-04-20 12:53   ` Segher Boessenkool
  0 siblings, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2016-04-20 12:53 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Wed, Apr 20, 2016 at 02:22:22AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> --- a/gcc/sched-rgn.c
> +++ b/gcc/sched-rgn.c
> @@ -2620,12 +2620,8 @@ deps_join (struct deps_desc *succ_deps, struct deps_desc *pred_deps)
>    concat_mem_list (pred_deps->pending_write_mems,
>  		   &succ_deps->pending_write_mems);
>  
> -  succ_deps->pending_jump_insns
> -    = concat_INSN_LIST (pred_deps->pending_jump_insns,
> -                        succ_deps->pending_jump_insns);
> -  succ_deps->last_pending_memory_flush
> -    = concat_INSN_LIST (pred_deps->last_pending_memory_flush,
> -                        succ_deps->last_pending_memory_flush);
> +  succ_deps->pending_jump_insns.safe_splice (pred_deps->pending_jump_insns);
> +  succ_deps->last_pending_memory_flush.safe_splice (pred_deps->last_pending_memory_flush);

Line too long.


Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list
  2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
                   ` (17 preceding siblings ...)
  2016-04-20  6:41 ` [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-20 13:03 ` Andi Kleen
  2016-04-20 23:18   ` Trevor Saunders
  2016-04-22  5:18   ` Jeff Law
  18 siblings, 2 replies; 60+ messages in thread
From: Andi Kleen @ 2016-04-20 13:03 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

tbsaunde+gcc@tbsaunde.org writes:

> I have some more patches that almost completely eliminate these, but I haven't
> tested the rest yet, and this is already a long series so it would be nice to
> get some of it out of my tree and reviewed.
>
> patches individually bootstrapped and regtested on x86_64-linux-gnu, ok? I
> expect none of this will more than textually conflict with something that may
> need backported to gcc-6, but its waited a month already I guess it can wait
> longer if people prefer.

A vector can have very different performance than a list, depending how
it is used. Do your patches cause any measure performance difference for
the compiler?

-Andi

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks
  2016-04-20 12:17   ` Segher Boessenkool
@ 2016-04-20 20:21     ` Trevor Saunders
  0 siblings, 0 replies; 60+ messages in thread
From: Trevor Saunders @ 2016-04-20 20:21 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: tbsaunde+gcc, gcc-patches

On Wed, Apr 20, 2016 at 07:17:03AM -0500, Segher Boessenkool wrote:
> On Wed, Apr 20, 2016 at 02:22:14AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> > 	* config/microblaze/microblaze.c (microblaze_adjust_cost):
> > 	* Likewise.
> 
> Stray * (here and elsewhere).
> 
> > --- a/gcc/config/alpha/alpha.c
> > +++ b/gcc/config/alpha/alpha.c
> > @@ -4758,14 +4758,15 @@ alpha_split_atomic_exchange_12 (rtx operands[])
> >     a dependency LINK or INSN on DEP_INSN.  COST is the current cost.  */
> >  
> >  static int
> > -alpha_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
> > +alpha_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
> 
> Why an int and not enum reg_note?

I think I just copied what adjust_cost_2 did, but using the enum makes
sense.

> 
> > +		   unsigned int)
> >  {
> >    enum attr_type dep_insn_type;
> >  
> >    /* If the dependence is an anti-dependence, there is no cost.  For an
> >       output dependence, there is sometimes a cost, but it doesn't seem
> >       worth handling those few cases.  */
> > -  if (REG_NOTE_KIND (link) != 0)
> > +  if (dep_type != 0)
> >      return cost;
> 
> From reg-notes.def:
> 
> /* REG_DEP_TRUE is used in scheduler dependencies lists to represent a
>    read-after-write dependency (i.e. a true data dependency).  This is
>    here, not grouped with REG_DEP_ANTI and REG_DEP_OUTPUT, because some
>    passes use a literal 0 for it.  */
> REG_NOTE (DEP_TRUE)
> 
> Get rid of the literal 0 while you're at it?  Some places already have
> REG_DEP_TRUE.

not entirely related to what the patch is doing, but not a bad idea.

> > @@ -4486,7 +4487,7 @@ c6x_adjust_cost (rtx_insn *insn, rtx link, rtx_insn *dep_insn, int cost)
> >    if (insn_code_number >= 0)
> >      insn_type = get_attr_type (insn);
> >  
> > -  kind = REG_NOTE_KIND (link);
> > +  kind = (reg_note) dep_type;
> 
> Maybe it's just me, but it would look a lot less confusing with "enum".

well, if you change the arg to be an enum then it goes away I think.

> >  static int
> > -mips_adjust_cost (rtx_insn *insn ATTRIBUTE_UNUSED, rtx link,
> > -		  rtx_insn *dep ATTRIBUTE_UNUSED, int cost)
> > +mips_adjust_cost (rtx_insn *, int dep_type, rtx_insn *, int cost, unsigned int)
> >  {
> > -  if (REG_NOTE_KIND (link) == REG_DEP_OUTPUT
> > -      && TUNE_20KC)
> > -    return cost;
> > -  if (REG_NOTE_KIND (link) != 0)
> > +  if (dep_type != 0 && (dep_type != REG_DEP_OUTPUT || !TUNE_20KC))
> >      return 0;
> >    return cost;
> >  }
> 
> The original logic was a lot more readable (test positives, not negatives).

 I'm not sure what I think there.

> > +as a data-dependence.  If the scheduler using the automaton based pipeline
> >  description, the cost of anti-dependence is zero and the cost of
> >  output-dependence is maximum of one and the difference of latency
> >  times of the first and the second insns.  If these values are not
> 
> "is using" (pre-existing, but hey).

makes sense I guess.

> So I wonder how much is gained by adding an extra unused argument to so
> many places.

Well that's just a side effect of merging the two hooks, so I'm not sure
what else you'd do other than not pass the arg to ia64, I'm not sure how
important it is there.  On the other hand the unused arg probably isn't
important relative to the indirect call to the hook.

Trev

> 
> 
> Segher

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list
  2016-04-20 13:03 ` [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list Andi Kleen
@ 2016-04-20 23:18   ` Trevor Saunders
  2016-04-25 12:37     ` Bernd Schmidt
  2016-04-22  5:18   ` Jeff Law
  1 sibling, 1 reply; 60+ messages in thread
From: Trevor Saunders @ 2016-04-20 23:18 UTC (permalink / raw)
  To: Andi Kleen; +Cc: tbsaunde+gcc, gcc-patches

On Wed, Apr 20, 2016 at 06:03:01AM -0700, Andi Kleen wrote:
> tbsaunde+gcc@tbsaunde.org writes:
> 
> > I have some more patches that almost completely eliminate these, but I haven't
> > tested the rest yet, and this is already a long series so it would be nice to
> > get some of it out of my tree and reviewed.
> >
> > patches individually bootstrapped and regtested on x86_64-linux-gnu, ok? I
> > expect none of this will more than textually conflict with something that may
> > need backported to gcc-6, but its waited a month already I guess it can wait
> > longer if people prefer.
> 
> A vector can have very different performance than a list, depending how
> it is used. Do your patches cause any measure performance difference for
> the compiler?

I haven't measured, but I am aware of that and did consider it when
writing these patches.  I expect they'll help perf some since I went
through some hoops to not move elements around the vector unnecessarily.
I'm not really sure what work load is most effected by each of these
patches, and they don't really seem that risky to me so I'd rather notdo
tons of testing on the off chance they slow something down, in the worst
case we can always revert something to a list without using rtx.

Trev

> 
> -Andi

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/18] add some utility methods to vec
  2016-04-20  9:13   ` Richard Biener
@ 2016-04-21  4:20     ` Trevor Saunders
  0 siblings, 0 replies; 60+ messages in thread
From: Trevor Saunders @ 2016-04-21  4:20 UTC (permalink / raw)
  To: Richard Biener; +Cc: tbsaunde+gcc, GCC Patches

On Wed, Apr 20, 2016 at 11:13:42AM +0200, Richard Biener wrote:
> On Wed, Apr 20, 2016 at 8:22 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >
> > Later patches use these functions, and I believe Mikhail has mentioned before
> > he'd like to have begin / end () on vec before.
> 
> begin() / end () is fine.  But contains ()?  That makes using a O(n) algorithm
> too easy I think (we have qsort + bsearch for a more efficient way).

 Well, contains is better if you will search less than log(n) times.

> I suppose you are replacing linear list walks with contains () so it
> might be ok...

yeah, and I'm not really sure how much open coding it will actually make
people think more than they would otherwise.

> At least stick some comment on contains () mentioning qsort / bsearch.

sure

Trev

> 
> Ok with that change.
> 
> Richard.
> 
> > gcc/ChangeLog:
> >
> > 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
> >
> >         * vec.h (vec_safe_contains): New function.
> >         (vec::contains): Likewise.
> >         (vec::begin): Likewise.
> >         (vec::end): Likewise.
> > ---
> >  gcc/vec.h | 39 ++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 38 insertions(+), 1 deletion(-)
> >
> > diff --git a/gcc/vec.h b/gcc/vec.h
> > index ff57528..3c16e83 100644
> > --- a/gcc/vec.h
> > +++ b/gcc/vec.h
> > @@ -454,6 +454,10 @@ public:
> >    bool is_empty (void) const { return m_vecpfx.m_num == 0; }
> >    T *address (void) { return m_vecdata; }
> >    const T *address (void) const { return m_vecdata; }
> > +  T *begin () { return address (); }
> > +  const T *begin () const { return address (); }
> > +  T *end () { return address () + length (); }
> > +  const T *end () const { return address () + length (); }
> >    const T &operator[] (unsigned) const;
> >    T &operator[] (unsigned);
> >    T &last (void);
> > @@ -473,6 +477,7 @@ public:
> >    void qsort (int (*) (const void *, const void *));
> >    T *bsearch (const void *key, int (*compar)(const void *, const void *));
> >    unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
> > +  bool contains (const T &search) const;
> >    static size_t embedded_size (unsigned);
> >    void embedded_init (unsigned, unsigned = 0, unsigned = 0);
> >    void quick_grow (unsigned len);
> > @@ -542,7 +547,6 @@ vec_safe_is_empty (vec<T, A, vl_embed> *v)
> >    return v ? v->is_empty () : true;
> >  }
> >
> > -
> >  /* If V does not have space for NELEMS elements, call
> >     V->reserve(NELEMS, EXACT).  */
> >  template<typename T, typename A>
> > @@ -695,6 +699,12 @@ vec_safe_splice (vec<T, A, vl_embed> *&dst, const vec<T, A, vl_embed> *src
> >      }
> >  }
> >
> > +template<typename T, typename A>
> > +inline bool
> > +vec_safe_contains (vec<T, A, vl_embed> *v, const T &search)
> > +{
> > +  return v? v->contains (search) : false;
> > +}
> >
> >  /* Index into vector.  Return the IX'th element.  IX must be in the
> >     domain of the vector.  */
> > @@ -973,6 +983,19 @@ vec<T, A, vl_embed>::bsearch (const void *key,
> >    return NULL;
> >  }
> >
> > +/* Return true if the vector contains search.  */
> > +
> > +template<typename T, typename A>
> > +inline bool
> > +vec<T, A, vl_embed>::contains (const T &search) const
> > +{
> > +  unsigned int len = length ();
> > +  for (unsigned int i = 0; i < len; i++)
> > +    if ((*this)[i] == search)
> > +      return true;
> > +
> > +  return false;
> > +}
> >
> >  /* Find and return the first position in which OBJ could be inserted
> >     without changing the ordering of this vector.  LESSTHAN is a
> > @@ -1167,6 +1190,10 @@ public:
> >    const T *address (void) const
> >    { return m_vec ? m_vec->m_vecdata : NULL; }
> >
> > +  T *begin () { return address (); }
> > +  const T *begin () const { return address (); }
> > +  T *end () { return begin () + length (); }
> > +  const T *end () const { return begin () + length (); }
> >    const T &operator[] (unsigned ix) const
> >    { return (*m_vec)[ix]; }
> >
> > @@ -1208,6 +1235,7 @@ public:
> >    void qsort (int (*) (const void *, const void *));
> >    T *bsearch (const void *key, int (*compar)(const void *, const void *));
> >    unsigned lower_bound (T, bool (*)(const T &, const T &)) const;
> > +  bool contains (const T &search) const;
> >
> >    bool using_auto_storage () const;
> >
> > @@ -1695,6 +1723,15 @@ vec<T, va_heap, vl_ptr>::lower_bound (T obj,
> >    return m_vec ? m_vec->lower_bound (obj, lessthan) : 0;
> >  }
> >
> > +/* Return true if the vector contains search.  */
> > +
> > +template<typename T>
> > +inline bool
> > +vec<T, va_heap, vl_ptr>::contains (const T &search) const
> > +{
> > +  return m_vec ? m_vec->contains (search) : false;
> > +}
> > +
> >  template<typename T>
> >  inline bool
> >  vec<T, va_heap, vl_ptr>::using_auto_storage () const
> > --
> > 2.7.4
> >

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/18] stop using rtx_insn_list in reorg.c
  2016-04-20  6:17 ` [PATCH 01/18] stop using rtx_insn_list in reorg.c tbsaunde+gcc
@ 2016-04-22  5:03   ` Jeff Law
  2016-04-25  9:35   ` Bernd Schmidt
  1 sibling, 0 replies; 60+ messages in thread
From: Jeff Law @ 2016-04-22  5:03 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 12:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> gcc/ChangeLog:
>
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
> 	* reorg.c (try_merge_delay_insns): Make merged_insns a vector.
OK.
jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 04/18] remove unused loads rtx_insn_list
  2016-04-20  6:18 ` [PATCH 04/18] remove unused loads rtx_insn_list tbsaunde+gcc
@ 2016-04-22  5:05   ` Jeff Law
  0 siblings, 0 replies; 60+ messages in thread
From: Jeff Law @ 2016-04-22  5:05 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 12:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> gcc/ChangeLog:
>
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
> 	* gcse.c (struct ls_expr): Remove loads field.
> 	(ldst_entry): Adjust.
> 	(free_ldst_entry): Likewise.
> 	(print_ldst_list): Likewise.
> 	(compute_ld_motion_mems): Likewise.
OK.
jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 05/18] make stores rtx_insn_list a vec
  2016-04-20 11:45   ` Segher Boessenkool
@ 2016-04-22  5:08     ` Jeff Law
  0 siblings, 0 replies; 60+ messages in thread
From: Jeff Law @ 2016-04-22  5:08 UTC (permalink / raw)
  To: Segher Boessenkool, tbsaunde+gcc; +Cc: gcc-patches

On 04/20/2016 05:45 AM, Segher Boessenkool wrote:
> On Wed, Apr 20, 2016 at 02:22:09AM -0400, tbsaunde+gcc@tbsaunde.org wrote:
>> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>>
>> 	* gcse.c (struct ls_expr): make stores field a vector.
>
> Capital M.
>
>> @@ -3604,7 +3604,7 @@ ldst_entry (rtx x)
>>     ptr->expr         = NULL;
>>     ptr->pattern      = x;
>>     ptr->pattern_regs = NULL_RTX;
>> -  ptr->stores       = NULL;
>> +  ptr->stores      .create (0);
>
> Spaces.
>
>> @@ -3620,7 +3620,7 @@ ldst_entry (rtx x)
>>   static void
>>   free_ldst_entry (struct ls_expr * ptr)
>>   {
>> -  free_INSN_LIST_list (& ptr->stores);
>> +   ptr->stores.release ();
>
> Wrong indent.
Patch is OK with those nits fixed.

jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 08/18] make side_effects a vec<rtx>
  2016-04-20  6:18 ` [PATCH 08/18] make side_effects a vec<rtx> tbsaunde+gcc
@ 2016-04-22  5:18   ` Jeff Law
  2016-04-22 12:05     ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Jeff Law @ 2016-04-22  5:18 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 12:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> gcc/ChangeLog:
>
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
> 	* var-tracking.c (struct adjust_mem_data): Make side_effects a vector.
> 	(adjust_mems): Adjust.
> 	(adjust_insn): Likewise.
> 	(prepare_call_arguments): Likewise.
> ---
>   gcc/var-tracking.c | 30 +++++++++++-------------------
>   1 file changed, 11 insertions(+), 19 deletions(-)
>
> diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
> index 9f09d30..7fc6ed3 100644
> --- a/gcc/var-tracking.c
> +++ b/gcc/var-tracking.c
> @@ -926,7 +926,7 @@ struct adjust_mem_data
>     bool store;
>     machine_mode mem_mode;
>     HOST_WIDE_INT stack_adjust;
> -  rtx_expr_list *side_effects;
> +  auto_vec<rtx> side_effects;
>   };
Is auto_vec what you really want here?  AFAICT this object is never 
destructed, so we're not releasing the memory.  Am I missing something here?


Jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list
  2016-04-20 13:03 ` [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list Andi Kleen
  2016-04-20 23:18   ` Trevor Saunders
@ 2016-04-22  5:18   ` Jeff Law
  1 sibling, 0 replies; 60+ messages in thread
From: Jeff Law @ 2016-04-22  5:18 UTC (permalink / raw)
  To: Andi Kleen, tbsaunde+gcc; +Cc: gcc-patches

On 04/20/2016 07:03 AM, Andi Kleen wrote:
> tbsaunde+gcc@tbsaunde.org writes:
>
>> I have some more patches that almost completely eliminate these, but I haven't
>> tested the rest yet, and this is already a long series so it would be nice to
>> get some of it out of my tree and reviewed.
>>
>> patches individually bootstrapped and regtested on x86_64-linux-gnu, ok? I
>> expect none of this will more than textually conflict with something that may
>> need backported to gcc-6, but its waited a month already I guess it can wait
>> longer if people prefer.
>
> A vector can have very different performance than a list, depending how
> it is used. Do your patches cause any measure performance difference for
> the compiler?
I've waffled between using a forward list and a vector for this stuff in 
the past.  The cases Trevor has changed so far seem suitable for either 
without a performance impact either way.

jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/18] make avail_stores a vec<rtx_insn *>
  2016-04-20  6:18 ` [PATCH 02/18] make avail_stores a vec<rtx_insn *> tbsaunde+gcc
  2016-04-20 11:32   ` Segher Boessenkool
@ 2016-04-22  5:19   ` Jeff Law
  2016-04-26 18:34   ` Richard Sandiford
  2 siblings, 0 replies; 60+ messages in thread
From: Jeff Law @ 2016-04-22  5:19 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 12:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> gcc/ChangeLog:
>
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
> 	* print-rtl.c (print_rtx_insn_vec): New function.
> 	* print-rtl.h: New prototype.
> 	* rtl.h: Likewise.
> 	* 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.
> ---
>   gcc/print-rtl.c    | 15 +++++++++++++++
>   gcc/print-rtl.h    |  1 +
>   gcc/rtl.h          |  1 +
>   gcc/store-motion.c | 31 +++++++++++++++----------------
>   4 files changed, 32 insertions(+), 16 deletions(-)
>
> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> index 85d9b8d..cf4922f 100644
> --- a/gcc/print-rtl.c
> +++ b/gcc/print-rtl.c
> @@ -870,6 +870,21 @@ print_simple_rtl (FILE *outf, const_rtx x)
>     flag_simple = 0;
>   }
>
> +void
> +print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec)
Function comment.

> index 8267252..167c090 100644
> --- a/gcc/rtl.h
> +++ b/gcc/rtl.h
> @@ -3572,6 +3572,7 @@ extern void print_simple_rtl (FILE *, const_rtx);
>   extern int print_rtl_single (FILE *, const_rtx);
>   extern int print_rtl_single_with_indent (FILE *, const_rtx, int);
>   extern void print_inline_rtx (FILE *, const_rtx, int);
> +extern void print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec);
Why a prototype in rtl.h rather than including print-rtl wherever it was 
needed?


OK with the nits pointed out by Segher fixed and those pointed out above 
fixed.

jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 08/18] make side_effects a vec<rtx>
  2016-04-22  5:18   ` Jeff Law
@ 2016-04-22 12:05     ` Trevor Saunders
  2016-04-28  4:29       ` Jeff Law
  0 siblings, 1 reply; 60+ messages in thread
From: Trevor Saunders @ 2016-04-22 12:05 UTC (permalink / raw)
  To: Jeff Law; +Cc: tbsaunde+gcc, gcc-patches

On Thu, Apr 21, 2016 at 11:12:48PM -0600, Jeff Law wrote:
> On 04/20/2016 12:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >
> >gcc/ChangeLog:
> >
> >2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
> >
> >	* var-tracking.c (struct adjust_mem_data): Make side_effects a vector.
> >	(adjust_mems): Adjust.
> >	(adjust_insn): Likewise.
> >	(prepare_call_arguments): Likewise.
> >---
> >  gcc/var-tracking.c | 30 +++++++++++-------------------
> >  1 file changed, 11 insertions(+), 19 deletions(-)
> >
> >diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
> >index 9f09d30..7fc6ed3 100644
> >--- a/gcc/var-tracking.c
> >+++ b/gcc/var-tracking.c
> >@@ -926,7 +926,7 @@ struct adjust_mem_data
> >    bool store;
> >    machine_mode mem_mode;
> >    HOST_WIDE_INT stack_adjust;
> >-  rtx_expr_list *side_effects;
> >+  auto_vec<rtx> side_effects;
> >  };
> Is auto_vec what you really want here?  AFAICT this object is never
> destructed, so we're not releasing the memory.  Am I missing something here?

it is destructed, auto_vec has a destructor, there for adjust_mem_data
has a destructor since it has a field with a destructor.
adjust_mem_data is always on the stack so the compiler deals with making
sure the destructor is called when it goes out of scope.

Trev

> 
> 
> Jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/18] stop using rtx_insn_list in reorg.c
  2016-04-20  6:17 ` [PATCH 01/18] stop using rtx_insn_list in reorg.c tbsaunde+gcc
  2016-04-22  5:03   ` Jeff Law
@ 2016-04-25  9:35   ` Bernd Schmidt
  2016-04-25 13:39     ` Trevor Saunders
  1 sibling, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25  9:35 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> -  rtx_insn_list *merged_insns = 0;
> +  auto_vec<std::pair<rtx_insn *, bool>, 10> merged_insns;

I see Jeff has already acked this, but some of the expressions here are 
getting unwieldy. can we maybe shorten some of this using typedefs?


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
  2016-04-20  6:18 ` [PATCH 07/18] loop-iv.c: make cond_list a vec tbsaunde+gcc
@ 2016-04-25 12:29   ` Bernd Schmidt
  2016-04-25 13:31     ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 12:29 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

> +		  unsigned int len = cond_list.length ();
> +		  for (unsigned int i = len - 1; i < len; i--)

This is a really icky way to write a loop, the i < len condition makes 
it look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any 
reason not to use these?


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list
  2016-04-20 23:18   ` Trevor Saunders
@ 2016-04-25 12:37     ` Bernd Schmidt
  0 siblings, 0 replies; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 12:37 UTC (permalink / raw)
  To: Trevor Saunders, Andi Kleen; +Cc: tbsaunde+gcc, gcc-patches

On 04/21/2016 01:24 AM, Trevor Saunders wrote:
> On Wed, Apr 20, 2016 at 06:03:01AM -0700, Andi Kleen wrote:

>> A vector can have very different performance than a list, depending how
>> it is used. Do your patches cause any measure performance difference for
>> the compiler?
>
> I haven't measured, but I am aware of that and did consider it when
> writing these patches.  I expect they'll help perf some since I went
> through some hoops to not move elements around the vector unnecessarily.
> I'm not really sure what work load is most effected by each of these
> patches, and they don't really seem that risky to me so I'd rather notdo
> tons of testing on the off chance they slow something down, in the worst
> case we can always revert something to a list without using rtx.

Well, at least post before/after numbers (with all patches applied for 
the "after") for compiling a large source file, including time and 
memory reports.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/18] make nonlocal_goto_handler_labels a vec
  2016-04-20  6:18 ` [PATCH 15/18] make nonlocal_goto_handler_labels a vec tbsaunde+gcc
  2016-04-20 12:36   ` Segher Boessenkool
@ 2016-04-25 12:43   ` Bernd Schmidt
  2016-04-25 13:44     ` Trevor Saunders
  1 sibling, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 12:43 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> -      remove_node_from_insn_list (insn, &nonlocal_goto_handler_labels);
> +
> +      unsigned int len = vec_safe_length (nonlocal_goto_handler_labels);
> +      for (unsigned int i = 0; i < len; i++)
> +	if ((*nonlocal_goto_handler_labels)[i] == insn)
> +	  {
> +	    nonlocal_goto_handler_labels->ordered_remove (i);
> +	    break;
> +	  }

Why not unordered_remove?

Should there be a vec-based version of remove-node_from_*_list?

> +  rtx_insn *temp;
> +  unsigned int i;
> +  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, temp)
> +      BLOCK_FOR_INSN (temp)->flags |= BB_NON_LOCAL_GOTO_TARGET;

Indentation looks wrong.

>
>         /* Process non-local goto edges.  */
>         if (can_nonlocal_goto (insn))
> -	for (rtx_insn_list *lab = nonlocal_goto_handler_labels;
> -	     lab;
> -	     lab = lab->next ())
> -	  maybe_record_trace_start_abnormal (lab->insn (), insn);
> +	{

Unnecessary brace?

>     /* Re-insert the EH_REGION notes.  */
> -  if (eh_note || (was_call && nonlocal_goto_handler_labels))
> +  if (eh_note || (was_call && vec_safe_length (nonlocal_goto_handler_labels)))

I'm not a big fan of omitting the > 0 and using the integer as a 
boolean. Multiple occurrences.

> +  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, insn)
> +      set_label_offsets (insn, NULL, 1);

Indentation.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 09/18] make pattern_regs a vec
  2016-04-20  6:18 ` [PATCH 09/18] make pattern_regs a vec tbsaunde+gcc
@ 2016-04-25 12:56   ` Bernd Schmidt
  2016-04-25 13:23     ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 12:56 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
>
> -static rtx_expr_list *
> +static vec<rtx>
>   extract_mentioned_regs (rtx x)
>   {
> -  rtx_expr_list *mentioned_regs = NULL;
> +  vec<rtx> mentioned_regs = vNULL;
>     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);
> +	mentioned_regs.safe_push (x);
>       }
>     return mentioned_regs;
>   }

Is it really such a great idea to return a vec by value? I'd rather pass 
a pointer to it into the function and operate on that.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 09/18] make pattern_regs a vec
  2016-04-25 12:56   ` Bernd Schmidt
@ 2016-04-25 13:23     ` Trevor Saunders
  0 siblings, 0 replies; 60+ messages in thread
From: Trevor Saunders @ 2016-04-25 13:23 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Mon, Apr 25, 2016 at 02:56:07PM +0200, Bernd Schmidt wrote:
> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >
> >-static rtx_expr_list *
> >+static vec<rtx>
> >  extract_mentioned_regs (rtx x)
> >  {
> >-  rtx_expr_list *mentioned_regs = NULL;
> >+  vec<rtx> mentioned_regs = vNULL;
> >    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);
> >+	mentioned_regs.safe_push (x);
> >      }
> >    return mentioned_regs;
> >  }
> 
> Is it really such a great idea to return a vec by value? I'd rather pass a
> pointer to it into the function and operate on that.

Well, at the moment its harmless since vec is POD and so you just copy
the pointer to the data (note there are other places that do this).
However I agree it would be nice to stop returning vec<>.

Trev

> 
> 
> Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
  2016-04-25 12:29   ` Bernd Schmidt
@ 2016-04-25 13:31     ` Trevor Saunders
  2016-04-25 14:21       ` Bernd Schmidt
  0 siblings, 1 reply; 60+ messages in thread
From: Trevor Saunders @ 2016-04-25 13:31 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Mon, Apr 25, 2016 at 02:28:51PM +0200, Bernd Schmidt wrote:
> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> 
> >+		  unsigned int len = cond_list.length ();
> >+		  for (unsigned int i = len - 1; i < len; i--)
> 
> This is a really icky way to write a loop, the i < len condition makes it
> look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any reason not
> to use these?

I'll agree that depending on unsigned wrapping is a tad wierd, but
personally I think FOR_EACH_VEC_* are pretty icky, and just forget to
think about them before writing a loop.  The vec::iterate () methods are
a little slower than they need to be since they check the vector length
each iteration instead of caching it (and pretty sure the compiler can't
save you in a bunch of these places).  Its Unfortunate you need to
declare a temporary for the vector item, and worse that temporary can't
be scoped by the loop.  Finally it seems like more work to remember
the order of arguments to FOR_EACH_VEC_ than just to write the loop.
That all said if people really feel strongly and I'll grant consistancy
matters I can try and change loops to use FOR_EACH_VEC_*.

Trev

> 
> 
> Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/18] stop using rtx_insn_list in reorg.c
  2016-04-25  9:35   ` Bernd Schmidt
@ 2016-04-25 13:39     ` Trevor Saunders
  0 siblings, 0 replies; 60+ messages in thread
From: Trevor Saunders @ 2016-04-25 13:39 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Mon, Apr 25, 2016 at 11:35:16AM +0200, Bernd Schmidt wrote:
> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >-  rtx_insn_list *merged_insns = 0;
> >+  auto_vec<std::pair<rtx_insn *, bool>, 10> merged_insns;
> 
> I see Jeff has already acked this, but some of the expressions here are
> getting unwieldy. can we maybe shorten some of this using typedefs?

I guess you could shorten std::pair<rtx_insn *, bool> to insn_bool_pair
or something, I don't have a great descriptive name.  It was only used 3
times I think, so I wasn't terribly concerned, but I'd be happy to
change it.

Trev

> 
> 
> Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/18] make nonlocal_goto_handler_labels a vec
  2016-04-25 12:43   ` Bernd Schmidt
@ 2016-04-25 13:44     ` Trevor Saunders
  0 siblings, 0 replies; 60+ messages in thread
From: Trevor Saunders @ 2016-04-25 13:44 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Mon, Apr 25, 2016 at 02:43:27PM +0200, Bernd Schmidt wrote:
> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >-      remove_node_from_insn_list (insn, &nonlocal_goto_handler_labels);
> >+
> >+      unsigned int len = vec_safe_length (nonlocal_goto_handler_labels);
> >+      for (unsigned int i = 0; i < len; i++)
> >+	if ((*nonlocal_goto_handler_labels)[i] == insn)
> >+	  {
> >+	    nonlocal_goto_handler_labels->ordered_remove (i);
> >+	    break;
> >+	  }
> 
> Why not unordered_remove?

I believe it was to keep the same behavior as what was done with lists.
I'm not sure that matters, but I don't think that I understand
everything involved well enough to say it definitely does not matter so
I wanted to be safe and avoid introducing bugs.

> Should there be a vec-based version of remove-node_from_*_list?

Maybe, but I will echo Richard's concern about making O(N) operations
easy.

> >+  rtx_insn *temp;
> >+  unsigned int i;
> >+  FOR_EACH_VEC_SAFE_ELT_REVERSE (nonlocal_goto_handler_labels, i, temp)
> >+      BLOCK_FOR_INSN (temp)->flags |= BB_NON_LOCAL_GOTO_TARGET;
> 
> Indentation looks wrong.

Sorry

> >
> >        /* Process non-local goto edges.  */
> >        if (can_nonlocal_goto (insn))
> >-	for (rtx_insn_list *lab = nonlocal_goto_handler_labels;
> >-	     lab;
> >-	     lab = lab->next ())
> >-	  maybe_record_trace_start_abnormal (lab->insn (), insn);
> >+	{
> 
> Unnecessary brace?

Will check

> >    /* Re-insert the EH_REGION notes.  */
> >-  if (eh_note || (was_call && nonlocal_goto_handler_labels))
> >+  if (eh_note || (was_call && vec_safe_length (nonlocal_goto_handler_labels)))
> 
> I'm not a big fan of omitting the > 0 and using the integer as a boolean.
> Multiple occurrences.

ok, I spend a lot of time working on code where that is the style, so
its habbit sorry.

Trev

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  2016-04-20  6:41 ` [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *> tbsaunde+gcc
@ 2016-04-25 13:55   ` Bernd Schmidt
  2016-04-25 14:13     ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 13:55 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> -/* Remove INSN from queue.  */
> +/* Remove INSN at idx from queue.  */
> +static void
> +queue_remove (unsigned int q, unsigned int idx)
> +{
> +  QUEUE_INDEX (insn_queue[q][idx]) = QUEUE_NOWHERE;
> +  insn_queue[q].ordered_remove (idx);
> +  q_size--;

I think I'm nacking this one, sorry. I don't think ordered_removes in 
the scheduler queues are going to fly.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  2016-04-25 13:55   ` Bernd Schmidt
@ 2016-04-25 14:13     ` Trevor Saunders
  2016-05-03 12:37       ` Bernd Schmidt
  0 siblings, 1 reply; 60+ messages in thread
From: Trevor Saunders @ 2016-04-25 14:13 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Mon, Apr 25, 2016 at 03:55:15PM +0200, Bernd Schmidt wrote:
> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >-/* Remove INSN from queue.  */
> >+/* Remove INSN at idx from queue.  */
> >+static void
> >+queue_remove (unsigned int q, unsigned int idx)
> >+{
> >+  QUEUE_INDEX (insn_queue[q][idx]) = QUEUE_NOWHERE;
> >+  insn_queue[q].ordered_remove (idx);
> >+  q_size--;
> 
> I think I'm nacking this one, sorry. I don't think ordered_removes in the
> scheduler queues are going to fly.

So, we're going from a linear walk through a linked list to linear scan
of part of a vector and memcpy of the rest.  That's certainly not great,
but the linked list walk doesn't seem great either.  Is unordered_remove
here safe?  Or do you have some other idea?  I guess we could write a
forward_list.

Trev

> 
> 
> Bernd
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
  2016-04-25 13:31     ` Trevor Saunders
@ 2016-04-25 14:21       ` Bernd Schmidt
  2016-04-25 14:25         ` Bernd Schmidt
  0 siblings, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 14:21 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, gcc-patches

On 04/25/2016 03:30 PM, Trevor Saunders wrote:
> On Mon, Apr 25, 2016 at 02:28:51PM +0200, Bernd Schmidt wrote:
>> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
>>> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>>
>>> +		  unsigned int len = cond_list.length ();
>>> +		  for (unsigned int i = len - 1; i < len; i--)
>>
>> This is a really icky way to write a loop, the i < len condition makes it
>> look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any reason not
>> to use these?
>
> I'll agree that depending on unsigned wrapping is a tad wierd, but
> personally I think FOR_EACH_VEC_* are pretty icky, and just forget to
> think about them before writing a loop.

They're standard inside gcc though, and readability-wise much 
preferrable to the above IMO.

I noticed this pattern in a lot of these patches; at this point I think 
the best thing to do would be for you to go through all of them, address 
review comments across the whole set, and then start a new thread with 
v2 patches of all of them so we can retire this thread.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 06/18] move reg_equivs out of gc memory
  2016-04-20  6:19 ` [PATCH 06/18] move reg_equivs out of gc memory tbsaunde+gcc
@ 2016-04-25 14:22   ` Bernd Schmidt
  0 siblings, 0 replies; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 14:22 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> It used the gc vector type, but isn't marked as a gc route, and appears
> to be manually managed, so it should be safe to use the normal heap
> vector.
>
> gcc/ChangeLog:
>
> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
> 	* ira-emit.c (emit_move_list): Adjust.
> 	* ira.c (fix_reg_equiv_init): Likewise.
> 	(update_equiv_regs): Likewise.
> 	(ira): Likewise.
> 	(do_reload): Likewise.
> 	* reload.c (subst_reloads): Likewise.
> 	* reload.h (reg_equivs): Move to the normal heap.
> 	* reload1.c (grow_reg_equivs): Adjust.
> 	(reload): Likewise.
> 	(eliminate_regs_1): Likewise.
> 	(elimination_effects): Likewise.
> 	(init_eliminable_invariants): Likewise.
> 	(free_reg_equiv): Likewise.

I wonder whether this is really worth it. The improvement is marginal, 
and there is a real cost associated with patches such as this one when 
people need to work across multiple branches.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
  2016-04-25 14:21       ` Bernd Schmidt
@ 2016-04-25 14:25         ` Bernd Schmidt
  2016-04-27  1:30           ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-04-25 14:25 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, gcc-patches

On 04/25/2016 04:21 PM, Bernd Schmidt wrote:
> On 04/25/2016 03:30 PM, Trevor Saunders wrote:
>> On Mon, Apr 25, 2016 at 02:28:51PM +0200, Bernd Schmidt wrote:
>>> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
>>>> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>>>
>>>> +          unsigned int len = cond_list.length ();
>>>> +          for (unsigned int i = len - 1; i < len; i--)
>>>
>>> This is a really icky way to write a loop, the i < len condition
>>> makes it
>>> look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any
>>> reason not
>>> to use these?
>>
>> I'll agree that depending on unsigned wrapping is a tad wierd, but
>> personally I think FOR_EACH_VEC_* are pretty icky, and just forget to
>> think about them before writing a loop.
>
> They're standard inside gcc though, and readability-wise much
> preferrable to the above IMO.
>
> I noticed this pattern in a lot of these patches; at this point I think
> the best thing to do would be for you to go through all of them, address
> review comments across the whole set, and then start a new thread with
> v2 patches of all of them so we can retire this thread.
>
Oh, and also - I would prefer for each nontrivial such loop some sort of 
analysis about what order elements were inserted/processed in before 
this change, and what order afterwards. This could be a source of subtle 
errors with this patch series. When removing elements in a loop, we also 
need to pay attention to whether that's still safe.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/18] make avail_stores a vec<rtx_insn *>
  2016-04-20  6:18 ` [PATCH 02/18] make avail_stores a vec<rtx_insn *> tbsaunde+gcc
  2016-04-20 11:32   ` Segher Boessenkool
  2016-04-22  5:19   ` Jeff Law
@ 2016-04-26 18:34   ` Richard Sandiford
  2 siblings, 0 replies; 60+ messages in thread
From: Richard Sandiford @ 2016-04-26 18:34 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

Another style nit on top of the ones already posted, sorry:

tbsaunde+gcc@tbsaunde.org writes:
> +void
> +print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec)
> +{
> +  fputc('{', file);

missing space before '('.

Richard

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
  2016-04-25 14:25         ` Bernd Schmidt
@ 2016-04-27  1:30           ` Trevor Saunders
  0 siblings, 0 replies; 60+ messages in thread
From: Trevor Saunders @ 2016-04-27  1:30 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Mon, Apr 25, 2016 at 04:25:27PM +0200, Bernd Schmidt wrote:
> On 04/25/2016 04:21 PM, Bernd Schmidt wrote:
> >On 04/25/2016 03:30 PM, Trevor Saunders wrote:
> >>On Mon, Apr 25, 2016 at 02:28:51PM +0200, Bernd Schmidt wrote:
> >>>On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >>>>From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >>>
> >>>>+          unsigned int len = cond_list.length ();
> >>>>+          for (unsigned int i = len - 1; i < len; i--)
> >>>
> >>>This is a really icky way to write a loop, the i < len condition
> >>>makes it
> >>>look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any
> >>>reason not
> >>>to use these?
> >>
> >>I'll agree that depending on unsigned wrapping is a tad wierd, but
> >>personally I think FOR_EACH_VEC_* are pretty icky, and just forget to
> >>think about them before writing a loop.
> >
> >They're standard inside gcc though, and readability-wise much
> >preferrable to the above IMO.
> >
> >I noticed this pattern in a lot of these patches; at this point I think
> >the best thing to do would be for you to go through all of them, address
> >review comments across the whole set, and then start a new thread with
> >v2 patches of all of them so we can retire this thread.
> >
> Oh, and also - I would prefer for each nontrivial such loop some sort of
> analysis about what order elements were inserted/processed in before this
> change, and what order afterwards. This could be a source of subtle errors
> with this patch series. When removing elements in a loop, we also need to
> pay attention to whether that's still safe.

I didn't write it down, but I did think about then when writing these
patches.  Most if not all places push stuff onto the front of a list and
then iterate the list from front to back.  Which is the same order as
pushing things on the back of a vector and then iterating the vector
back to front.

Trev

> 
> 
> Bernd
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 08/18] make side_effects a vec<rtx>
  2016-04-22 12:05     ` Trevor Saunders
@ 2016-04-28  4:29       ` Jeff Law
  0 siblings, 0 replies; 60+ messages in thread
From: Jeff Law @ 2016-04-28  4:29 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, gcc-patches

On 04/22/2016 06:11 AM, Trevor Saunders wrote:
> On Thu, Apr 21, 2016 at 11:12:48PM -0600, Jeff Law wrote:
>> On 04/20/2016 12:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
>>> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>>>
>>> gcc/ChangeLog:
>>>
>>> 2016-04-19  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>>>
>>> 	* var-tracking.c (struct adjust_mem_data): Make side_effects a vector.
>>> 	(adjust_mems): Adjust.
>>> 	(adjust_insn): Likewise.
>>> 	(prepare_call_arguments): Likewise.
>>> ---
>>>  gcc/var-tracking.c | 30 +++++++++++-------------------
>>>  1 file changed, 11 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
>>> index 9f09d30..7fc6ed3 100644
>>> --- a/gcc/var-tracking.c
>>> +++ b/gcc/var-tracking.c
>>> @@ -926,7 +926,7 @@ struct adjust_mem_data
>>>    bool store;
>>>    machine_mode mem_mode;
>>>    HOST_WIDE_INT stack_adjust;
>>> -  rtx_expr_list *side_effects;
>>> +  auto_vec<rtx> side_effects;
>>>  };
>> Is auto_vec what you really want here?  AFAICT this object is never
>> destructed, so we're not releasing the memory.  Am I missing something here?
>
> it is destructed, auto_vec has a destructor, there for adjust_mem_data
> has a destructor since it has a field with a destructor.
> adjust_mem_data is always on the stack so the compiler deals with making
> sure the destructor is called when it goes out of scope.\
Duh :-)

OK for the trunk.  It looks like Bernd and others are handling the bulk 
of these, so I'll step aside.

jeff

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  2016-04-25 14:13     ` Trevor Saunders
@ 2016-05-03 12:37       ` Bernd Schmidt
  2016-05-03 13:03         ` Trevor Saunders
  0 siblings, 1 reply; 60+ messages in thread
From: Bernd Schmidt @ 2016-05-03 12:37 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, gcc-patches

On 04/25/2016 04:17 PM, Trevor Saunders wrote:
> On Mon, Apr 25, 2016 at 03:55:15PM +0200, Bernd Schmidt wrote:
>> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
>>> -/* Remove INSN from queue.  */
>>> +/* Remove INSN at idx from queue.  */
>>> +static void
>>> +queue_remove (unsigned int q, unsigned int idx)
>>> +{
>>> +  QUEUE_INDEX (insn_queue[q][idx]) = QUEUE_NOWHERE;
>>> +  insn_queue[q].ordered_remove (idx);
>>> +  q_size--;
>>
>> I think I'm nacking this one, sorry. I don't think ordered_removes in the
>> scheduler queues are going to fly.
>
> So, we're going from a linear walk through a linked list to linear scan
> of part of a vector and memcpy of the rest.  That's certainly not great,
> but the linked list walk doesn't seem great either.  Is unordered_remove
> here safe?  Or do you have some other idea?  I guess we could write a
> forward_list.

After looking at it for a bit, I think unordered_remove for the queues 
(leaving the ready list alone entirely) is probably alright. I think 
here in particular but also for the other patches it would be good to 
run some tests that code generation is identical before and after.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  2016-05-03 12:37       ` Bernd Schmidt
@ 2016-05-03 13:03         ` Trevor Saunders
  2016-05-04 15:14           ` Bernd Schmidt
  0 siblings, 1 reply; 60+ messages in thread
From: Trevor Saunders @ 2016-05-03 13:03 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Tue, May 03, 2016 at 02:36:55PM +0200, Bernd Schmidt wrote:
> On 04/25/2016 04:17 PM, Trevor Saunders wrote:
> > On Mon, Apr 25, 2016 at 03:55:15PM +0200, Bernd Schmidt wrote:
> > > On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> > > > -/* Remove INSN from queue.  */
> > > > +/* Remove INSN at idx from queue.  */
> > > > +static void
> > > > +queue_remove (unsigned int q, unsigned int idx)
> > > > +{
> > > > +  QUEUE_INDEX (insn_queue[q][idx]) = QUEUE_NOWHERE;
> > > > +  insn_queue[q].ordered_remove (idx);
> > > > +  q_size--;
> > > 
> > > I think I'm nacking this one, sorry. I don't think ordered_removes in the
> > > scheduler queues are going to fly.
> > 
> > So, we're going from a linear walk through a linked list to linear scan
> > of part of a vector and memcpy of the rest.  That's certainly not great,
> > but the linked list walk doesn't seem great either.  Is unordered_remove
> > here safe?  Or do you have some other idea?  I guess we could write a
> > forward_list.
> 
> After looking at it for a bit, I think unordered_remove for the queues
> (leaving the ready list alone entirely) is probably alright. I think here in

Thanks for looking at that, I'll try it.

> particular but also for the other patches it would be good to run some tests
> that code generation is identical before and after.

I guess the usual tool for that is contrib/compare-all-tests? is there a
simpler one?

Trev

> 
> 
> Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *>
  2016-05-03 13:03         ` Trevor Saunders
@ 2016-05-04 15:14           ` Bernd Schmidt
  0 siblings, 0 replies; 60+ messages in thread
From: Bernd Schmidt @ 2016-05-04 15:14 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, gcc-patches

On 05/03/2016 02:41 PM, Trevor Saunders wrote:

> I guess the usual tool for that is contrib/compare-all-tests? is there a
> simpler one?

Not sure. I have a collection of .i files (from building things like gcc 
and the kernel with -save-temps) and a script that compiles them all, 
then I just use diff to look at interesting changes. Doesn't make sense 
to post the whole thing since it's rather specific to my setup, but it's 
basically

CFLAGS="-quiet -O2 -fno-reorder-blocks -fno-schedule-insns2"
y=/your/output/directory
mkdir -p $y
cp cc1 $y
( cd /local/data; find $FINDCMD -name '*.i' -print0 ) | nice -n15 xargs 
-n1 -0 dirname |parallel "cd $y; mkdir -p {}"
( cd /local/data; find $FINDCMD -name '*.i' -print0 ) | nice -n15 
parallel -j10% -v -0 "./cc1 $CFLAGS $2 /local/data/{} -o $y/{.}.s"

The CFLAGS are chosen to avoid scheduling/reordering differences that 
most of the time aren't actually interesting when not testing thingsl 
ike scheduler patches.


Bernd

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2016-05-04 15:14 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-20  6:17 [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list tbsaunde+gcc
2016-04-20  6:17 ` [PATCH 01/18] stop using rtx_insn_list in reorg.c tbsaunde+gcc
2016-04-22  5:03   ` Jeff Law
2016-04-25  9:35   ` Bernd Schmidt
2016-04-25 13:39     ` Trevor Saunders
2016-04-20  6:18 ` [PATCH 04/18] remove unused loads rtx_insn_list tbsaunde+gcc
2016-04-22  5:05   ` Jeff Law
2016-04-20  6:18 ` [PATCH 16/18] make forced labels a vec tbsaunde+gcc
2016-04-20 12:41   ` Segher Boessenkool
2016-04-20  6:18 ` [PATCH 13/18] haifa-sched.c: make twins a auto_vec<rtx_insn *> tbsaunde+gcc
2016-04-20  6:18 ` [PATCH 15/18] make nonlocal_goto_handler_labels a vec tbsaunde+gcc
2016-04-20 12:36   ` Segher Boessenkool
2016-04-25 12:43   ` Bernd Schmidt
2016-04-25 13:44     ` Trevor Saunders
2016-04-20  6:18 ` [PATCH 05/18] make stores rtx_insn_list " tbsaunde+gcc
2016-04-20 11:45   ` Segher Boessenkool
2016-04-22  5:08     ` Jeff Law
2016-04-20  6:18 ` [PATCH 08/18] make side_effects a vec<rtx> tbsaunde+gcc
2016-04-22  5:18   ` Jeff Law
2016-04-22 12:05     ` Trevor Saunders
2016-04-28  4:29       ` Jeff Law
2016-04-20  6:18 ` [PATCH 17/18] make pending_{read,write}_insns vec<rtx_insn *> tbsaunde+gcc
2016-04-20 12:50   ` Segher Boessenkool
2016-04-20  6:18 ` [PATCH 03/18] make antic_stores a " tbsaunde+gcc
2016-04-20 11:40   ` Segher Boessenkool
2016-04-20  6:18 ` [PATCH 07/18] loop-iv.c: make cond_list a vec tbsaunde+gcc
2016-04-25 12:29   ` Bernd Schmidt
2016-04-25 13:31     ` Trevor Saunders
2016-04-25 14:21       ` Bernd Schmidt
2016-04-25 14:25         ` Bernd Schmidt
2016-04-27  1:30           ` Trevor Saunders
2016-04-20  6:18 ` [PATCH 02/18] make avail_stores a vec<rtx_insn *> tbsaunde+gcc
2016-04-20 11:32   ` Segher Boessenkool
2016-04-22  5:19   ` Jeff Law
2016-04-26 18:34   ` Richard Sandiford
2016-04-20  6:18 ` [PATCH 09/18] make pattern_regs a vec tbsaunde+gcc
2016-04-25 12:56   ` Bernd Schmidt
2016-04-25 13:23     ` Trevor Saunders
2016-04-20  6:19 ` [PATCH 06/18] move reg_equivs out of gc memory tbsaunde+gcc
2016-04-25 14:22   ` Bernd Schmidt
2016-04-20  6:19 ` [PATCH 10/18] merge adjust_cost and adjust_cost_2 target hooks tbsaunde+gcc
2016-04-20 12:17   ` Segher Boessenkool
2016-04-20 20:21     ` Trevor Saunders
2016-04-20  6:19 ` [PATCH 11/18] add some utility methods to vec tbsaunde+gcc
2016-04-20  9:13   ` Richard Biener
2016-04-21  4:20     ` Trevor Saunders
2016-04-20 12:29   ` Segher Boessenkool
2016-04-20  6:37 ` [PATCH 18/18] make last_pending_memory_flush a vec tbsaunde+gcc
2016-04-20 12:53   ` Segher Boessenkool
2016-04-20  6:41 ` [PATCH 14/18] haifa-sched.c: make ready_list an auto_vec<rtx_insn *> tbsaunde+gcc
2016-04-20  6:41 ` [PATCH 12/18] haifa-sched.c: make insn_queue[] a vec<rtx_insn *> tbsaunde+gcc
2016-04-25 13:55   ` Bernd Schmidt
2016-04-25 14:13     ` Trevor Saunders
2016-05-03 12:37       ` Bernd Schmidt
2016-05-03 13:03         ` Trevor Saunders
2016-05-04 15:14           ` Bernd Schmidt
2016-04-20 13:03 ` [PATCH 00/18] towards removing rtx_insn_list and rtx_expr_list Andi Kleen
2016-04-20 23:18   ` Trevor Saunders
2016-04-25 12:37     ` Bernd Schmidt
2016-04-22  5:18   ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).