From d3319be5865ce0f1a78fe02d2ac6eb4865ca43b1 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 6 Jan 2014 22:51:37 -0500
Subject: [PATCH 080/159] FIXME: HAVE_cc0 fixes for 'FIXME: recog.c,
 combine.c, gen' seen on m68k

---
 gcc/combine.c  | 23 ++++++++++++++---------
 gcc/emit-rtl.c |  6 +++---
 gcc/rtl.h      |  2 +-
 3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/gcc/combine.c b/gcc/combine.c
index 7210e01..c6f047b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -1116,7 +1116,7 @@ combine_instructions (rtx_base_insn f, unsigned int nregs)
 {
   rtx_base_insn insn, next;
 #ifdef HAVE_cc0
-  rtx prev;
+  rtx_base_insn prev;
 #endif
   struct insn_link *links, *nextlinks;
   rtx_base_insn first;
@@ -1299,14 +1299,16 @@ combine_instructions (rtx_base_insn f, unsigned int nregs)
 		  && NONJUMP_INSN_P (prev)
 		  && sets_cc0_p (PATTERN (prev)))
 		{
-		  if ((next = try_combine (insn, prev, NULL_RTX, NULL_RTX,
+		  if ((next = try_combine (insn, prev, NULL_RTX_BASE_INSN,
+					   NULL_RTX_BASE_INSN,
 					   &new_direct_jump_p,
 					   last_combined_insn)) != 0)
 		    goto retry;
 
 		  FOR_EACH_LOG_LINK (nextlinks, prev)
 		    if ((next = try_combine (insn, prev, nextlinks->insn,
-					     NULL_RTX, &new_direct_jump_p,
+					     NULL_RTX_BASE_INSN,
+					     &new_direct_jump_p,
 					     last_combined_insn)) != 0)
 		      goto retry;
 		}
@@ -1319,14 +1321,16 @@ combine_instructions (rtx_base_insn f, unsigned int nregs)
 		  && GET_CODE (PATTERN (insn)) == SET
 		  && reg_mentioned_p (cc0_rtx, SET_SRC (PATTERN (insn))))
 		{
-		  if ((next = try_combine (insn, prev, NULL_RTX, NULL_RTX,
+		  if ((next = try_combine (insn, prev, NULL_RTX_BASE_INSN,
+					   NULL_RTX_BASE_INSN,
 					   &new_direct_jump_p,
 					   last_combined_insn)) != 0)
 		    goto retry;
 
 		  FOR_EACH_LOG_LINK (nextlinks, prev)
 		    if ((next = try_combine (insn, prev, nextlinks->insn,
-					     NULL_RTX, &new_direct_jump_p,
+					     NULL_RTX_BASE_INSN,
+					     &new_direct_jump_p,
 					     last_combined_insn)) != 0)
 		      goto retry;
 		}
@@ -1342,7 +1346,8 @@ combine_instructions (rtx_base_insn f, unsigned int nregs)
 		    && NONJUMP_INSN_P (prev)
 		    && sets_cc0_p (PATTERN (prev))
 		    && (next = try_combine (insn, links->insn,
-					    prev, NULL_RTX, &new_direct_jump_p,
+					    prev, NULL_RTX_BASE_INSN,
+					    &new_direct_jump_p,
 					    last_combined_insn)) != 0)
 		  goto retry;
 #endif
@@ -13515,7 +13520,7 @@ distribute_notes (rtx notes, rtx_base_insn from_insn,
 		      rtx set = single_set (tem_insn);
 		      rtx inner_dest = 0;
 #ifdef HAVE_cc0
-		      rtx cc0_setter = NULL_RTX;
+		      rtx_base_insn cc0_setter = NULL_RTX_BASE_INSN;
 #endif
 
 		      if (set != 0)
@@ -13538,7 +13543,7 @@ distribute_notes (rtx notes, rtx_base_insn from_insn,
 			  && rtx_equal_p (XEXP (note, 0), inner_dest)
 #ifdef HAVE_cc0
 			  && (! reg_mentioned_p (cc0_rtx, SET_SRC (set))
-			      || ((cc0_setter = prev_cc0_setter (tem)) != NULL
+			      || ((cc0_setter = prev_cc0_setter (tem_insn)) != NULL
 				  && sets_cc0_p (PATTERN (cc0_setter)) > 0))
 #endif
 			  )
@@ -13570,7 +13575,7 @@ distribute_notes (rtx notes, rtx_base_insn from_insn,
 			      REG_NOTES (cc0_setter) = NULL;
 
 			      distribute_notes (old_notes, cc0_setter,
-						cc0_setter, NULL_RTX,
+						cc0_setter, NULL_RTX_BASE_INSN,
 						NULL_RTX, NULL_RTX, NULL_RTX);
 			      distribute_links (LOG_LINKS (cc0_setter));
 
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 1a61991..19b0507 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3401,13 +3401,13 @@ next_cc0_user (rtx insn)
 /* Find the insn that set CC0 for INSN.  Unless INSN has a REG_CC_SETTER
    note, it is the previous insn.  */
 
-rtx
-prev_cc0_setter (rtx insn)
+rtx_base_insn
+prev_cc0_setter (rtx_base_insn insn)
 {
   rtx note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
 
   if (note)
-    return XEXP (note, 0);
+    return XEXP (note, 0)->as_an_rtx_base_insn ();
 
   insn = prev_nonnote_insn (insn);
   gcc_assert (sets_cc0_p (PATTERN (insn)));
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 766d712..8985e25 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2199,7 +2199,7 @@ extern rtx_base_insn prev_active_insn (rtx);
 extern rtx_base_insn next_active_insn (rtx);
 extern int active_insn_p (const_rtx);
 extern rtx next_cc0_user (rtx);
-extern rtx prev_cc0_setter (rtx);
+extern rtx_base_insn prev_cc0_setter (rtx_base_insn);
 
 /* In emit-rtl.c  */
 extern int insn_line (const_rtx);
-- 
1.7.11.7

