This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix CSE RTL sharing ICE (PR rtl-optimization/55010)


Hi!

On the following testcase we have IF_THEN_ELSE in insn notes,
and when folding it, folded_arg1 is a subreg from earlier CC setter,
as the other argument has equiv constant, simplify_relational_operation
is called on it to simplify it and we end up with invalid RTL sharing
of the subreg in between the CC setter insn and the insn with the REG_EQ*
note.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2012-10-22  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/55010
	* cse.c (fold_rtx): Call copy_rtx on folded_arg{0,1} before passing
	it to simplify_relational_operation.

	* gcc.dg/pr55010.c: New test.

--- gcc/cse.c.jj	2012-10-16 13:15:45.000000000 +0200
+++ gcc/cse.c	2012-10-22 10:44:34.100033945 +0200
@@ -3461,8 +3461,8 @@ fold_rtx (rtx x, rtx insn)
 	}
 
       {
-	rtx op0 = const_arg0 ? const_arg0 : folded_arg0;
-	rtx op1 = const_arg1 ? const_arg1 : folded_arg1;
+	rtx op0 = const_arg0 ? const_arg0 : copy_rtx (folded_arg0);
+	rtx op1 = const_arg1 ? const_arg1 : copy_rtx (folded_arg1);
         new_rtx = simplify_relational_operation (code, mode, mode_arg0, op0, op1);
       }
       break;
--- gcc/testsuite/gcc.dg/pr55010.c.jj	2012-10-22 10:47:47.289857369 +0200
+++ gcc/testsuite/gcc.dg/pr55010.c	2012-10-22 10:47:33.000000000 +0200
@@ -0,0 +1,13 @@
+/* PR rtl-optimization/55010 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
+
+long long int a;
+unsigned long long int b;
+
+void
+foo (void)
+{
+  a = (a < 0) / ((a -= b) ? b >= ((b = a) || 0) : 0);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]