revert: re PR rtl-optimization/57381 (array of volatile pointers hangs gcc)

2013-05-27  Richard Biener  <rguenther@suse.de>

	Revert
	PR middle-end/57381
	* fold-const.c (operand_equal_p): Compare FIELD_DECLs with
	OEP_CONSTANT_ADDRESS_OF retained.

	PR tree-optimization/57417
	* tree-ssa-sccvn.c (vn_reference_fold_indirect): Fix test
	for unchanged base.
	(set_ssa_val_to): Compare addresses using
	get_addr_base_and_unit_offset.

	* gcc.dg/torture/pr57417.c: New testcase.

From-SVN: r199356
This commit is contained in:
Richard Biener 2013-05-27 12:44:29 +00:00 committed by Richard Biener
parent 9606f3c9b1
commit d1de852b68
5 changed files with 45 additions and 4 deletions

View File

@ -1,3 +1,16 @@
2013-05-27 Richard Biener <rguenther@suse.de>
Revert
PR middle-end/57381
* fold-const.c (operand_equal_p): Compare FIELD_DECLs with
OEP_CONSTANT_ADDRESS_OF retained.
PR tree-optimization/57417
* tree-ssa-sccvn.c (vn_reference_fold_indirect): Fix test
for unchanged base.
(set_ssa_val_to): Compare addresses using
get_addr_base_and_unit_offset.
2013-05-27 Joern Rennecke <joern.rennecke@embecosm.com>
PR rtl-optimization/56833

View File

@ -2664,10 +2664,10 @@ 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) || !OP_SAME (1))
if (!OP_SAME_WITH_NULL (0))
return 0;
flags &= ~OEP_CONSTANT_ADDRESS_OF;
return OP_SAME_WITH_NULL (2);
return OP_SAME (1) && OP_SAME_WITH_NULL (2);
case BIT_FIELD_REF:
if (!OP_SAME (0))

View File

@ -1,3 +1,8 @@
2013-05-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/57417
* gcc.dg/torture/pr57417.c: New testcase.
2013-05-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/57396

View File

@ -0,0 +1,12 @@
/* { dg-do compile } */
int a, b;
volatile int *c;
void foo ()
{
volatile int d[1];
b = 0;
for (;; a--)
c = &d[b];
}

View File

@ -1145,7 +1145,7 @@ vn_reference_fold_indirect (vec<vn_reference_op_s> *ops,
addr_base = get_addr_base_and_unit_offset (TREE_OPERAND (op->op0, 0),
&addr_offset);
gcc_checking_assert (addr_base && TREE_CODE (addr_base) != MEM_REF);
if (addr_base != op->op0)
if (addr_base != TREE_OPERAND (op->op0, 0))
{
double_int off = tree_to_double_int (mem_op->op0);
off = off.sext (TYPE_PRECISION (TREE_TYPE (mem_op->op0)));
@ -2608,6 +2608,7 @@ static inline bool
set_ssa_val_to (tree from, tree to)
{
tree currval = SSA_VAL (from);
HOST_WIDE_INT toff, coff;
if (from != to)
{
@ -2643,7 +2644,17 @@ set_ssa_val_to (tree from, tree to)
print_generic_expr (dump_file, to, 0);
}
if (currval != to && !operand_equal_p (currval, to, OEP_PURE_SAME))
if (currval != to
&& !operand_equal_p (currval, to, 0)
/* ??? For addresses involving volatile objects or types operand_equal_p
does not reliably detect ADDR_EXPRs as equal. We know we are only
getting invariant gimple addresses here, so can use
get_addr_base_and_unit_offset to do this comparison. */
&& !(TREE_CODE (currval) == ADDR_EXPR
&& TREE_CODE (to) == ADDR_EXPR
&& (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff)
== get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff))
&& coff == toff))
{
VN_INFO (from)->valnum = to;
if (dump_file && (dump_flags & TDF_DETAILS))