From 6153aa8c7c576801d65bc3c28572c4cbc9ee7593 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 8 Jan 2014 15:14:06 -0500
Subject: [PATCH 104/159] FIXME: canonicalize_condition, get_condition, etc

---
 gcc/cfgcleanup.c    |  7 ++++---
 gcc/cprop.c         |  2 +-
 gcc/ifcvt.c         | 31 +++++++++++++++++++------------
 gcc/loop-iv.c       |  3 ++-
 gcc/loop-unswitch.c |  3 ++-
 gcc/predict.c       |  2 +-
 gcc/rtl.h           |  7 ++++---
 gcc/rtlanal.c       |  8 +++++---
 8 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 41cb5a3..0aac8f5 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2289,9 +2289,10 @@ try_head_merge_bb (basic_block bb)
   rtx *headptr, *currptr, *nextptr;
   bool changed, moveall;
   unsigned ix;
-  rtx e0_last_head, cond, move_before;
+  rtx e0_last_head, cond;
+  rtx_base_insn move_before;
   unsigned nedges = EDGE_COUNT (bb->succs);
-  rtx jump = BB_END (bb);
+  rtx_base_insn jump = BB_END (bb);
   regset live, live_union;
 
   /* Nothing to do if there is not at least two outgoing edges.  */
@@ -2432,7 +2433,7 @@ try_head_merge_bb (basic_block bb)
     {
       int j;
       basic_block merge_bb = EDGE_SUCC (bb, ix)->dest;
-      rtx head = BB_HEAD (merge_bb);
+      rtx_base_insn head = BB_HEAD (merge_bb);
 
       while (!NONDEBUG_INSN_P (head))
 	head = NEXT_INSN (head);
diff --git a/gcc/cprop.c b/gcc/cprop.c
index 15f2e20..75f0253 100644
--- a/gcc/cprop.c
+++ b/gcc/cprop.c
@@ -1287,7 +1287,7 @@ local_cprop_pass (void)
    but this would require some code reorganization.  */
 
 rtx
-fis_get_condition (rtx jump)
+fis_get_condition (rtx_base_insn jump)
 {
   return get_condition (jump, NULL, false, true);
 }
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 5717b79..e2c51a6 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -93,7 +93,7 @@ static rtx_base_insn find_active_insn_after (basic_block, rtx_base_insn);
 static basic_block block_fallthru (basic_block);
 static int cond_exec_process_insns (ce_if_block_t *, rtx_base_insn, 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_base_insn, rtx_base_insn *, bool);
 static int noce_operand_ok (const_rtx);
 static void merge_if_block (ce_if_block_t *);
 static int find_cond_trap (basic_block, edge, edge);
@@ -749,13 +749,13 @@ struct noce_if_info
   basic_block test_bb, then_bb, else_bb, join_bb;
 
   /* The jump that ends TEST_BB.  */
-  rtx jump;
+  rtx_base_insn jump;
 
   /* The jump condition.  */
   rtx cond;
 
   /* New insns should be inserted before this one.  */
-  rtx cond_earliest;
+  rtx_base_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.
@@ -791,7 +791,8 @@ 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_base_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 *);
@@ -1716,7 +1717,7 @@ 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_base_insn *earliest)
 {
   rtx cond, set, insn;
   int reverse;
@@ -1868,7 +1869,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, seq;
+  rtx cond, target, seq;
+  rtx_base_insn earliest;
   enum rtx_code code, op;
   int unsignedp;
 
@@ -1963,7 +1965,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, seq, a, b, c;
+  rtx cond, target, seq, a, b, c;
+  rtx_base_insn earliest;
   int negate;
   bool one_cmpl = false;
 
@@ -2288,7 +2291,8 @@ 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_base_insn jump, rtx_base_insn *earliest,
+		    bool then_else_reversed)
 {
   rtx cond, set, tmp;
   bool reverse;
@@ -3003,8 +3007,9 @@ noce_find_if_block (basic_block test_bb, edge then_edge, edge else_edge,
 {
   basic_block then_bb, else_bb, join_bb;
   bool then_else_reversed = false;
-  rtx jump, cond;
-  rtx cond_earliest;
+  rtx_base_insn jump;
+  rtx cond;
+  rtx_base_insn cond_earliest;
   struct noce_if_info if_info;
 
   /* We only ever should get here before reload.  */
@@ -3629,7 +3634,8 @@ find_cond_trap (basic_block test_bb, edge then_edge, edge else_edge)
   basic_block then_bb = then_edge->dest;
   basic_block else_bb = else_edge->dest;
   basic_block other_bb, trap_bb;
-  rtx trap, jump, cond, cond_earliest, seq;
+  rtx trap, cond, seq;
+  rtx_base_insn jump, cond_earliest;
   enum rtx_code code;
 
   /* Locate the block with the trap instruction.  */
@@ -4061,7 +4067,8 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
 {
   basic_block new_dest = dest_edge->dest;
   rtx_base_insn head, end, jump;
-  rtx earliest = NULL_RTX, old_dest;
+  rtx_base_insn earliest = NULL_RTX_BASE_INSN;
+  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 dd872e7..2b1d991 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_base_insn at;
   edge ein;
 
   exit_bb = e->src;
diff --git a/gcc/loop-unswitch.c b/gcc/loop-unswitch.c
index 0b4a7c4..aab8a83 100644
--- a/gcc/loop-unswitch.c
+++ b/gcc/loop-unswitch.c
@@ -166,7 +166,8 @@ unswitch_loops (void)
 static rtx
 may_unswitch_on (basic_block bb, struct loop *loop, rtx_base_insn *cinsn)
 {
-  rtx test, at, op[2], stest;
+  rtx test, op[2], stest;
+  rtx_base_insn at;
   struct rtx_iv iv;
   unsigned i;
   enum machine_mode mode;
diff --git a/gcc/predict.c b/gcc/predict.c
index a4cad93..30371eb8 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1686,7 +1686,7 @@ predict_loops (void)
 static void
 bb_estimate_probability_locally (basic_block bb)
 {
-  rtx last_insn = BB_END (bb);
+  rtx_base_insn last_insn = BB_END (bb);
   rtx cond;
 
   if (! can_predict_insn_p (last_insn))
diff --git a/gcc/rtl.h b/gcc/rtl.h
index ce86eab..ade3424 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2535,11 +2535,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_base_insn, rtx, int, rtx_base_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_base_insn, rtx_base_insn *, int, int);
 
 /* Information about a subreg of a hard register.  */
 struct subreg_info
@@ -3069,7 +3070,7 @@ extern void init_lower_subreg (void);
 /* In gcse.c */
 extern bool can_copy_p (enum machine_mode);
 extern bool can_assign_to_reg_without_clobbers_p (rtx);
-extern rtx fis_get_condition (rtx);
+extern rtx fis_get_condition (rtx_base_insn);
 
 /* In ira.c */
 #ifdef HARD_CONST
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index e22ce90..7e3ef05 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -4944,11 +4944,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_base_insn insn, rtx cond, int reverse,
+			rtx_base_insn *earliest,
 			rtx want_reg, int allow_cc_mode, int valid_at_insn_p)
 {
   enum rtx_code code;
-  rtx prev = insn;
+  rtx_base_insn prev = insn;
   const_rtx set;
   rtx tem;
   rtx op0, op1;
@@ -5202,7 +5203,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_base_insn jump, rtx_base_insn *earliest, int allow_cc_mode,
+	       int valid_at_insn_p)
 {
   rtx cond;
   int reverse;
-- 
1.7.11.7

