public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use sufficient alignment when expanding VCE (PR  target/35366)
@ 2008-11-11 13:48 Jakub Jelinek
  2008-11-11 15:42 ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2008-11-11 13:48 UTC (permalink / raw)
  To: gcc-patches

Hi!

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  <jakub@redhat.com>

	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)

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-12  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-11 13:48 [PATCH] Use sufficient alignment when expanding VCE (PR target/35366) Jakub Jelinek
2008-11-11 15:42 ` Richard Guenther
2008-11-11 18:54   ` Jakub Jelinek
2008-11-11 19:53     ` Richard Guenther
2008-11-12  3:29   ` Geert Bosch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).