re PR tree-optimization/53663 (inconsistent inline handling of bool within union)

2012-09-25  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/53663
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Conditional
	native encode/interpret translation on VN_WALKREWRITE.

	* gcc.dg/torture/pr53663-1.c: New testcase.
	* gcc.dg/torture/pr53663-2.c: Likewise.
	* gcc.dg/torture/pr53663-3.c: Likewise.

From-SVN: r191694
This commit is contained in:
Richard Guenther 2012-09-25 07:51:51 +00:00 committed by Richard Biener
parent 9fe7fbd5df
commit b2e519796c
6 changed files with 93 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2012-09-25 Richard Guenther <rguenther@suse.de>
PR tree-optimization/53663
* tree-ssa-sccvn.c (vn_reference_lookup_3): Conditional
native encode/interpret translation on VN_WALKREWRITE.
2012-09-24 Dehao Chen <dehao@google.com>
* tree-cfg.c (move_stmt_op): Reset the expr block only

View File

@ -1,3 +1,10 @@
2012-09-25 Richard Guenther <rguenther@suse.de>
PR tree-optimization/53663
* gcc.dg/torture/pr53663-1.c: New testcase.
* gcc.dg/torture/pr53663-2.c: Likewise.
* gcc.dg/torture/pr53663-3.c: Likewise.
2012-09-25 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/pr50725.c: Change 'long' to 'long long'.

View File

@ -0,0 +1,30 @@
/* { dg-do run } */
extern void abort (void);
union u
{
int i;
_Bool b;
};
void f(union u * vp, union u v)
{
*vp = v;
}
int main()
{
union u v;
union u v1;
union u v2;
v.i = 10;
f(&v1, v);
v.b = 0;
f(&v2, v);
if (v2.b != 0)
abort ();
return 0;
}

View File

@ -0,0 +1,24 @@
/* { dg-do run } */
extern void abort (void);
union u
{
int i;
short f;
} v;
short foo (short *f)
{
*f = 1;
v.i = 0;
v.f = 0;
return *f;
}
int main()
{
if (foo (&v.f) != 0)
abort ();
return 0;
}

View File

@ -0,0 +1,24 @@
/* { dg-do run } */
extern void abort (void);
union u
{
int i;
float f;
} v;
float foo (float *f)
{
*f = 1;
v.i = 0;
v.f = 0.;
return *f;
}
int main()
{
if (foo (&v.f) != 0.)
abort ();
return 0;
}

View File

@ -1555,7 +1555,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_)
/* 3) Assignment from a constant. We can use folds native encode/interpret
routines to extract the assigned bits. */
else if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
else if (vn_walk_kind == VN_WALKREWRITE
&& CHAR_BIT == 8 && BITS_PER_UNIT == 8
&& ref->size == maxsize
&& maxsize % BITS_PER_UNIT == 0
&& offset % BITS_PER_UNIT == 0