diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-02-11 21:08:44 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-02-11 21:08:44 +0000 |
commit | c89118bcfe7b1d0b546101c5dc09d9f19ece68bf (patch) | |
tree | 7fae11a3fb3ae2fe3eb5779237227483c916e792 | |
parent | 7983510f5f68031ea27ad57d0388a1855700d1f4 (diff) |
PR middle-end/19858
* fold-const.c (make_bit_field_ref): If bitpos == 0 and bitsize
is number of inner's bits, avoid creating a BIT_FIELD_REF.
* gcc.c-torture/compile/20050210-1.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@94892 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/fold-const.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20050210-1.c | 8 |
4 files changed, 31 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b88ef126485..a8535170c44 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2005-02-11 Jakub Jelinek <jakub@redhat.com> + PR middle-end/19858 + * fold-const.c (make_bit_field_ref): If bitpos == 0 and bitsize + is number of inner's bits, avoid creating a BIT_FIELD_REF. + * config/rs6000/sysv4.h (ENDFILE_LINUX_SPEC): Use crtendS.o instead of crtend.o if -pie. Use %{x:a;:b} spec syntax. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index de54258c2a4..0d732730426 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3076,8 +3076,20 @@ static tree make_bit_field_ref (tree inner, tree type, int bitsize, int bitpos, int unsignedp) { - tree result = build3 (BIT_FIELD_REF, type, inner, - size_int (bitsize), bitsize_int (bitpos)); + tree result; + + if (bitpos == 0) + { + tree size = TYPE_SIZE (TREE_TYPE (inner)); + if ((INTEGRAL_TYPE_P (TREE_TYPE (inner)) + || POINTER_TYPE_P (TREE_TYPE (inner))) + && host_integerp (size, 0) + && tree_low_cst (size, 0) == bitsize) + return fold_convert (type, inner); + } + + result = build3 (BIT_FIELD_REF, type, inner, + size_int (bitsize), bitsize_int (bitpos)); BIT_FIELD_REF_UNSIGNED (result) = unsignedp; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1064f44346e..97a1b12b450 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-02-11 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/19858 + * gcc.c-torture/compile/20050210-1.c: New test. + 2005-02-11 Mark Mitchell <mark@codesourcery.com> PR c++/19755 diff --git a/gcc/testsuite/gcc.c-torture/compile/20050210-1.c b/gcc/testsuite/gcc.c-torture/compile/20050210-1.c new file mode 100644 index 00000000000..c9e33264035 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20050210-1.c @@ -0,0 +1,8 @@ +/* PR middle-end/19858 */ + +typedef __SIZE_TYPE__ size_t; +union U { int c; } foo; +int bar (void) +{ + return !(((size_t) &foo & 3) == 0 && !((size_t) &foo & 1)); +} |