From f54437d5f7912771af11f75bdb370dc440ab2b26 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Wed, 15 Oct 2014 15:48:33 +0000 Subject: [PATCH] re PR rtl-optimization/63448 (ICE when compiling atlas 3.10.2) 2014-10-15 Vladimir Makarov 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 Vladimir Makarov PR rtl-optimization/63448 * gcc.target/i386/pr63448.c: New test. From-SVN: r216270 --- gcc/ChangeLog | 24 +++++ gcc/lra-assigns.c | 29 +++++- gcc/lra-constraints.c | 9 -- gcc/lra-int.h | 12 ++- gcc/lra.c | 6 +- gcc/testsuite/ChangeLog | 5 + gcc/testsuite/gcc.target/i386/pr63448.c | 120 ++++++++++++++++++++++++ 7 files changed, 187 insertions(+), 18 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr63448.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9dc31881fb3..8eb654c0a4b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,27 @@ +2014-10-15 Vladimir Makarov + + 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 PR bootstrap/63432 diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c index 7b862a488e6..8dbcec4eaec 100644 --- a/gcc/lra-assigns.c +++ b/gcc/lra-assigns.c @@ -97,6 +97,15 @@ along with GCC; see the file COPYING3. If not see #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; @@ -994,6 +1003,8 @@ spill_for (int regno, bitmap spilled_pseudo_bitmap, bool first_p) /* 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), @@ -1109,6 +1120,8 @@ setup_live_pseudos_and_spill_after_risky_transforms (bitmap 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); @@ -1373,7 +1386,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, @@ -1487,12 +1503,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, ®_obstack); create_live_range_start_chains (); @@ -1540,5 +1561,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; } diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index f90d13be0a3..2b17aa39fbc 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -3895,10 +3895,6 @@ loc_equivalence_callback (rtx loc, const_rtx, void *data) /* 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 @@ -4043,11 +4039,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; if (pic_offset_table_rtx && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER) diff --git a/gcc/lra-int.h b/gcc/lra-int.h index 28903e1cad8..1337acad0d0 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -251,9 +251,10 @@ typedef struct lra_insn_recog_data *lra_insn_recog_data_t; #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 @@ -266,7 +267,7 @@ typedef struct lra_insn_recog_data *lra_insn_recog_data_t; #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 @@ -331,7 +332,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; @@ -368,6 +368,8 @@ extern void lra_setup_reload_pseudo_preferenced_hard_reg (int, int, int); /* 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); diff --git a/gcc/lra.c b/gcc/lra.c index e9194bbd8b6..f664f070cbb 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -2140,8 +2140,8 @@ lra (FILE *f) 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 (); @@ -2275,7 +2275,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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fb25dae6f94..0c3e540c69b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-10-15 Vladimir Makarov + + PR rtl-optimization/63448 + * gcc.target/i386/pr63448.c: New test. + 2014-10-15 Eric Botcazou * gnat.dg/opt41.adb: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr63448.c b/gcc/testsuite/gcc.target/i386/pr63448.c new file mode 100644 index 00000000000..3f8262e87e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr63448.c @@ -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); +} -- 2.30.2