This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use sufficient alignment when expanding VCE (PR target/35366)


This is another patch for PR35366, either of the patches fixes the failure,
but IMHO we want both.  If for whatever reason VIEW_CONVERT_EXPR <double, STRING_CST>
(or some other VCE) isn't folded, and the TREE_TYPE of the VCE needs bigger
alignment than the inner operand, the inner constant is emitted with a small
alignment, but it is actually accessed as if the alignment was big enough
for the outer type.  The following patch makes sure an inner constant
is sufficiently aligned.

Ok for trunk?

2008-11-11  Jakub Jelinek  <>

	PR target/35366
	* expr.c (expand_expr_addr_expr_1): If EXP needs bigger alignment
	than INNER and INNER is a constant, forcibly align INNER as much
	as needed.

--- gcc/expr.c.jj	2008-10-29 23:16:25.000000000 +0100
+++ gcc/expr.c	2008-11-11 14:24:56.000000000 +0100
@@ -6862,6 +6862,16 @@ expand_expr_addr_expr_1 (tree exp, rtx t
   gcc_assert (inner != exp);
   subtarget = offset || bitpos ? NULL_RTX : target;
+  /* For VIEW_CONVERT_EXPR, where the outer alignment is bigger than
+     inner alignment, force the inner to be sufficiently aligned.  */
+  if (CONSTANT_CLASS_P (inner)
+      && TYPE_ALIGN (TREE_TYPE (inner)) < TYPE_ALIGN (TREE_TYPE (exp)))
+    {
+      inner = copy_node (inner);
+      TREE_TYPE (inner) = copy_node (TREE_TYPE (inner));
+      TYPE_ALIGN (TREE_TYPE (inner)) = TYPE_ALIGN (TREE_TYPE (exp));
+      TYPE_USER_ALIGN (TREE_TYPE (inner)) = 1;
+    }
   result = expand_expr_addr_expr_1 (inner, subtarget, tmode, modifier);
   if (offset)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]