public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Use sufficient alignment when expanding VCE (PR 	target/35366)
Date: Tue, 11 Nov 2008 13:48:00 -0000	[thread overview]
Message-ID: <20081111133012.GA3572@tyan-ft48-01.lab.bos.redhat.com> (raw)

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

             reply	other threads:[~2008-11-11 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-11 13:48 Jakub Jelinek [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081111133012.GA3572@tyan-ft48-01.lab.bos.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).