diff options
author | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2015-02-04 08:22:45 +0000 |
---|---|---|
committer | Thomas Preud'homme <thopre01@gcc.gnu.org> | 2015-02-04 08:22:45 +0000 |
commit | cc9ef6a6419a8c343a5f0d233405411e8c5ca4cc (patch) | |
tree | e96e1033253fd235a5ba2291f141bd766024c589 | |
parent | 6a5fd0f8c1ecdae5c74fd058c524efdc44f87b80 (diff) | |
download | gcc-cc9ef6a6419a8c343a5f0d233405411e8c5ca4cc.zip gcc-cc9ef6a6419a8c343a5f0d233405411e8c5ca4cc.tar.gz gcc-cc9ef6a6419a8c343a5f0d233405411e8c5ca4cc.tar.bz2 |
re PR middle-end/62103 (Incorrect folding of bitfield in a union on big endian targets)
2015-02-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
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.
gcc/testsuite/
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.
From-SVN: r220390
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/bitfld-7.c | 23 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 2 |
4 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fdea07e..44aa27f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-02-04 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-02-03 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/64756 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad2633b..03585db 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2015-02-04 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. + +2015-02-04 Thomas Preud'homme <thomas.preudhomme@arm.com> + PR testsuite/64796 * lib/target-supports.exp (check_effective_target_bswap64): Do not cache result in a global variable. Include all 32-bit targets for 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; |