aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-02-11 22:08:44 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2005-02-11 22:08:44 +0100
commit97e9692bfbd5d43f26bc7938336affe1f5fddaaa (patch)
tree7fae11a3fb3ae2fe3eb5779237227483c916e792 /gcc/fold-const.c
parent28f8ecf9120fefbc4b046b256c0731a270dc6c7b (diff)
downloadgcc-97e9692bfbd5d43f26bc7938336affe1f5fddaaa.zip
gcc-97e9692bfbd5d43f26bc7938336affe1f5fddaaa.tar.gz
gcc-97e9692bfbd5d43f26bc7938336affe1f5fddaaa.tar.bz2
re PR middle-end/19858 (ICE on simple SSE code)
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. From-SVN: r94892
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index de54258..0d73273 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;