From 389517c8bf63dd9a116e74ebe1da65f4818b1afc Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 18 Jun 2014 11:22:45 -0400
Subject: [PATCH 091/229] loop-unroll.c: Use rtx_insn (also touches
 basic-block.h)

gcc/
	* basic-block.h (basic_block split_edge_and_insert): Strengthen
	param "insns" from rtx to rtx_insn *.

	* loop-unroll.c (struct iv_to_split): Strengthen field "insn" from
	rtx to rtx_insn *.
	(struct iv_to_split): Likewise.
	(loop_exit_at_end_p): Likewise for local "insn".
	(split_edge_and_insert): Likewise for param "insns".
	(compare_and_jump_seq): Likewise for return type, param "cinsn",
	and locals "seq", "jump".
	(unroll_loop_runtime_iterations): Likewise for locals "init_code",
	"branch_code"; update invocations of compare_and_jump_seq to
	eliminate NULL_RTX in favor of NULL.
	(referenced_in_one_insn_in_loop_p): Strengthen local "insn" from
	rtx to rtx_insn *.
	(reset_debug_uses_in_loop): Likewise.
	(analyze_insn_to_expand_var): Likewise for param "insn".
	(analyze_iv_to_split_insn): Likewise.
	(analyze_insns_in_loop): Likewise for local "insn".
	(insert_base_initialization): Likewise for param
	"insn" and local "seq".
	(split_iv): Likewise for param "insn" and local "seq".
	(expand_var_during_unrolling): Likewise for param "insn".
	(insert_var_expansion_initialization): Likewise for local "seq".
	(combine_var_copies_in_loop_exit): Likewise.
	(combine_var_copies_in_loop_exit): Likewise for locals "seq" and
	"insn".
	(maybe_strip_eq_note_for_split_iv): Likewise for param "insn".
	(apply_opt_in_copies): Likewise for locals "insn", "orig_insn",
	"next".
---
 gcc/basic-block.h |  2 +-
 gcc/loop-unroll.c | 53 +++++++++++++++++++++++++++++------------------------
 2 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 172908d..18d3871 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -399,7 +399,7 @@ extern unsigned int free_bb_for_insn (void);
 extern void update_bb_for_insn (basic_block);
 
 extern void insert_insn_on_edge (rtx, edge);
-basic_block split_edge_and_insert (edge, rtx);
+basic_block split_edge_and_insert (edge, rtx_insn *);
 
 extern void commit_one_edge_insertion (edge e);
 extern void commit_edge_insertions (void);
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index c283900..67dbe8b 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -73,7 +73,7 @@ along with GCC; see the file COPYING3.  If not see
 
 struct iv_to_split
 {
-  rtx insn;		/* The insn in that the induction variable occurs.  */
+  rtx_insn *insn;	/* The insn in that the induction variable occurs.  */
   rtx orig_var;		/* The variable (register) for the IV before split.  */
   rtx base_var;		/* The variable on that the values in the further
 			   iterations are based.  */
@@ -90,7 +90,7 @@ struct iv_to_split
 
 struct var_to_expand
 {
-  rtx insn;		           /* The insn in that the variable expansion occurs.  */
+  rtx_insn *insn;	           /* The insn in that the variable expansion occurs.  */
   rtx reg;                         /* The accumulator which is expanded.  */
   vec<rtx> var_expansions;   /* The copies of the accumulator which is expanded.  */
   struct var_to_expand *next;	   /* Next entry in walking order.  */
@@ -192,10 +192,10 @@ static struct opt_info *analyze_insns_in_loop (struct loop *);
 static void opt_info_start_duplication (struct opt_info *);
 static void apply_opt_in_copies (struct opt_info *, unsigned, bool, bool);
 static void free_opt_info (struct opt_info *);
-static struct var_to_expand *analyze_insn_to_expand_var (struct loop*, rtx);
+static struct var_to_expand *analyze_insn_to_expand_var (struct loop*, rtx_insn *);
 static bool referenced_in_one_insn_in_loop_p (struct loop *, rtx, int *);
 static struct iv_to_split *analyze_iv_to_split_insn (rtx_insn *);
-static void expand_var_during_unrolling (struct var_to_expand *, rtx);
+static void expand_var_during_unrolling (struct var_to_expand *, rtx_insn *);
 static void insert_var_expansion_initialization (struct var_to_expand *,
 						 basic_block);
 static void combine_var_copies_in_loop_exit (struct var_to_expand *,
@@ -324,7 +324,7 @@ static bool
 loop_exit_at_end_p (struct loop *loop)
 {
   struct niter_desc *desc = get_simple_loop_desc (loop);
-  rtx insn;
+  rtx_insn *insn;
 
   if (desc->in_edge->dest != loop->latch)
     return false;
@@ -1012,7 +1012,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
    and NULL is returned instead.  */
 
 basic_block
-split_edge_and_insert (edge e, rtx insns)
+split_edge_and_insert (edge e, rtx_insn *insns)
 {
   basic_block bb;
 
@@ -1058,11 +1058,12 @@ split_edge_and_insert (edge e, rtx insns)
    true, with probability PROB.  If CINSN is not NULL, it is the insn to copy
    in order to create a jump.  */
 
-static rtx
+static rtx_insn *
 compare_and_jump_seq (rtx op0, rtx op1, enum rtx_code comp, rtx label, int prob,
-		      rtx cinsn)
+		      rtx_insn *cinsn)
 {
-  rtx seq, jump, cond;
+  rtx_insn *seq, *jump;
+  rtx cond;
   enum machine_mode mode;
 
   mode = GET_MODE (op0);
@@ -1141,7 +1142,8 @@ compare_and_jump_seq (rtx op0, rtx op1, enum rtx_code comp, rtx label, int prob,
 static void
 unroll_loop_runtime_iterations (struct loop *loop)
 {
-  rtx old_niter, niter, init_code, branch_code, tmp;
+  rtx old_niter, niter, tmp;
+  rtx_insn *init_code, *branch_code;
   unsigned i, j, p;
   basic_block preheader, *body, swtch, ezc_swtch;
   sbitmap wont_exit;
@@ -1258,7 +1260,7 @@ unroll_loop_runtime_iterations (struct loop *loop)
       preheader = split_edge (loop_preheader_edge (loop));
       branch_code = compare_and_jump_seq (copy_rtx (niter), GEN_INT (j), EQ,
 					  block_label (preheader), p,
-					  NULL_RTX);
+					  NULL);
 
       /* We rely on the fact that the compare and jump cannot be optimized out,
 	 and hence the cfg we create is correct.  */
@@ -1281,7 +1283,7 @@ unroll_loop_runtime_iterations (struct loop *loop)
       preheader = split_edge (loop_preheader_edge (loop));
       branch_code = compare_and_jump_seq (copy_rtx (niter), const0_rtx, EQ,
 					  block_label (preheader), p,
-					  NULL_RTX);
+					  NULL);
       gcc_assert (branch_code != NULL_RTX);
 
       swtch = split_edge_and_insert (single_succ_edge (swtch), branch_code);
@@ -1689,7 +1691,7 @@ referenced_in_one_insn_in_loop_p (struct loop *loop, rtx reg,
   basic_block *body, bb;
   unsigned i;
   int count_ref = 0;
-  rtx insn;
+  rtx_insn *insn;
 
   body = get_loop_body (loop);
   for (i = 0; i < loop->num_nodes; i++)
@@ -1715,7 +1717,7 @@ reset_debug_uses_in_loop (struct loop *loop, rtx reg, int debug_uses)
 {
   basic_block *body, bb;
   unsigned i;
-  rtx insn;
+  rtx_insn *insn;
 
   body = get_loop_body (loop);
   for (i = 0; debug_uses && i < loop->num_nodes; i++)
@@ -1760,7 +1762,7 @@ reset_debug_uses_in_loop (struct loop *loop, rtx reg, int debug_uses)
 */
 
 static struct var_to_expand *
-analyze_insn_to_expand_var (struct loop *loop, rtx insn)
+analyze_insn_to_expand_var (struct loop *loop, rtx_insn *insn)
 {
   rtx set, dest, src;
   struct var_to_expand *ves;
@@ -2107,10 +2109,10 @@ allocate_basic_variable (struct iv_to_split *ivts)
    the initial value from INSN.  */
 
 static void
-insert_base_initialization (struct iv_to_split *ivts, rtx insn)
+insert_base_initialization (struct iv_to_split *ivts, rtx_insn *insn)
 {
   rtx expr = copy_rtx (*get_ivts_expr (single_set (insn), ivts));
-  rtx seq;
+  rtx_insn *seq;
 
   start_sequence ();
   expr = force_operand (expr, ivts->base_var);
@@ -2126,9 +2128,10 @@ insert_base_initialization (struct iv_to_split *ivts, rtx insn)
    by base variable + DELTA * step.  */
 
 static void
-split_iv (struct iv_to_split *ivts, rtx insn, unsigned delta)
+split_iv (struct iv_to_split *ivts, rtx_insn *insn, unsigned delta)
 {
-  rtx expr, *loc, seq, incr, var;
+  rtx expr, *loc, incr, var;
+  rtx_insn *seq;
   enum machine_mode mode = GET_MODE (ivts->base_var);
   rtx src, dest, set;
 
@@ -2208,7 +2211,7 @@ get_expansion (struct var_to_expand *ve)
    with a new register.  */
 
 static void
-expand_var_during_unrolling (struct var_to_expand *ve, rtx insn)
+expand_var_during_unrolling (struct var_to_expand *ve, rtx_insn *insn)
 {
   rtx new_reg, set;
   bool really_new_expansion = false;
@@ -2266,7 +2269,8 @@ static void
 insert_var_expansion_initialization (struct var_to_expand *ve,
 				     basic_block place)
 {
-  rtx seq, var, zero_init;
+  rtx_insn *seq;
+  rtx var, zero_init;
   unsigned i;
   enum machine_mode mode = GET_MODE (ve->reg);
   bool honor_signed_zero_p = HONOR_SIGNED_ZEROS (mode);
@@ -2317,7 +2321,8 @@ static void
 combine_var_copies_in_loop_exit (struct var_to_expand *ve, basic_block place)
 {
   rtx sum = ve->reg;
-  rtx expr, seq, var, insn;
+  rtx expr, var;
+  rtx_insn *seq, *insn;
   unsigned i;
 
   if (ve->var_expansions.length () == 0)
@@ -2368,7 +2373,7 @@ combine_var_copies_in_loop_exit (struct var_to_expand *ve, basic_block place)
    any notes attached to them.  So resort to old techniques...  */
 
 static void
-maybe_strip_eq_note_for_split_iv (struct opt_info *opt_info, rtx insn)
+maybe_strip_eq_note_for_split_iv (struct opt_info *opt_info, rtx_insn *insn)
 {
   struct iv_to_split *ivts;
   rtx note = find_reg_equal_equiv_note (insn);
@@ -2398,7 +2403,7 @@ apply_opt_in_copies (struct opt_info *opt_info,
 {
   unsigned i, delta;
   basic_block bb, orig_bb;
-  rtx insn, orig_insn, next;
+  rtx_insn *insn, *orig_insn, *next;
   struct iv_to_split ivts_templ, *ivts;
   struct var_to_expand ve_templ, *ves;
 
-- 
1.8.5.3

