From c952ff4b08da49521b76581968e7ec99b2da88e7 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Fri, 16 Nov 2001 14:02:56 +0000 Subject: [PATCH] expr.c (expand_expr, [...]): Refine test for when to copy misaligned data. * expr.c (expand_expr, case ADDR_EXPR): Refine test for when to copy misaligned data. * varasm.c (assemble_variable): Set alignment into MEM when changed. From-SVN: r47089 --- gcc/ChangeLog | 6 ++++++ gcc/expr.c | 18 +++++++++++++----- gcc/varasm.c | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 04cd517d744..e7e264a369d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +Fri Nov 16 09:06:25 2001 Richard Kenner + + * expr.c (expand_expr, case ADDR_EXPR): Refine test for when to + copy misaligned data. + * varasm.c (assemble_variable): Set alignment into MEM when changed. + 2001-11-16 Graham Stott * optabs.c (prepare_cmp_insn): Correct lossage in last change fix diff --git a/gcc/expr.c b/gcc/expr.c index afc43cc223b..92397ee4064 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8649,11 +8649,19 @@ expand_expr (exp, target, tmode, modifier) return op0; } - /* If OP0 is not aligned as least as much as the type requires, - we need to make a temporary, copy OP0 to it, and take the - address of the temporary. */ - if (GET_MODE (op0) == BLKmode - && expr_align (TREE_OPERAND (exp, 0)) > MEM_ALIGN (op0)) + /* If OP0 is not aligned as least as much as the type requires, we + need to make a temporary, copy OP0 to it, and take the address of + the temporary. We want to use the alignment of the type, not of + the operand. Note that this is incorrect for FUNCTION_TYPE, but + the test for BLKmode means that can't happen. The test for + BLKmode is because we never make mis-aligned MEMs with + non-BLKmode. + + We don't need to do this at all if the machine doesn't have + strict alignment. */ + if (STRICT_ALIGNMENT && GET_MODE (op0) == BLKmode + && (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0))) + > MEM_ALIGN (op0))) { tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); rtx new diff --git a/gcc/varasm.c b/gcc/varasm.c index cb1cd16ff43..697276234b0 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1615,6 +1615,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data) /* Reset the alignment in case we have made it tighter, so we can benefit from it in get_pointer_alignment. */ DECL_ALIGN (decl) = align; + set_mem_align (decl_rtl, align); /* Handle uninitialized definitions. */