Commit e4969090 by Richard Biener Committed by Richard Biener

re PR tree-optimization/73434 (Wrong code with casting, branches and aliasing)

2016-08-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/73434
	* tree-ssa-sccvn.c (vn_reference_maybe_forwprop_address): Preserve
	TBAA info on the base when forwarding a non-invariant address.

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

From-SVN: r239471
parent 980bd537
2016-08-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/73434
* tree-ssa-sccvn.c (vn_reference_maybe_forwprop_address): Preserve
TBAA info on the base when forwarding a non-invariant address.
2016-08-15 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (struct checksum_attributes): Add
......
2016-08-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/73434
* gcc.dg/torture/pr73434.c: New testcase.
2016-08-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/72824
......
/* { dg-do run } */
typedef struct { unsigned char x; } A;
typedef struct { unsigned char x; } B;
int idx = 0;
A objs[1] = {{0}};
int main()
{
B *b = (B*)&objs[idx];
b->x++;
if (b->x)
b->x = 0;
if (b->x)
__builtin_abort ();
return 0;
}
......@@ -1225,6 +1225,18 @@ vn_reference_maybe_forwprop_address (vec<vn_reference_op_s> *ops,
{
auto_vec<vn_reference_op_s, 32> tem;
copy_reference_ops_from_ref (TREE_OPERAND (addr, 0), &tem);
/* Make sure to preserve TBAA info. The only objects not
wrapped in MEM_REFs that can have their address taken are
STRING_CSTs. */
if (tem.length () >= 2
&& tem[tem.length () - 2].opcode == MEM_REF)
{
vn_reference_op_t new_mem_op = &tem[tem.length () - 2];
new_mem_op->op0 = fold_convert (TREE_TYPE (mem_op->op0),
new_mem_op->op0);
}
else
gcc_assert (tem.last ().opcode == STRING_CST);
ops->pop ();
ops->pop ();
ops->safe_splice (tem);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment