From fa48e40f9772b9415ea25b97cc2b5788c0a4cef3 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 27 Jun 2014 20:02:16 -0400
Subject: [PATCH 114/162] store-motion.c: Use rtx_insn

gcc/
	* store-motion.c (store_killed_in_insn): Strengthen param "insn"
	from const_rtx to const rtx_insn *.
	(store_killed_after): Likewise.  Strengthen locals "last", "act"
	from rtx to rtx_insn *.
	(store_killed_before): Strengthen param "insn" from const_rtx to
	const rtx_insn *.  Strengthen local "first" from rtx to rtx_insn *.
	(find_moveable_store): Strengthen param "insn" from rtx to
	rtx_insn *.
	(compute_store_table): Likewise for local "insn".
	(insert_insn_start_basic_block): Likewise for param "insn" and
	locals "prev", "before", "insn".
	(insert_store): For now, add a checked cast to rtx_insn * on the
	result of gen_move_insn.
	(remove_reachable_equiv_notes): Strengthen local "insn" from rtx
	to rtx_insn *.
	(replace_store_insn): Likewise.  For now, add a checked cast to
	rtx_insn * on the result of gen_move_insn.
---
 gcc/store-motion.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index b3e5890..567ab07 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -396,7 +396,7 @@ 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, int after)
+store_killed_in_insn (const_rtx x, const_rtx x_regs, const rtx_insn *insn, int after)
 {
   const_rtx reg, note, pat;
 
@@ -458,10 +458,11 @@ store_killed_in_insn (const_rtx x, const_rtx x_regs, const_rtx insn, int after)
    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, const_basic_block bb,
+store_killed_after (const_rtx x, const_rtx x_regs, const rtx_insn *insn,
+		    const_basic_block bb,
 		    int *regs_set_after, rtx *fail_insn)
 {
-  rtx last = BB_END (bb), act;
+  rtx_insn *last = BB_END (bb), *act;
 
   if (!store_ops_ok (x_regs, regs_set_after))
     {
@@ -487,10 +488,10 @@ store_killed_after (const_rtx x, const_rtx x_regs, const_rtx insn, const_basic_b
    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, const_basic_block bb,
-		     int *regs_set_before)
+store_killed_before (const_rtx x, const_rtx x_regs, const rtx_insn *insn,
+		     const_basic_block bb, int *regs_set_before)
 {
-  rtx first = BB_HEAD (bb);
+  rtx_insn *first = BB_HEAD (bb);
 
   if (!store_ops_ok (x_regs, regs_set_before))
     return true;
@@ -536,7 +537,7 @@ store_killed_before (const_rtx x, const_rtx x_regs, const_rtx insn, const_basic_
    */
 
 static void
-find_moveable_store (rtx insn, int *regs_set_before, int *regs_set_after)
+find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
 {
   struct st_expr * ptr;
   rtx dest, set, tmp;
@@ -644,7 +645,8 @@ compute_store_table (void)
 #ifdef ENABLE_CHECKING
   unsigned regno;
 #endif
-  rtx insn, tmp;
+  rtx_insn *insn;
+  rtx tmp;
   df_ref *def_rec;
   int *last_set_in, *already_set;
   struct st_expr * ptr, **prev_next_ptr_ptr;
@@ -739,11 +741,11 @@ compute_store_table (void)
    the BB_HEAD if needed.  */
 
 static void
-insert_insn_start_basic_block (rtx insn, basic_block bb)
+insert_insn_start_basic_block (rtx_insn *insn, basic_block bb)
 {
   /* Insert at start of successor block.  */
-  rtx prev = PREV_INSN (BB_HEAD (bb));
-  rtx before = BB_HEAD (bb);
+  rtx_insn *prev = PREV_INSN (BB_HEAD (bb));
+  rtx_insn *before = BB_HEAD (bb);
   while (before != 0)
     {
       if (! LABEL_P (before)
@@ -773,7 +775,8 @@ insert_insn_start_basic_block (rtx insn, basic_block bb)
 static int
 insert_store (struct st_expr * expr, edge e)
 {
-  rtx reg, insn;
+  rtx reg;
+  rtx_insn *insn;
   basic_block bb;
   edge tmp;
   edge_iterator ei;
@@ -787,7 +790,7 @@ insert_store (struct st_expr * expr, edge e)
     return 0;
 
   reg = expr->reaching_reg;
-  insn = gen_move_insn (copy_rtx (expr->pattern), reg);
+  insn = as_a <rtx_insn *> (gen_move_insn (copy_rtx (expr->pattern), reg));
 
   /* If we are inserting this expression on ALL predecessor edges of a BB,
      insert it at the start of the BB, and reset the insert bits on the other
@@ -845,7 +848,8 @@ 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, insn, note;
+  rtx last, note;
+  rtx_insn *insn;
   rtx mem = smexpr->pattern;
 
   stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun));
@@ -922,10 +926,11 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr)
 static void
 replace_store_insn (rtx reg, rtx del, basic_block bb, struct st_expr *smexpr)
 {
-  rtx insn, mem, note, set, ptr;
+  rtx_insn *insn;
+  rtx mem, note, set, ptr;
 
   mem = smexpr->pattern;
-  insn = gen_move_insn (reg, SET_SRC (single_set (del)));
+  insn = as_a <rtx_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)
-- 
1.8.5.3

