Hi, The issue is also present in 4.9 branch as explained in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65647 As 4.9 doesn't contains lra rematerialization passe, we only need to stop updating lra_constraint_new_regno_start when inheritance is switched off. Bootstrapped and tested on x64_64 and cross built and tested on AArch64, arm, armeb and i686. Ok for 4.9 ? Cheers, Yvan 2015-04-05 Yvan Roux <yvan.r...@linaro.org> Backport from trunk r221867 2015-04-04 Vladimir Makarov <vmaka...@redhat.com> PR target/65647 * lra.c (lra): Stop updating lra_constraint_new_regno_start after switching off inheritance. 2015-04-05 Yvan Roux <yvan.r...@linaro.org> Backport from trunk r221867 2015-04-04 Vladimir Makarov <vmaka...@redhat.com> PR target/65647 * gcc.target/arm/pr65647.c: New. * gcc.target/arm/pr65647-2.c: New. On 4 April 2015 at 16:39, Vladimir Makarov <vmaka...@redhat.com> wrote: > The following patch fixes > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65647 > > This very complicated problem occurred in rare cases when chain of reloads > involving at least two pseudos and insns were generated and one pseudo was > spilled on later sub-passes after spilling sub-pass and this pattern > happened to be repeated. > > The patch was bootstrapped and tested on x86/x86-64, ppc64, and aarch64. > > Committed as rev.221867. > > 2015-04-04 Vladimir Makarov <vmaka...@redhat.com> > > PR target/65647 > * lra-int.h (LRA_MAX_REMATERIALIZATION_PASSES): New. Add its > value checking. > (lra_rematerialization_iter): New. > * lra.c (lra): Initialize lra_rematerialization_iter. > Stop updating lra_constraint_new_regno_start after switching of > inheritance and rematerialization. > * lra-remat.c (lra_rematerialization_iter): New. > (lra_remat): Add printing pass iteration. Do rematerialization > only first LRA_MAX_REMATERIALIZATION_PASSES iterations. > > 2015-04-04 Vladimir Makarov <vmaka...@redhat.com> > > PR target/65647 > * gcc.target/arm/pr65647.c: New. > >
diff --git a/gcc/lra.c b/gcc/lra.c index 69b08dc..98f0444 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -2417,7 +2417,11 @@ lra (FILE *f) /* Assignment of stack slots changes elimination offsets for some eliminations. So update the offsets here. */ lra_eliminate (false, false); - lra_constraint_new_regno_start = max_reg_num (); + /* After switching off inheritance passe, don't forget reload pseudos + after spilling sub-pass to avoid LRA cycling in some complicated + cases. */ + if (lra_inheritance_iter <= LRA_MAX_INHERITANCE_PASSES) + lra_constraint_new_regno_start = max_reg_num (); lra_constraint_new_insn_uid_start = get_max_uid (); lra_assignment_iter_after_spill = 0; } diff --git a/gcc/testsuite/gcc.target/arm/pr65647-2.c b/gcc/testsuite/gcc.target/arm/pr65647-2.c new file mode 100644 index 0000000..f2985f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr65647-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -marm -march=armv6 -std=c99" } */ + +typedef struct { + int i; +} x264_union32_t; +typedef struct { + int level_idx; +} trellis_node_t; +int a, c, d, f, h, i = (int)&c; +trellis_node_t b[1][1]; +short *e = 0; +short g; +void fn1() { + int k[64 * 8 * 2]; + trellis_node_t *l = b[0]; + for (; i >= d; i--) { + if (e[i]) { + for (int j = 1; j < 8; j++) { + ((x264_union32_t *)&k[a])->i = l[j].level_idx; + l[j].level_idx = a; + a++; + } + continue; + } + for (int j;; j++) + ; + } + int m[6] __attribute__((aligned(16))); + for (; h; h++, f++) + g = m[h]; +} diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c b/gcc/testsuite/gcc.target/arm/pr65647.c new file mode 100644 index 0000000..686eb58 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr65647.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv6-m -mthumb -O3 -w" } */ + +a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x, + y = 6, z, t6 = 7, t8, t9 = 1, t11 = 5, t12 = &t8, t13 = 3, t15, + t16 = &t15; +struct { + long long f3; + char f4 +} p = {3} + + , + t = {4}; + +struct S1 { + long long f0; + short f1; + long long f2 +} d; +long long f = 4073709551613, t7 = 8, t14 = 4073709551610; +j[]; +k = j; +v = &d; +*t10 = j; +struct S1 fn1(); +struct S1 fn2() { + signed char t1; + struct S1 t2; + long t3 = x; + short t4 = h; + short *t5 = &l; + fn1(t2, w, 1, o); + if (u) { + l = q; + t1 = a < b ?: b; + z = c >= 2 || t1 << c; + } + *t5 = t4 &= t3; + fn3(y); +} + +fn4() { + t6 = t.f3; + fn5(k, t7); +} + +struct S1 fn1() { + f = 0; + for (; i;) + ; + t11 = 0; + t13 = *t10 = t14 || n; + t9 = t12; + for (; p.f4;) + s = t16 <= fn6(); + if (g) + v = 0; +}