Message ID | 00d701d04024$9aa50250$cfef06f0$@arm.com |
---|---|
State | New |
Headers | show |
On Wed, Feb 04, 2015 at 10:45:11AM +0800, Thomas Preud'homme wrote: > 2015-01-30 Thomas Preud'homme <thomas.preudhomme@arm.com> > > PR middle-end/62103 > * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Use TYPE_PRECISION > to compute size of referenced value in the constant case. > > 2015-01-30 Thomas Preud'homme <thomas.preudhomme@arm.com> > > PR middle-end/62103 > * gcc.c-torture/execute/bitfld-7.c: New test adapted from bitfld-6.c > to use 24 bits for bitfield b. Richard already acked it with the new testcase, so yes, this is ok for the trunk (just use today's date). Jakub
> From: Jakub Jelinek [mailto:jakub@redhat.com] > Sent: Wednesday, February 04, 2015 3:54 PM > > Richard already acked it with the new testcase, so yes, this is ok for the > trunk (just use today's date). Oups my bad, I forgot he acked it. Thanks and best regards. Thomas
diff --git a/gcc/testsuite/gcc.c-torture/execute/bitfld-7.c b/gcc/testsuite/gcc.c-torture/execute/bitfld-7.c new file mode 100644 index 0000000..e9a61df --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bitfld-7.c @@ -0,0 +1,23 @@ +union U +{ + const int a; + unsigned b : 24; +}; + +static union U u = { 0x12345678 }; + +/* Constant folding used to fail to account for endianness when folding a + union. */ + +int +main (void) +{ +#ifdef __BYTE_ORDER__ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + return u.b - 0x345678; +#else + return u.b - 0x123456; +#endif +#endif + return 0; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 25c67d0..0f1299a 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1352,7 +1352,7 @@ fully_constant_vn_reference_p (vn_reference_t ref) || TYPE_PRECISION (ref->type) % BITS_PER_UNIT == 0)) { HOST_WIDE_INT off = 0; - HOST_WIDE_INT size = tree_to_shwi (TYPE_SIZE (ref->type)); + HOST_WIDE_INT size = TYPE_PRECISION (ref->type); if (size % BITS_PER_UNIT != 0 || size > MAX_BITSIZE_MODE_ANY_MODE) return NULL_TREE;