summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1992-08-03 01:31:25 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1992-08-03 01:31:25 +0000
commit66716a9769f073b8a6e811695dfec03ba97fdc4b (patch)
tree6f6771c8e9b20882f8b6b6a5cf79a72a5486a6de /gcc
parent23415bc73f11e681f2876098831a8065d2fd2ffa (diff)
downloadgcc-66716a9769f073b8a6e811695dfec03ba97fdc4b.tar.gz
(optimize_bit_field_compare): Correct bogus use of types in
expressions; always do computation in a type wide enough for the result. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@1743 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fold-const.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index ed3f7ddba38..207c75a8e17 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2178,13 +2178,13 @@ optimize_bit_field_compare (code, compare_type, lhs, rhs)
/* If not comparing with constant, just rework the comparison
and return. */
return build (code, compare_type,
- build (BIT_AND_EXPR, type,
- make_bit_field_ref (linner, type,
- lnbitsize, lnbitpos, lunsignedp),
+ build (BIT_AND_EXPR, unsigned_type,
+ make_bit_field_ref (linner, unsigned_type,
+ lnbitsize, lnbitpos, 1),
mask),
- build (BIT_AND_EXPR, type,
- make_bit_field_ref (rinner, type,
- rnbitsize, rnbitpos, runsignedp),
+ build (BIT_AND_EXPR, unsigned_type,
+ make_bit_field_ref (rinner, unsigned_type,
+ rnbitsize, rnbitpos, 1),
mask));
/* Otherwise, we are handling the constant case. See if the constant is too
@@ -2233,17 +2233,16 @@ optimize_bit_field_compare (code, compare_type, lhs, rhs)
/* Make a new bitfield reference, shift the constant over the
appropriate number of bits and mask it with the computed mask
(in case this was a signed field). If we changed it, make a new one. */
- lhs = make_bit_field_ref (linner, TREE_TYPE (lhs), lnbitsize, lnbitpos,
- lunsignedp);
+ lhs = make_bit_field_ref (linner, unsigned_type, lnbitsize, lnbitpos, 1);
- rhs = fold (build1 (NOP_EXPR, type,
- const_binop (BIT_AND_EXPR,
- const_binop (LSHIFT_EXPR,
- convert (unsigned_type, rhs),
- size_int (lbitpos)), mask)));
+ rhs = fold (const_binop (BIT_AND_EXPR,
+ const_binop (LSHIFT_EXPR,
+ convert (unsigned_type, rhs),
+ size_int (lbitpos)),
+ mask));
return build (code, compare_type,
- build (BIT_AND_EXPR, type, lhs, mask),
+ build (BIT_AND_EXPR, unsigned_type, lhs, mask),
rhs);
}