aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2005-01-27 00:07:41 +0000
committerRichard Henderson <rth@redhat.com>2005-01-27 00:07:41 +0000
commit6debf6cdeca9e57bb12109dedd2ed7f2971115ab (patch)
treef3474ccdfed8911f1cf4ff4e40df78bca88922f7
parenta0767bcf261eec8e609e10fc10617ea3526d30e6 (diff)
For real this time...
PR middle-end/18008 * c-decl.c (finish_struct): Set DECL_MODE after resetting a field's type. * expr.c (store_field): Strip conversions to odd-bit-sized types if the destination field width matches. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@94294 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-decl.c7
-rw-r--r--gcc/expr.c16
3 files changed, 28 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 288527460ae..3f158552670 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2005-01-26 Richard Henderson <rth@redhat.com>
+ PR middle-end/18008
+ * c-decl.c (finish_struct): Set DECL_MODE after resetting a
+ field's type.
+ * expr.c (store_field): Strip conversions to odd-bit-sized types
+ if the destination field width matches.
+
+2005-01-26 Richard Henderson <rth@redhat.com>
+
* c-decl.c, expmed.c, expr.c: Revert last change.
2005-01-26 Richard Henderson <rth@redhat.com>
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 6673927eab6..61521e861c7 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5301,8 +5301,11 @@ finish_struct (tree t, tree fieldlist, tree attributes)
= tree_low_cst (DECL_INITIAL (*fieldlistp), 1);
tree type = TREE_TYPE (*fieldlistp);
if (width != TYPE_PRECISION (type))
- TREE_TYPE (*fieldlistp)
- = build_nonstandard_integer_type (width, TYPE_UNSIGNED (type));
+ {
+ TREE_TYPE (*fieldlistp)
+ = build_nonstandard_integer_type (width, TYPE_UNSIGNED (type));
+ DECL_MODE (*fieldlistp) = TYPE_MODE (TREE_TYPE (*fieldlistp));
+ }
DECL_INITIAL (*fieldlistp) = 0;
}
else
diff --git a/gcc/expr.c b/gcc/expr.c
index ed693a3166f..1f82b1d9834 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5215,7 +5215,21 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos,
&& TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST
&& compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0))
{
- rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
+ rtx temp;
+
+ /* If EXP is a NOP_EXPR of precision less than its mode, then that
+ implies a mask operation. If the precision is the same size as
+ the field we're storing into, that mask is redundant. This is
+ particularly common with bit field assignments generated by the
+ C front end. */
+ if (TREE_CODE (exp) == NOP_EXPR
+ && INTEGRAL_TYPE_P (TREE_TYPE (exp))
+ && (TYPE_PRECISION (TREE_TYPE (exp))
+ < GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp))))
+ && bitsize == TYPE_PRECISION (TREE_TYPE (exp)))
+ exp = TREE_OPERAND (exp, 0);
+
+ temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
/* If BITSIZE is narrower than the size of the type of EXP
we will be narrowing TEMP. Normally, what's wanted are the