aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-11-10 19:41:37 +0000
committerRichard Stallman <rms@gnu.org>1993-11-10 19:41:37 +0000
commitd78d243c9c2801c8bf3acd42f2b1dc369819d98a (patch)
treec7bbebb0035aa87f5c38cbd8006f8b52ae5e863b
parentf820ace744fc98106c880d0d2c54e56e698c6f87 (diff)
downloadgcc-d78d243c9c2801c8bf3acd42f2b1dc369819d98a.zip
gcc-d78d243c9c2801c8bf3acd42f2b1dc369819d98a.tar.gz
gcc-d78d243c9c2801c8bf3acd42f2b1dc369819d98a.tar.bz2
(expand_assignment): Use a smaller alignment when storing
into a field with a variable offset. From-SVN: r6051
-rw-r--r--gcc/expr.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index fc33c84f..4d99bca 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -2347,6 +2347,7 @@ expand_assignment (to, from, want_value, suggest_reg)
int unsignedp;
int volatilep = 0;
tree tem;
+ int alignment;
push_temp_slots ();
tem = get_inner_reference (to, &bitsize, &bitpos, &offset,
@@ -2358,6 +2359,7 @@ expand_assignment (to, from, want_value, suggest_reg)
if (mode1 == VOIDmode && want_value)
tem = stabilize_reference (tem);
+ alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, 0);
if (offset != 0)
{
@@ -2368,6 +2370,14 @@ expand_assignment (to, from, want_value, suggest_reg)
to_rtx = change_address (to_rtx, VOIDmode,
gen_rtx (PLUS, Pmode, XEXP (to_rtx, 0),
force_reg (Pmode, offset_rtx)));
+ /* If we have a variable offset, the known alignment
+ is only that of the innermost structure containing the field.
+ (Actually, we could sometimes do better by using the
+ align of an element of the innermost array, but no need.) */
+ if (TREE_CODE (to) == COMPONENT_REF
+ || TREE_CODE (to) == BIT_FIELD_REF)
+ alignment
+ = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (to, 0))) / BITS_PER_UNIT;
}
if (volatilep)
{
@@ -2388,7 +2398,7 @@ expand_assignment (to, from, want_value, suggest_reg)
: VOIDmode),
unsignedp,
/* Required alignment of containing datum. */
- TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT,
+ alignment,
int_size_in_bytes (TREE_TYPE (tem)));
preserve_temp_slots (result);
free_temp_slots ();