OSDN Git Service

PR debug/43516
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 14:23:35 +0000 (14:23 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 14:23:35 +0000 (14:23 +0000)
* tree.c (MAX_INT_CACHED_PREC): Define.
(nonstandard_integer_type_cache): New array.
(build_nonstandard_integer_type): Cache results for precision
<= MAX_INT_CACHED_PREC.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158062 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree.c

index af2e371..0840425 100644 (file)
@@ -1,3 +1,11 @@
+2010-04-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43516
+       * tree.c (MAX_INT_CACHED_PREC): Define.
+       (nonstandard_integer_type_cache): New array.
+       (build_nonstandard_integer_type): Cache results for precision
+       <= MAX_INT_CACHED_PREC.
+
 2010-04-07  Richard Guenther  <rguenther@suse.de>
 
        * doc/invoke.texi (-fargument-alias, -fargument-noalias,
index b72e057..30bc5be 100644 (file)
@@ -1,6 +1,6 @@
 /* Language-independent node constructors for parse phase of GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -6876,6 +6876,10 @@ build_index_type (tree maxval)
     }
 }
 
+#define MAX_INT_CACHED_PREC \
+  (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
+static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2];
+
 /* Builds a signed or unsigned integer type of precision PRECISION.
    Used for C bitfields whose precision does not match that of
    built-in target types.  */
@@ -6883,8 +6887,19 @@ tree
 build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
                                int unsignedp)
 {
-  tree itype = make_node (INTEGER_TYPE);
+  tree itype, ret;
 
+  if (unsignedp)
+    unsignedp = MAX_INT_CACHED_PREC + 1;
+    
+  if (precision <= MAX_INT_CACHED_PREC)
+    {
+      itype = nonstandard_integer_type_cache[precision + unsignedp];
+      if (itype)
+       return itype;
+    }
+
+  itype = make_node (INTEGER_TYPE);
   TYPE_PRECISION (itype) = precision;
 
   if (unsignedp)
@@ -6892,10 +6907,13 @@ build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
   else
     fixup_signed_type (itype);
 
+  ret = itype;
   if (host_integerp (TYPE_MAX_VALUE (itype), 1))
-    return type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype);
+    ret = type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype);
+  if (precision <= MAX_INT_CACHED_PREC && lang_hooks.types.hash_types)
+    nonstandard_integer_type_cache[precision + unsignedp] = ret;
 
-  return itype;
+  return ret;
 }
 
 /* Create a range of some discrete type TYPE (an INTEGER_TYPE,