re PR tree-optimization/58794 (ICE in set_lattice_value, at tree-ssa-ccp.c:455 on x86_64-linux-gnu (at -O1, -O2, and -O3))

2013-10-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/58794
	* fold-const.c (operand_equal_p): Compare FIELD_DECL operand
	of COMPONENT_REFs with OEP_CONSTANT_ADDRESS_OF left in place.

	* c-c++-common/torture/pr58794-1.c: New testcase.
	* c-c++-common/torture/pr58794-2.c: Likewise.

From-SVN: r203891
This commit is contained in:
Richard Biener 2013-10-21 13:33:29 +00:00 committed by Richard Biener
parent d480e6a572
commit 2445aeac04
5 changed files with 65 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2013-10-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/58794
* fold-const.c (operand_equal_p): Compare FIELD_DECL operand
of COMPONENT_REFs with OEP_CONSTANT_ADDRESS_OF left in place.
2013-10-21 Richard Biener <rguenther@suse.de>
PR middle-end/58742

View File

@ -2715,10 +2715,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
case COMPONENT_REF:
/* Handle operand 2 the same as for ARRAY_REF. Operand 0
may be NULL when we're called to compare MEM_EXPRs. */
if (!OP_SAME_WITH_NULL (0))
if (!OP_SAME_WITH_NULL (0)
|| !OP_SAME (1))
return 0;
flags &= ~OEP_CONSTANT_ADDRESS_OF;
return OP_SAME (1) && OP_SAME_WITH_NULL (2);
return OP_SAME_WITH_NULL (2);
case BIT_FIELD_REF:
if (!OP_SAME (0))

View File

@ -1,3 +1,9 @@
2013-10-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/58794
* c-c++-common/torture/pr58794-1.c: New testcase.
* c-c++-common/torture/pr58794-2.c: Likewise.
2013-10-21 Richard Biener <rguenther@suse.de>
PR middle-end/58742

View File

@ -0,0 +1,29 @@
/* { dg-do compile } */
struct S0
{
int f;
};
struct S1
{
struct S0 f1;
volatile int f2;
};
struct S2
{
struct S1 g;
} a, b;
static int *c[1][2] = {{0, (int *)&a.g.f2}};
static int d;
int
main ()
{
for (d = 0; d < 1; d++)
for (b.g.f1.f = 0; b.g.f1.f < 1; b.g.f1.f++)
*c[b.g.f1.f][d + 1] = 0;
return 0;
}

View File

@ -0,0 +1,21 @@
/* { dg-do compile } */
struct S
{
volatile int f;
} a;
unsigned int b;
static int *c[1][2] = {{0, (int *)&a.f}};
static unsigned int d;
int
main ()
{
for (; d < 1; d++)
for (; b < 1; b++)
*c[b][d + 1] = 0;
return 0;
}