expr.c (expand_expr, [...]): Refine test for when to copy misaligned data.
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Fri, 16 Nov 2001 14:02:56 +0000 (14:02 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 16 Nov 2001 14:02:56 +0000 (09:02 -0500)
* 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
gcc/expr.c
gcc/varasm.c

index 04cd517d7443c95cf908872b4dda640fdeeee490..e7e264a369d667d3b377894ab439dd52a75ccc22 100644 (file)
@@ -1,3 +1,9 @@
+Fri Nov 16 09:06:25 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+       * 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  <grahams@redhat.com>
 
        * optabs.c (prepare_cmp_insn): Correct lossage in last change fix
index afc43cc223b7b8c4a3c2cc651c49c5bec01a0c0a..92397ee4064a5247551607f5c375c9adaf28694e 100644 (file)
@@ -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
index cb1cd16ff432e56fbba8d1b4d4de6ee003aac5ba..697276234b04aa8c58e39df7daa6a85545158770 100644 (file)
@@ -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.  */