+2014-10-15 Vladimir Makarov <vmakarov@redhat.com>
+
+ PR rtl-optimization/63448
+ * lra-int.h (LRA_MAX_CONSTRAINT_ITERATION_NUMBER): Remove.
+ (LRA_MAX_ASSIGNMENT_ITERATION_NUMBER): New.
+ (LRA_MAX_INHERITANCE_PASSES): Use it.
+ (lra_constraint_iter_after_spill): Remove.
+ (lra_assignment_iter): New.
+ (lra_assignment_iter_after_spill): New.
+ * lra-assigns.c (lra_assignment_iter): New.
+ (lra_assignment_iter_after_spill): New.
+ (former_reload_pseudo_spill_p): New.
+ (spill_for): Set up former_reload_pseudo_spill_p.
+ (setup_live_pseudos_and_spill_after_risky): Ditto.
+ (assign_by_spills): Ditto.
+ (lra_assign): Increment lra_assignment_iter. Print the iteration
+ number. Reset former_reload_pseudo_spill_p. Check
+ lra_assignment_iter_after_spill.
+ * lra.c (lra): Remove lra_constraint_iter_after_spill. Initialize
+ lra_assignment_iter and lra_assignment_iter_after_spill.
+ * lra-constraints.c (lra_constraint_iter_after_spill): Remove.
+ (lra_constraints): Remove code with
+ lra_assignment_iter_after_spill.
+
2014-10-15 Teresa Johnson <tejohnson@google.com>
PR bootstrap/63432
#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;
/* 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),
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);
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,
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, ®_obstack);
create_live_range_start_chains ();
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;
}
/* 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
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;
if (pic_offset_table_rtx
&& REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER)
#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
#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
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;
/* 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);
values, clear them. */
recog_init ();
- 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 ();
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);
+2014-10-15 Vladimir Makarov <vmakarov@redhat.com>
+
+ PR rtl-optimization/63448
+ * gcc.target/i386/pr63448.c: New test.
+
2014-10-15 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt41.adb: New test.
--- /dev/null
+/* 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);
+}