Blame SOURCES/gcc48-pr52714.patch

8178f7
2014-02-27  Jeff Law  <law@redhat.com>
8178f7
8178f7
	PR rtl-optimization/52714
8178f7
	* combine.c (try_combine): When splitting an unrecognized PARALLEL
8178f7
	into two independent simple sets, if I3 is a jump, ensure the
8178f7
	pattern we place into I3 is a (set (pc) ...)
8178f7
8178f7
	* gcc.c-torture/compile/pr52714.c: New test.
8178f7
8178f7
2016-06-15  Jakub Jelinek  <jakub@redhat.com>
8178f7
8178f7
	* gcc.c-torture/compile/20160615-1.c: New test.
8178f7
8178f7
--- gcc/combine.c	(revision 208203)
8178f7
+++ gcc/combine.c	(revision 208204)
8178f7
@@ -3706,6 +3706,9 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx
8178f7
 #ifdef HAVE_cc0
8178f7
 	  && !reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0))
8178f7
 #endif
8178f7
+	  /* If I3 is a jump, ensure that set0 is a jump so that
8178f7
+	     we do not create invalid RTL.  */
8178f7
+	  && (!JUMP_P (i3) || SET_DEST (XVECEXP (newpat, 0, 0)) == pc_rtx)
8178f7
 	 )
8178f7
 	{
8178f7
 	  newi2pat = XVECEXP (newpat, 0, 1);
8178f7
@@ -3716,6 +3719,9 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx
8178f7
 #ifdef HAVE_cc0
8178f7
 	       && !reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 1))
8178f7
 #endif
8178f7
+	       /* If I3 is a jump, ensure that set1 is a jump so that
8178f7
+		  we do not create invalid RTL.  */
8178f7
+	       && (!JUMP_P (i3) || SET_DEST (XVECEXP (newpat, 0, 1)) == pc_rtx)
8178f7
 	      )
8178f7
 	{
8178f7
 	  newi2pat = XVECEXP (newpat, 0, 0);
8178f7
--- gcc/testsuite/gcc.c-torture/compile/pr52714.c	(revision 0)
8178f7
+++ gcc/testsuite/gcc.c-torture/compile/pr52714.c	(revision 208204)
8178f7
@@ -0,0 +1,25 @@
8178f7
+
8178f7
+int __re_compile_fastmap(unsigned char *p)
8178f7
+{
8178f7
+    unsigned char **stack;
8178f7
+    unsigned size;
8178f7
+    unsigned avail;
8178f7
+
8178f7
+    stack = __builtin_alloca(5 * sizeof(unsigned char*));
8178f7
+    if (stack == 0)
8178f7
+	return -2;
8178f7
+    size = 5;
8178f7
+    avail = 0;
8178f7
+
8178f7
+    for (;;) {
8178f7
+	switch (*p++) {
8178f7
+	case 0:
8178f7
+	    if (avail == size)
8178f7
+		return -2;
8178f7
+	    stack[avail++] = p;
8178f7
+	}
8178f7
+    }
8178f7
+
8178f7
+    return 0;
8178f7
+}
8178f7
+
8178f7
--- gcc/testsuite/gcc.c-torture/compile/20160615-1.c.jj	2016-06-15 11:17:54.690689056 +0200
8178f7
+++ gcc/testsuite/gcc.c-torture/compile/20160615-1.c	2016-06-15 11:17:48.811765657 +0200
8178f7
@@ -0,0 +1,10 @@
8178f7
+int a;
8178f7
+void bar (int, unsigned, unsigned);
8178f7
+
8178f7
+void
8178f7
+foo (unsigned x)
8178f7
+{
8178f7
+  unsigned b = a ? x : 0;
8178f7
+  if (x || b)
8178f7
+    bar (0, x, b);
8178f7
+}