diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e620e306403..d15a87dcca6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-01-21 Vladimir Makarov + + PR rtl-optimization/68990 + * lra-coalesce.c (lra_coalesce): Invalidate value for the result + pseudo instead of inheritance ones. + 2016-01-21 Bernd Enlinger Nick Clifton diff --git a/gcc/lra-coalesce.c b/gcc/lra-coalesce.c index 94764d98444..178ed3ff5cb 100644 --- a/gcc/lra-coalesce.c +++ b/gcc/lra-coalesce.c @@ -224,13 +224,10 @@ lra_coalesce (void) rtx_insn *mv, *insn, *next, **sorted_moves; rtx set; int i, mv_num, sregno, dregno; - unsigned int regno; int coalesced_moves; int max_regno = max_reg_num (); bitmap_head involved_insns_bitmap; - bitmap_head result_pseudo_vals_bitmap; - bitmap_iterator bi; - + timevar_push (TV_LRA_COALESCE); if (lra_dump_file != NULL) @@ -327,7 +324,7 @@ lra_coalesce (void) } /* If we have situation after inheritance pass: - r1 <- ... insn originally setting p1 + r1 <- p1 insn originally setting p1 i1 <- r1 setting inheritance i1 from reload r1 ... ... <- ... p2 ... dead p2 @@ -339,20 +336,18 @@ lra_coalesce (void) And we are coalescing p1 and p2 using p1. In this case i1 and p1 should have different values, otherwise they can get the same hard reg and this is wrong for insn using p2 before coalescing. - So invalidate such inheritance pseudo values. */ - bitmap_initialize (&result_pseudo_vals_bitmap, ®_obstack); - EXECUTE_IF_SET_IN_BITMAP (&coalesced_pseudos_bitmap, 0, regno, bi) - bitmap_set_bit (&result_pseudo_vals_bitmap, - lra_reg_info[first_coalesced_pseudo[regno]].val); - EXECUTE_IF_SET_IN_BITMAP (&lra_inheritance_pseudos, 0, regno, bi) - if (bitmap_bit_p (&result_pseudo_vals_bitmap, lra_reg_info[regno].val)) + The situation even can be more complicated when new reload + pseudos occur after the inheriatnce. So invalidate the result + pseudos. */ + for (i = 0; i < max_regno; i++) + if (first_coalesced_pseudo[i] == i + && first_coalesced_pseudo[i] != next_coalesced_pseudo[i]) { - lra_set_regno_unique_value (regno); + lra_set_regno_unique_value (i); if (lra_dump_file != NULL) fprintf (lra_dump_file, - " Make unique value for inheritance r%d\n", regno); + " Make unique value for coalescing result r%d\n", i); } - bitmap_clear (&result_pseudo_vals_bitmap); bitmap_clear (&used_pseudos_bitmap); bitmap_clear (&involved_insns_bitmap); bitmap_clear (&coalesced_pseudos_bitmap); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08aafd10722..843ccac194d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-01-21 Vladimir Makarov + + PR rtl-optimization/68990 + * gcc.target/i386/pr68990: New. + 2016-01-21 Nick Clifton PR target/69129 diff --git a/gcc/testsuite/gcc.target/i386/pr68990.c b/gcc/testsuite/gcc.target/i386/pr68990.c new file mode 100644 index 00000000000..4c3ca0331d5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr68990.c @@ -0,0 +1,49 @@ +/* { dg-do compile { target { ia32 } } } */ +/* { dg-options "-O3 -march=x86-64" } */ +/* { dg-final { scan-assembler-not "cmpl\[ \t]+(\[%a-z]+), \\1" } } */ + +short a; +int b = 1, f; +char c, e = 1; +long long d; + +static short +foo () +{ + unsigned g, h = 0; + int i = 0 || d * (b | e); + char j = a << i, l = a; + short k; + int m = -b; + if (m < b) + { + k = m = b; + g = (k || l) / (b / e); + if (b) + __builtin_printf ("foo=%lld\n", (long long) a); + } + a = b = m; + if (j || e) + { + h = g; + i = m; + g = j * k / (i - d); + if (m) + b = j && b; + e = b * (h & d) || g; + } + b = i; + char n = e || h | d; + e = i < d & k / n; + return f; +} + +int +main () +{ + if (foo ()) + if (c) + lab: + goto lab; + return 0; +}