public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Rafael Espindola" <espindola@google.com>
To: "Richard Guenther" <richard.guenther@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	        "Diego Novillo" <dnovillo@google.com>
Subject: Re: [lto][patch] remove local variables from types (after gimplification)
Date: Tue, 24 Jun 2008 20:38:00 -0000	[thread overview]
Message-ID: <38a0d8450806241326w5f03bf3bo4c6e16eff91f675f@mail.gmail.com> (raw)
In-Reply-To: <84fc9c000806240617me7aa397n2afde424583222ce@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]

> While we in most places check for NULL TYPE_MIN/MAX_VALUE we
> should not need to - so I'd like you to adjust it instead of NULLing it.

OK. I think I got it right. Can you take a look at the attached patch?
It would probably be cleaner to split
set_min_and_max_values_for_integral_type, but I would like to reduce
the difference from branch to trunk.

Just calling set_min_and_max_values_for_integral_type unconditionally
doesn't work because set_sizetype tries to be smart and copies the
type cache from type A to type B and when we try to build a constant
for type B, build_int_cst_wide aborts.

2008-06-24  Rafael Espindola  <espindola@google.com>

	* calls.c (must_pass_in_stack_var_size_or_pad): Don't check if
	TYPE_SIZE is NULL.
	* expr.c (store_field): Don't check if TYPE_SIZE is NULL.
	* tree.c (reset_type_lang_specific): Set both TYPE_SIZE_UNIT
	and TYPE_SIZE or none of them. Don't set TYPE_MAX_VALUE to
	NULL. call set_min_and_max_values_for_integral_type.

> Richard.
>

Cheers,
-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

[-- Attachment #2: types.patch --]
[-- Type: application/octet-stream, Size: 2444 bytes --]

diff --git a/gcc/calls.c b/gcc/calls.c
index 022bdaf..e7799f0 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -4301,13 +4301,11 @@ must_pass_in_stack_var_size (enum machine_mode mode ATTRIBUTE_UNUSED,
 bool
 must_pass_in_stack_var_size_or_pad (enum machine_mode mode, const_tree type)
 {
-  tree size;
   if (!type)
     return false;
 
-  size = TYPE_SIZE (type);
   /* If the type has variable size...  */
-  if (!size || TREE_CODE (size) != INTEGER_CST)
+  if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
     return true;
 
   /* If the type is marked as addressable (it is required
diff --git a/gcc/expr.c b/gcc/expr.c
index 6898530..e2693d8 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5752,7 +5752,6 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos,
 	 RHS isn't the same size as the bitfield, we must use bitfield
 	 operations.  */
       || (bitsize >= 0
-	  && TYPE_SIZE (TREE_TYPE (exp))
 	  && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST
 	  && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0))
     {
diff --git a/gcc/tree.c b/gcc/tree.c
index 79bff67..f69c593 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3789,18 +3789,29 @@ reset_type_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
       tree unit_size = TYPE_SIZE_UNIT (decl);
       tree size = TYPE_SIZE (decl);
 
-      if (unit_size && TREE_CODE (unit_size) != INTEGER_CST)
-	TYPE_SIZE_UNIT (decl) = NULL_TREE;
-
-      if (size && TREE_CODE (size) != INTEGER_CST)
-	TYPE_SIZE (decl) = NULL_TREE;
+      if ((unit_size && TREE_CODE (unit_size) != INTEGER_CST)
+	  || (size && TREE_CODE (size) != INTEGER_CST))
+	{
+	  TYPE_SIZE_UNIT (decl) = NULL_TREE;
+	  TYPE_SIZE (decl) = NULL_TREE;
+	}
     }
 
   if (TREE_CODE (decl) == INTEGER_TYPE)
     {
-      tree max = TYPE_MAX_VALUE (decl);
-      if (max && TREE_CODE (max) != INTEGER_CST)
-	TYPE_MAX_VALUE (decl) = NULL_TREE;
+      tree old_max = TYPE_MAX_VALUE (decl);
+      tree old_min = TYPE_MIN_VALUE (decl);
+
+      if ((old_max && TREE_CODE (old_max) != INTEGER_CST)
+	  || (old_min && TREE_CODE (old_min) != INTEGER_CST))
+	  set_min_and_max_values_for_integral_type (decl,
+						    TYPE_PRECISION (decl),
+				 		    TYPE_UNSIGNED (decl));
+
+      if (old_max && TREE_CODE (old_max) == INTEGER_CST)
+	TYPE_MAX_VALUE (decl) = old_max;
+      if (old_min && TREE_CODE (old_min) == INTEGER_CST)
+	TYPE_MIN_VALUE (decl) = old_min;
     }
 
   return 1;

  reply	other threads:[~2008-06-24 20:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-23 14:48 Rafael Espindola
2008-06-23 15:27 ` Diego Novillo
2008-06-24  9:32 ` Richard Guenther
2008-06-24 13:18   ` Rafael Espindola
2008-06-24 13:44     ` Richard Guenther
2008-06-24 20:38       ` Rafael Espindola [this message]
2008-06-24 20:44         ` Richard Guenther
2008-06-24 20:49           ` Rafael Espindola
2008-06-24 20:56             ` Richard Guenther
2008-06-25 21:13         ` Bill Maddox
2008-06-25 21:19           ` Rafael Espindola
2008-06-25 21:39             ` Richard Guenther
2008-06-25 23:33             ` Bill Maddox
2008-06-26  9:53               ` Richard Guenther
2008-06-26 14:53                 ` Rafael Espindola
2008-06-26 15:13                   ` Richard Guenther
2008-06-26 16:14               ` Rafael Espindola
2008-06-26 17:48                 ` Diego Novillo
2008-06-26 18:36                   ` Rafael Espindola
2008-06-26 14:26             ` Rafael Espindola
2008-06-26 18:14               ` Rafael Espindola
2008-07-02 20:58 ` Bill Maddox

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=38a0d8450806241326w5f03bf3bo4c6e16eff91f675f@mail.gmail.com \
    --to=espindola@google.com \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /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).