re PR rtl-optimization/68990 (wrong code at -O3 on x86_64-pc-linux-gnu in 32-bit mode.)

2016-01-21  Vladimir Makarov  <vmakarov@redhat.com>

	PR rtl-optimization/68990
	* lra-coalesce.c (lra_coalesce): Invalidate value for the result
	pseudo instead of inheritance ones.

2016-01-21  Vladimir Makarov  <vmakarov@redhat.com>

	PR rtl-optimization/68990
	* gcc.target/i386/pr68990: New.

From-SVN: r232679
This commit is contained in:
Vladimir Makarov 2016-01-21 16:01:22 +00:00 committed by Vladimir Makarov
parent 975b10daea
commit 35b707ff99
4 changed files with 70 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2016-01-21 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/68990
* lra-coalesce.c (lra_coalesce): Invalidate value for the result
pseudo instead of inheritance ones.
2016-01-21 Bernd Enlinger <bernd.edlinger@hotmail.de>
Nick Clifton <nickc@redhat.com>

View File

@ -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, &reg_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);

View File

@ -1,3 +1,8 @@
2016-01-21 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/68990
* gcc.target/i386/pr68990: New.
2016-01-21 Nick Clifton <nickc@redhat.com>
PR target/69129

View File

@ -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;
}