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]

Fix/work around PR57676, LRA terminates prematurely


The testcase in this PR causes gcc to abort with

internal compiler error: Maximum number of LRA constraint passes is achieved (30)

[in theory - I've not managed to reproduce this on my system with any compiler]

The abort is premature, allowing LRA to continue would allow the testcase to compile. Vlad would like to leave the check in, however, as it is a good way to catch problems with machine descriptions as they are converted to use LRA.

The following is a compromise I came up with after some internal discussion. The idea is to leave the assert in under -fchecking, so that release compilers do not prematurely abort for valid testcases, while development builds get an additional sanity check.

Bootstrapped and tested on x86_64-linux. Ok?


Bernd

	PR rtl-optimization/57676
	* lra-assigns.c (lra_assign): Guard test for maximum iterations
	with flag_checking.

	PR rtl-optimization/57676
	* gcc.dg/torture/pr57676.c: New test.

Index: gcc/lra-assigns.c
===================================================================
--- gcc/lra-assigns.c	(revision 233451)
+++ gcc/lra-assigns.c	(working copy)
@@ -1620,7 +1620,12 @@ lra_assign (void)
   timevar_pop (TV_LRA_ASSIGN);
   if (former_reload_pseudo_spill_p)
     lra_assignment_iter_after_spill++;
-  if (lra_assignment_iter_after_spill > LRA_MAX_ASSIGNMENT_ITERATION_NUMBER)
+  /* This is conditional on flag_checking because valid code can take
+     more than this maximum number of iteration, but at the same time
+     the test can uncover errors in machine descriptions.  */
+  if (flag_checking
+      && (lra_assignment_iter_after_spill
+	  > LRA_MAX_ASSIGNMENT_ITERATION_NUMBER))
     internal_error
       ("Maximum number of LRA assignment passes is achieved (%d)\n",
        LRA_MAX_ASSIGNMENT_ITERATION_NUMBER);
Index: gcc/testsuite/gcc.dg/torture/pr57676.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr57676.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr57676.c	(working copy)
@@ -0,0 +1,28 @@
+/* Verify that LRA does not abort prematurely in a release build of the
+   compiler.  */
+/* { dg-do compile } */
+/* { dg-options "-fno-checking -w -funroll-loops" } */
+
+int a, b, c;
+
+void f(p1)
+{
+    for(;;)
+    {
+        if(p1 ? : (c /= 0))
+        {
+            int d;
+
+            for(; d; d++)
+            {
+                for(b = 0; b < 4; b++)
+                    p1 /= p1;
+lbl:
+                while(a);
+            }
+        }
+
+        if((c &= 1))
+            goto lbl;
+    }
+}


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