From d8f2ed331960c89500a4857e5f2a6992ba039ba6 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 7 Jul 2014 06:24:37 -0400
Subject: [PATCH 186/236] Various condition-handling calls

gcc/
	* rtl.h (canonicalize_condition): Strengthen param 1 from rtx to
	rtx_insn * and param 4 from rtx * to rtx_insn **.
	(get_condition): Strengthen param 1 from rtx to rtx_insn * and
	param 2 from rtx * to rtx_insn **.

	* df.h (can_move_insns_across): Strengthen params 1-4 from rtx to
	rtx_insn * and final param from rtx * to rtx_insn **.

	* cfgcleanup.c (try_head_merge_bb): Strengthen local "move_before"
	from rtx to rtx_insn *.
	(try_head_merge_bb): Likewise for both locals named "move_upto".
	* df-problems.c (can_move_insns_across): Likewise for params
	"from", "to", "across_from", "across_to" and locals "insn",
	"next", "max_to".  Strengthen param "pmove_upto" from rtx * to
	rtx_insn **.
	* ifcvt.c (struct noce_if_info): Strengthen field "cond_earliest"
	from rtx to rtx_insn *.
	(noce_get_alt_condition): Strengthen param "earliest" from rtx *
	to rtx_insn **.  Strengthen local "insn" from rtx to rtx_insn *.
	(noce_try_minmax): Strengthen locals "earliest", "seq" from rtx to
	rtx_insn *.
	(noce_try_abs): Likewise.
	(noce_get_condition): Likewise for param "jump".  Strengthen param
	"earliest" from rtx * to rtx_insn **.
	(noce_find_if_block): Strengthen local "cond_earliest" from rtx to
	rtx_insn *.
	(find_cond_trap): Likewise.
	(dead_or_predicable): Likewise for local "earliest".
	* loop-iv.c (check_simple_exit): Likewise for local "at".  Add
	checked cast.
	* rtlanal.c (canonicalize_condition): Likewise for param "insn"
	and local "prev".  Strengthen param "earliest" from rtx * to
	rtx_insn **.
	(get_condition): Strengthen param "jump" from rtx to rtx_insn *
	Strengthen param "earliest" from rtx * to rtx_insn **.
---
 gcc/cfgcleanup.c  |  7 ++++---
 gcc/df-problems.c | 11 ++++++-----
 gcc/df.h          |  6 ++++--
 gcc/ifcvt.c       | 29 ++++++++++++++++-------------
 gcc/loop-iv.c     |  6 +++---
 gcc/rtl.h         |  5 +++--
 gcc/rtlanal.c     |  8 +++++---
 7 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 1a35a89..fe0de9f 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2291,7 +2291,8 @@ try_head_merge_bb (basic_block bb)
   bool changed, moveall;
   unsigned ix;
   rtx_insn *e0_last_head;
-  rtx cond, move_before;
+  rtx cond;
+  rtx_insn *move_before;
   unsigned nedges = EDGE_COUNT (bb->succs);
   rtx_insn *jump = BB_END (bb);
   regset live, live_union;
@@ -2455,7 +2456,7 @@ try_head_merge_bb (basic_block bb)
      with the final move.  */
   if (final_dest_bb != NULL)
     {
-      rtx move_upto;
+      rtx_insn *move_upto;
 
       moveall = can_move_insns_across (currptr[0], e0_last_head, move_before,
 				       jump, e0->dest, live_union,
@@ -2490,7 +2491,7 @@ try_head_merge_bb (basic_block bb)
 
   do
     {
-      rtx move_upto;
+      rtx_insn *move_upto;
       moveall = can_move_insns_across (currptr[0], e0_last_head,
 				       move_before, jump, e0->dest, live_union,
 				       NULL, &move_upto);
diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index 47902f7..6da3418 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -3816,11 +3816,12 @@ simulate_backwards_to_point (basic_block bb, regset live, rtx point)
    is set to point at the last moveable insn in such a case.  */
 
 bool
-can_move_insns_across (rtx from, rtx to, rtx across_from, rtx across_to,
+can_move_insns_across (rtx_insn *from, rtx_insn *to,
+		       rtx_insn *across_from, rtx_insn *across_to,
 		       basic_block merge_bb, regset merge_live,
-		       regset other_branch_live, rtx *pmove_upto)
+		       regset other_branch_live, rtx_insn **pmove_upto)
 {
-  rtx insn, next, max_to;
+  rtx_insn *insn, *next, *max_to;
   bitmap merge_set, merge_use, local_merge_live;
   bitmap test_set, test_use;
   unsigned i, fail = 0;
@@ -3830,7 +3831,7 @@ can_move_insns_across (rtx from, rtx to, rtx across_from, rtx across_to,
   bool trapping_insns_in_across = false;
 
   if (pmove_upto != NULL)
-    *pmove_upto = NULL_RTX;
+    *pmove_upto = NULL;
 
   /* Find real bounds, ignoring debug insns.  */
   while (!NONDEBUG_INSN_P (from) && from != to)
@@ -3906,7 +3907,7 @@ can_move_insns_across (rtx from, rtx to, rtx across_from, rtx across_to,
      the first insn in MERGE that sets a register in TEST_USE, or uses
      a register in TEST_SET.  We also check for calls, trapping operations,
      and memory references.  */
-  max_to = NULL_RTX;
+  max_to = NULL;
   for (insn = from; ; insn = next)
     {
       if (CALL_P (insn))
diff --git a/gcc/df.h b/gcc/df.h
index aabde63..a235996 100644
--- a/gcc/df.h
+++ b/gcc/df.h
@@ -984,8 +984,10 @@ extern void df_simulate_finalize_backwards (basic_block, bitmap);
 extern void df_simulate_initialize_forwards (basic_block, bitmap);
 extern void df_simulate_one_insn_forwards (basic_block, rtx, bitmap);
 extern void simulate_backwards_to_point (basic_block, regset, rtx);
-extern bool can_move_insns_across (rtx, rtx, rtx, rtx, basic_block, regset,
-				   regset, rtx *);
+extern bool can_move_insns_across (rtx_insn *, rtx_insn *,
+				   rtx_insn *, rtx_insn *,
+				   basic_block, regset,
+				   regset, rtx_insn **);
 /* Functions defined in df-scan.c.  */
 
 extern void df_scan_alloc (bitmap);
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 25e6493..c5f3647 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -93,7 +93,7 @@ static rtx find_active_insn_after (basic_block, rtx);
 static basic_block block_fallthru (basic_block);
 static int cond_exec_process_insns (ce_if_block *, rtx, rtx, rtx, int, int);
 static rtx cond_exec_get_condition (rtx);
-static rtx noce_get_condition (rtx, rtx *, bool);
+static rtx noce_get_condition (rtx_insn *, rtx_insn **, bool);
 static int noce_operand_ok (const_rtx);
 static void merge_if_block (ce_if_block *);
 static int find_cond_trap (basic_block, edge, edge);
@@ -762,7 +762,7 @@ struct noce_if_info
   rtx cond;
 
   /* New insns should be inserted before this one.  */
-  rtx cond_earliest;
+  rtx_insn *cond_earliest;
 
   /* Insns in the THEN and ELSE block.  There is always just this
      one insns in those blocks.  The insns are single_set insns.
@@ -798,7 +798,7 @@ static rtx noce_emit_cmove (struct noce_if_info *, rtx, enum rtx_code, rtx,
 			    rtx, rtx, rtx);
 static int noce_try_cmove (struct noce_if_info *);
 static int noce_try_cmove_arith (struct noce_if_info *);
-static rtx noce_get_alt_condition (struct noce_if_info *, rtx, rtx *);
+static rtx noce_get_alt_condition (struct noce_if_info *, rtx, rtx_insn **);
 static int noce_try_minmax (struct noce_if_info *);
 static int noce_try_abs (struct noce_if_info *);
 static int noce_try_sign_mask (struct noce_if_info *);
@@ -1730,9 +1730,10 @@ noce_try_cmove_arith (struct noce_if_info *if_info)
 
 static rtx
 noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
-			rtx *earliest)
+			rtx_insn **earliest)
 {
-  rtx cond, set, insn;
+  rtx cond, set;
+  rtx_insn *insn;
   int reverse;
 
   /* If target is already mentioned in the known condition, return it.  */
@@ -1882,8 +1883,8 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
 static int
 noce_try_minmax (struct noce_if_info *if_info)
 {
-  rtx cond, earliest, target;
-  rtx_insn *seq;
+  rtx cond, target;
+  rtx_insn *earliest, *seq;
   enum rtx_code code, op;
   int unsignedp;
 
@@ -1978,8 +1979,8 @@ noce_try_minmax (struct noce_if_info *if_info)
 static int
 noce_try_abs (struct noce_if_info *if_info)
 {
-  rtx cond, earliest, target, a, b, c;
-  rtx_insn *seq;
+  rtx cond, target, a, b, c;
+  rtx_insn *earliest, *seq;
   int negate;
   bool one_cmpl = false;
 
@@ -2306,7 +2307,7 @@ noce_try_bitop (struct noce_if_info *if_info)
    THEN block of the caller, and we have to reverse the condition.  */
 
 static rtx
-noce_get_condition (rtx jump, rtx *earliest, bool then_else_reversed)
+noce_get_condition (rtx_insn *jump, rtx_insn **earliest, bool then_else_reversed)
 {
   rtx cond, set, tmp;
   bool reverse;
@@ -3027,7 +3028,7 @@ noce_find_if_block (basic_block test_bb, edge then_edge, edge else_edge,
   bool then_else_reversed = false;
   rtx_insn *jump;
   rtx cond;
-  rtx cond_earliest;
+  rtx_insn *cond_earliest;
   struct noce_if_info if_info;
 
   /* We only ever should get here before reload.  */
@@ -3681,7 +3682,8 @@ find_cond_trap (basic_block test_bb, edge then_edge, edge else_edge)
   basic_block else_bb = else_edge->dest;
   basic_block other_bb, trap_bb;
   rtx_insn *trap, *jump;
-  rtx cond, cond_earliest, seq;
+  rtx cond, seq;
+  rtx_insn *cond_earliest;
   enum rtx_code code;
 
   /* Locate the block with the trap instruction.  */
@@ -4117,7 +4119,8 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
 {
   basic_block new_dest = dest_edge->dest;
   rtx_insn *head, *end, *jump;
-  rtx earliest = NULL_RTX, old_dest;
+  rtx_insn *earliest = NULL;
+  rtx old_dest;
   bitmap merge_set = NULL;
   /* Number of pending changes.  */
   int n_validated_changes = 0;
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index b8b5d19..74e38e1 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -2892,7 +2892,8 @@ static void
 check_simple_exit (struct loop *loop, edge e, struct niter_desc *desc)
 {
   basic_block exit_bb;
-  rtx condition, at;
+  rtx condition;
+  rtx_insn *at;
   edge ein;
 
   exit_bb = e->src;
@@ -2930,8 +2931,7 @@ check_simple_exit (struct loop *loop, edge e, struct niter_desc *desc)
 
   /* Check that we are able to determine number of iterations and fill
      in information about it.  */
-  iv_number_of_iterations (loop, as_a_nullable <rtx_insn *> (at),
-			   condition, desc);
+  iv_number_of_iterations (loop, at, condition, desc);
 }
 
 /* Finds a simple exit of LOOP and stores its description into DESC.  */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 2c27b84..cda76cd 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2648,11 +2648,12 @@ extern int insn_rtx_cost (rtx, bool);
 
 /* Given an insn and condition, return a canonical description of
    the test being made.  */
-extern rtx canonicalize_condition (rtx, rtx, int, rtx *, rtx, int, int);
+extern rtx canonicalize_condition (rtx_insn *, rtx, int, rtx_insn **, rtx,
+				   int, int);
 
 /* Given a JUMP_INSN, return a canonical description of the test
    being made.  */
-extern rtx get_condition (rtx, rtx *, int, int);
+extern rtx get_condition (rtx_insn *, rtx_insn **, int, int);
 
 /* Information about a subreg of a hard register.  */
 struct subreg_info
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 5c5e643..99869a1 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -4985,11 +4985,12 @@ insn_rtx_cost (rtx pat, bool speed)
    and at INSN.  */
 
 rtx
-canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
+canonicalize_condition (rtx_insn *insn, rtx cond, int reverse,
+			rtx_insn **earliest,
 			rtx want_reg, int allow_cc_mode, int valid_at_insn_p)
 {
   enum rtx_code code;
-  rtx prev = insn;
+  rtx_insn *prev = insn;
   const_rtx set;
   rtx tem;
   rtx op0, op1;
@@ -5254,7 +5255,8 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
    VALID_AT_INSN_P is the same as for canonicalize_condition.  */
 
 rtx
-get_condition (rtx jump, rtx *earliest, int allow_cc_mode, int valid_at_insn_p)
+get_condition (rtx_insn *jump, rtx_insn **earliest, int allow_cc_mode,
+	       int valid_at_insn_p)
 {
   rtx cond;
   int reverse;
-- 
1.8.5.3

