Index: lra-assigns.c
===================================================================
--- lra-assigns.c	(revision 216205)
+++ lra-assigns.c	(working copy)
@@ -97,6 +97,15 @@ along with GCC; see the file COPYING3.	I
 #include "params.h"
 #include "lra-int.h"
 
+/* Current iteration number of the pass and current iteration number
+   of the pass after the latest spill pass when any former reload
+   pseudo was spilled.  */
+int lra_assignment_iter;
+int lra_assignment_iter_after_spill;
+
+/* Flag of spilling former reload pseudos on this pass.  */
+static bool former_reload_pseudo_spill_p;
+
 /* Array containing corresponding values of function
    lra_get_allocno_class.  It is used to speed up the code.  */
 static enum reg_class *regno_allocno_class_array;
@@ -992,6 +1001,8 @@ spill_for (int regno, bitmap spilled_pse
   /* Spill: */
   EXECUTE_IF_SET_IN_BITMAP (&best_spill_pseudos_bitmap, 0, spill_regno, bi)
     {
+      if ((int) spill_regno >= lra_constraint_new_regno_start)
+	former_reload_pseudo_spill_p = true;
       if (lra_dump_file != NULL)
 	fprintf (lra_dump_file, "      Spill %sr%d(hr=%d, freq=%d) for r%d\n",
 		 pseudo_prefix_title (spill_regno),
@@ -1101,6 +1112,8 @@ setup_live_pseudos_and_spill_after_risky
 	   j++)
 	lra_hard_reg_usage[hard_regno + j] -= lra_reg_info[regno].freq;
       reg_renumber[regno] = -1;
+      if (regno >= lra_constraint_new_regno_start)
+	former_reload_pseudo_spill_p = true;
       if (lra_dump_file != NULL)
 	fprintf (lra_dump_file, "    Spill r%d after risky transformations\n",
 		 regno);
@@ -1361,7 +1374,10 @@ assign_by_spills (void)
       EXECUTE_IF_SET_IN_SPARSESET (live_range_hard_reg_pseudos, conflict_regno)
 	{
 	  if ((int) conflict_regno >= lra_constraint_new_regno_start)
-	    sorted_pseudos[nfails++] = conflict_regno;
+	    {
+	      sorted_pseudos[nfails++] = conflict_regno;
+	      former_reload_pseudo_spill_p = true;
+	    }
 	  if (lra_dump_file != NULL)
 	    fprintf (lra_dump_file, "	  Spill %s r%d(hr=%d, freq=%d)\n",
 		     pseudo_prefix_title (conflict_regno), conflict_regno,
@@ -1449,12 +1465,17 @@ lra_assign (void)
   int max_regno = max_reg_num ();
 
   timevar_push (TV_LRA_ASSIGN);
+  lra_assignment_iter++;
+  if (lra_dump_file != NULL)
+    fprintf (lra_dump_file, "\n********** Assignment #%d: **********\n\n",
+	     lra_assignment_iter);
   init_lives ();
   sorted_pseudos = XNEWVEC (int, max_regno);
   sorted_reload_pseudos = XNEWVEC (int, max_regno);
   regno_allocno_class_array = XNEWVEC (enum reg_class, max_regno);
   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
     regno_allocno_class_array[i] = lra_get_allocno_class (i);
+  former_reload_pseudo_spill_p = false;
   init_regno_assign_info ();
   bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
   create_live_range_start_chains ();
@@ -1501,5 +1522,11 @@ lra_assign (void)
   free (sorted_reload_pseudos);
   finish_lives ();
   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)
+    internal_error
+      ("Maximum number of LRA assignment passes is achieved (%d)\n",
+       LRA_MAX_ASSIGNMENT_ITERATION_NUMBER);
   return no_spills_p;
 }
Index: lra-constraints.c
===================================================================
--- lra-constraints.c	(revision 216205)
+++ lra-constraints.c	(working copy)
@@ -3920,10 +3920,6 @@ loc_equivalence_callback (rtx loc, const
 /* The current iteration number of this LRA pass.  */
 int lra_constraint_iter;
 
-/* The current iteration number of this LRA pass after the last spill
-   pass.  */
-int lra_constraint_iter_after_spill;
-
 /* True if we substituted equiv which needs checking register
    allocation correctness because the equivalent value contains
    allocatable hard registers or when we restore multi-register
@@ -4069,11 +4065,6 @@ lra_constraints (bool first_p)
   if (lra_dump_file != NULL)
     fprintf (lra_dump_file, "\n********** Local #%d: **********\n\n",
 	     lra_constraint_iter);
-  lra_constraint_iter_after_spill++;
-  if (lra_constraint_iter_after_spill > LRA_MAX_CONSTRAINT_ITERATION_NUMBER)
-    internal_error
-      ("Maximum number of LRA constraint passes is achieved (%d)\n",
-       LRA_MAX_CONSTRAINT_ITERATION_NUMBER);
   changed_p = false;
   lra_risky_transformations_p = false;
   new_insn_uid_start = get_max_uid ();
Index: lra-int.h
===================================================================
--- lra-int.h	(revision 216205)
+++ lra-int.h	(working copy)
@@ -244,9 +244,10 @@ typedef struct lra_insn_recog_data *lra_
 #define LRA_LOSER_COST_FACTOR 6
 #define LRA_MAX_REJECT 600
 
-/* Maximum allowed number of constraint pass iterations after the last
-   spill pass.	It is for preventing LRA cycling in a bug case.	 */
-#define LRA_MAX_CONSTRAINT_ITERATION_NUMBER 30
+/* Maximum allowed number of assignment pass iterations after the
+   latest spill pass when any former reload pseudo was spilled.  It is
+   for preventing LRA cycling in a bug case.  */
+#define LRA_MAX_ASSIGNMENT_ITERATION_NUMBER 30
 
 /* The maximal number of inheritance/split passes in LRA.  It should
    be more 1 in order to perform caller saves transformations and much
@@ -259,7 +260,7 @@ typedef struct lra_insn_recog_data *lra_
 #define LRA_MAX_INHERITANCE_PASSES 2
 
 #if LRA_MAX_INHERITANCE_PASSES <= 0 \
-    || LRA_MAX_INHERITANCE_PASSES >= LRA_MAX_CONSTRAINT_ITERATION_NUMBER - 8
+    || LRA_MAX_INHERITANCE_PASSES >= LRA_MAX_ASSIGNMENT_ITERATION_NUMBER - 8
 #error wrong LRA_MAX_INHERITANCE_PASSES value
 #endif
 
@@ -323,7 +324,6 @@ extern void lra_init_equiv (void);
 extern int lra_constraint_offset (int, enum machine_mode);
 
 extern int lra_constraint_iter;
-extern int lra_constraint_iter_after_spill;
 extern bool lra_risky_transformations_p;
 extern int lra_inheritance_iter;
 extern int lra_undo_inheritance_iter;
@@ -360,6 +360,8 @@ extern void lra_setup_reload_pseudo_pref
 
 /* lra-assigns.c: */
 
+extern int lra_assignment_iter;
+extern int lra_assignment_iter_after_spill;
 extern void lra_setup_reg_renumber (int, int, bool);
 extern bool lra_assign (void);
 
Index: lra.c
===================================================================
--- lra.c	(revision 216205)
+++ lra.c	(working copy)
@@ -2295,8 +2295,8 @@ lra (FILE *f)
 
   lra_in_progress = 1;
 
-  lra_live_range_iter = lra_coalesce_iter = 0;
-  lra_constraint_iter = lra_constraint_iter_after_spill = 0;
+  lra_live_range_iter = lra_coalesce_iter = lra_constraint_iter = 0;
+  lra_assignment_iter = lra_assignment_iter_after_spill = 0;
   lra_inheritance_iter = lra_undo_inheritance_iter = 0;
 
   setup_reg_spill_flag ();
@@ -2419,7 +2419,7 @@ lra (FILE *f)
       lra_eliminate (false, false);
       lra_constraint_new_regno_start = max_reg_num ();
       lra_constraint_new_insn_uid_start = get_max_uid ();
-      lra_constraint_iter_after_spill = 0;
+      lra_assignment_iter_after_spill = 0;
     }
   restore_scratches ();
   lra_eliminate (true, false);
Index: testsuite/gcc.target/i386/pr63448.c
===================================================================
--- testsuite/gcc.target/i386/pr63448.c	(revision 0)
+++ testsuite/gcc.target/i386/pr63448.c	(working copy)
@@ -0,0 +1,120 @@
+/* PR rtl-optimization/63448 */
+/* { dg-do compile } */
+/* { dg-options "-O -std=c99" } */
+
+int a, d, e, g, h, j;
+float b, c, k, l, m, n;
+int *__restrict i;
+void
+foo (void)
+{
+  int o = e;
+  int *p;
+  float *q, *r = (float *) 0x1234000;
+  float s, t, u, v, w, x;
+  do
+    {
+      for (a = o; a; a--)
+	{
+	  s += m;
+	  t += n;
+	  u += m;
+	  v += n;
+	  w += d;
+	  x += d;
+	  n = l;
+	  s += r[1];
+	  t += n;
+	  v += r[1];
+	  m = k * r[4];
+	  n = q[0] * r[4];
+	  s += m;
+	  m = q[1] * r[4];
+	  t += n;
+	  q += g;
+	  k = *q;
+	  n = q[1] * r[4];
+	  s += m;
+	  t += n;
+	  u += r[4];
+	  m = q[8] * r[4];
+	  q += 1;
+	  n = q[1] * r[4];
+	  s += m;
+	  m = q[4];
+	  t += n;
+	  q += g;
+	  w += m;
+	  m = k * r[4];
+	  s += m;
+	  t += q[0];
+	  m = q[1] * r[4];
+	  v += q[0];
+	  n = q[10] * r[4];
+	  s += m;
+	  t += n;
+	  u += b;
+	  m = q[8] * r[4];
+	  n = q[2] * r[4];
+	  s += m;
+	  m = q[4] * r[4];
+	  t += n;
+	  q++;
+	  n = q[2] * r[16];
+	  s += m;
+	  m = q[4];
+	  t += n;
+	  s += m;
+	  t += r[6];
+	  q += g;
+	  k = *q;
+	  w += m;
+	  m = k * r[20];
+	  x += r[16];
+	  n = q[1] * r[20];
+	  s += m;
+	  t += n;
+	  q += g;
+	  k = *q;
+	  w += m;
+	  m = k * r[2];
+	  n = q[1] * r[22];
+	  s += m;
+	  m = q[4];
+	  t += n;
+	  q += g;
+	  s += m;
+	  t += q[0];
+	  s += m;
+	  u += m;
+	  n = q[1] * r[22];
+	  s += m;
+	  m = q[4] * r[22];
+	  t += n;
+	  q += g;
+	  k = 1;
+	  w += m;
+	  c = q[10];
+	  x += r[22];
+	  s += m;
+	  t += r[22];
+	  u += m;
+	  v += r[22];
+	  n = q[10] * r[30];
+	  d = r[32];
+	  l = q[1];
+	  b = 0;
+	  w += m;
+	  m = r[32];
+	  x += n;
+	  r = 0;
+	}
+      *i = s;
+      p[0] = t;
+      p[1] = u;
+      p[6] = v;
+      p[8] = w;
+      p[10] = x;
+    }
+  while (j);
+}
