diff options
author | Richard Guenther <rguenther@suse.de> | 2012-01-03 08:59:21 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2012-01-03 08:59:21 +0000 |
commit | 8b3c295192e3886940be529ebd380b093d77fdef (patch) | |
tree | cce39e915f0c8795b8736c761af35b64f69fe9a8 | |
parent | 96fda42cb42f8aa502b306f2626227d5d2615919 (diff) | |
download | gcc-8b3c295192e3886940be529ebd380b093d77fdef.zip gcc-8b3c295192e3886940be529ebd380b093d77fdef.tar.gz gcc-8b3c295192e3886940be529ebd380b093d77fdef.tar.bz2 |
re PR c/51730 (autoconf 2.60 through 2.67 stdbool.h check fails with GCC 4.7)
2012-01-03 Richard Guenther <rguenther@suse.de>
PR middle-end/51730
* fold-const.c (fold_comparison): Properly canonicalize
tree offset and HOST_WIDE_INT bit position.
* gcc.dg/fold-compare-6.c: New testcase.
From-SVN: r182830
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-compare-6.c | 12 |
4 files changed, 39 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e9329b4..21533a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-01-03 Richard Guenther <rguenther@suse.de> + + PR middle-end/51730 + * fold-const.c (fold_comparison): Properly canonicalize + tree offset and HOST_WIDE_INT bit position. + 2012-01-02 Uros Bizjak <ubizjak@gmail.com> * config/ia64/ia64.c (expand_vec_perm_broadcast): Use correct diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5d3196b..b88b5d7 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8886,6 +8886,14 @@ fold_comparison (location_t loc, enum tree_code code, tree type, indirect_base0 = true; } offset0 = TREE_OPERAND (arg0, 1); + if (host_integerp (offset0, 0) + && ((HOST_WIDE_INT) (TREE_INT_CST_LOW (offset0) * BITS_PER_UNIT) + / BITS_PER_UNIT + == (HOST_WIDE_INT) TREE_INT_CST_LOW (offset0))) + { + bitpos0 = TREE_INT_CST_LOW (offset0) * BITS_PER_UNIT; + offset0 = NULL_TREE; + } } base1 = arg1; @@ -8909,6 +8917,14 @@ fold_comparison (location_t loc, enum tree_code code, tree type, indirect_base1 = true; } offset1 = TREE_OPERAND (arg1, 1); + if (host_integerp (offset1, 0) + && ((HOST_WIDE_INT) (TREE_INT_CST_LOW (offset1) * BITS_PER_UNIT) + / BITS_PER_UNIT + == (HOST_WIDE_INT) TREE_INT_CST_LOW (offset1))) + { + bitpos1 = TREE_INT_CST_LOW (offset1) * BITS_PER_UNIT; + offset1 = NULL_TREE; + } } /* A local variable can never be pointed to by diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e84b3a..70a292b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-03 Richard Guenther <rguenther@suse.de> + + PR middle-end/51730 + * gcc.dg/fold-compare-6.c: New testcase. + 2012-01-03 Jakub Jelinek <jakub@redhat.com> PR c++/51669 diff --git a/gcc/testsuite/gcc.dg/fold-compare-6.c b/gcc/testsuite/gcc.dg/fold-compare-6.c new file mode 100644 index 0000000..7ddf6b4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-compare-6.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +char digs[] = "0123456789"; +int foo (void) +{ + int xlcbug = 1 / (&(digs + 5)[-2 + (_Bool) 1] == &digs[4] ? 1 : -1); + return xlcbug; +} + +/* { dg-final { scan-tree-dump "xlcbug = 1;" "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ |