diff mbox

PR rtl-optimization/46878 fix

Message ID 201101272004.p0RK4aO6017952@greed.delorie.com
State New
Headers show

Commit Message

DJ Delorie Jan. 27, 2011, 8:04 p.m. UTC
Approved in the PR.  Committed.

2011-01-26  DJ Delorie  <dj@redhat.com>

	PR rtl-optimization/46878
	* combine.c (insn_a_feeds_b): Check for the implicit cc0
	setter/user dependency as well.

2011-01-26  DJ Delorie  <dj@redhat.com>

	PR rtl-optimization/46878
	* gcc.dg/pr46878-1.c: New test.
diff mbox

Patch

Index: combine.c
===================================================================
--- combine.c	(revision 169299)
+++ combine.c	(working copy)
@@ -1029,21 +1029,27 @@  clear_log_links (void)
       free_INSN_LIST_list (&LOG_LINKS (insn));
 }
 
 /* Walk the LOG_LINKS of insn B to see if we find a reference to A.  Return
    true if we found a LOG_LINK that proves that A feeds B.  This only works
    if there are no instructions between A and B which could have a link
-   depending on A, since in that case we would not record a link for B.  */
+   depending on A, since in that case we would not record a link for B.
+   We also check the implicit dependency created by a cc0 setter/user
+   pair.  */
 
 static bool
 insn_a_feeds_b (rtx a, rtx b)
 {
   rtx links;
   for (links = LOG_LINKS (b); links; links = XEXP (links, 1))
     if (XEXP (links, 0) == a)
       return true;
+#ifdef HAVE_cc0
+  if (sets_cc0_p (a))
+    return true;
+#endif
   return false;
 }
 
 /* Main entry point for combiner.  F is the first insn of the function.
    NREGS is the first unused pseudo-reg number.
 
Index: testsuite/gcc.dg/pr46878-1.c
===================================================================
--- testsuite/gcc.dg/pr46878-1.c	(revision 0)
+++ testsuite/gcc.dg/pr46878-1.c	(revision 0)
@@ -0,0 +1,30 @@ 
+/* PR rtl-optimization/46878 */
+/* Make sure this doesn't ICE.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct baz
+{
+  int *newp;
+};
+
+int
+get_ice (int *op, struct baz *ret)
+{
+  int *tmpp;
+  int c;
+  c = (__foo () != 1);
+  if (__bar ())
+    {
+      return (1);
+    }
+  if (c)
+    tmpp = op;
+  if (tmpp)
+    {
+    }
+  else if (c)
+    {
+      ret->newp = tmpp;
+    }
+}