re PR middle-end/17957 (vector type node used after garbage-collected)
authorAndrew Pinski <pinskia@physics.uc.edu>
Fri, 26 Nov 2004 03:55:10 +0000 (03:55 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 26 Nov 2004 03:55:10 +0000 (19:55 -0800)
2004-11-25  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/17957
        * testsuite/gcc.dg/pr17957.c: New test.

2004-11-25  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/17957
        * tree-complex.c (vector_inner_type): New variable moved from
        build_word_mode_vector_type.
        (vector_last_type): Likewise.
        (vector_last_nunits): Likewise.
        (build_word_mode_vector_type): Use the new variables.
        * Makefile.in (tree-complex.o): Add gt-tree-complex.h $(GGC_H).
        (GTFILES): Add tree-complex.c.
        (gt-tree-complex.h): New rule, add it to the rest of the gt-* rules.

From-SVN: r91322

gcc/ChangeLog
gcc/Makefile.in
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr17957.c [new file with mode: 0644]
gcc/tree-complex.c

index 411a636c586428fe05051a9974020fad56767d41..183fd91e1d5cbdf214ec9d73d67138932380cf42 100644 (file)
@@ -1,3 +1,15 @@
+2004-11-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/17957
+       * tree-complex.c (vector_inner_type): New variable moved from
+       build_word_mode_vector_type.
+       (vector_last_type): Likewise.
+       (vector_last_nunits): Likewise.
+       (build_word_mode_vector_type): Use the new variables.
+       * Makefile.in (tree-complex.o): Add gt-tree-complex.h $(GGC_H).
+       (GTFILES): Add tree-complex.c.
+       (gt-tree-complex.h): New rule, add it to the rest of the gt-* rules.
+
 2004-11-25  Bob Wilson  <bob.wilson@acm.org>
 
        * config/xtensa/xtensa.h (TARGET_CPU_CPP_BUILTINS): Define
index 879b0571abfd8b60940d5a29c4440efa763afa75..74d362ccc81ff0d3c207a40c09721879d14144d7 100644 (file)
@@ -1962,7 +1962,7 @@ tree-sra.o : tree-sra.c $(CONFIG_H) system.h errors.h $(TREE_H) $(RTL_H) \
 tree-complex.o : tree-complex.c $(CONFIG_H) system.h $(TREE_H) \
     $(TM_H) $(TREE_FLOW_H) $(TREE_GIMPLE_H) tree-iterator.h tree-pass.h \
     $(FLAGS_H) $(OPTABS_H) $(RTL_H) $(MACHMODE_H) $(EXPR_H) \
-    langhooks.h $(FLAGS_H) $(DIAGNOSTIC_H)
+    langhooks.h $(FLAGS_H) $(DIAGNOSTIC_H) gt-tree-complex.h $(GGC_H)
 df.o : df.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    insn-config.h $(RECOG_H) function.h $(REGS_H) alloc-pool.h hard-reg-set.h \
    $(BASIC_BLOCK_H) $(DF_H)
@@ -2420,7 +2420,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
   $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
   $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
-  $(srcdir)/tree-chrec.h \
+  $(srcdir)/tree-chrec.h $(srcdir)/tree-complex.c \
   $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
   $(srcdir)/tree-profile.c $(srcdir)/rtl-profile.c $(srcdir)/tree-nested.c \
   $(out_file) \
@@ -2439,7 +2439,7 @@ gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h gt-dojump.h \
 gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \
 gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \
 gt-c-pragma.h gtype-c.h gt-input.h gt-cfglayout.h \
-gt-tree-mudflap.h \
+gt-tree-mudflap.h gt-tree-complex.h \
 gt-tree-ssa-ccp.h gt-tree-eh.h \
 gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
 gt-tree-phinodes.h gt-tree-cfg.h gt-tree-nested.h \
index dc9628f6d61268cfc46a29c0eb5563e3b502f30a..67da0286f4cf7e6a7383c532efa955a292dd636a 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/17957
+       * testsuite/gcc.dg/pr17957.c: New test.
+
 2004-11-25  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/18445
diff --git a/gcc/testsuite/gcc.dg/pr17957.c b/gcc/testsuite/gcc.dg/pr17957.c
new file mode 100644 (file)
index 0000000..292dbb5
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "--param ggc-min-expand=0 -param ggc-min-heapsize=0" } */
+__attribute__ ((vector_size (64))) unsigned char v1, v2, v3;
+void
+vadd (void)
+{
+  v1 = v2 + v3;
+}
+void
+test_add (void)
+{
+  vadd ();
+}
+void
+vsub (void)
+{
+  v1 = v2 - v3;
+}
index bfd74bdc8002f0d22b807463c1c24a08378d79e2..4a4ba62a05bc0f9d485524e7bd69bc19fbd5cd17 100644 (file)
@@ -35,6 +35,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "tree-iterator.h"
 #include "tree-pass.h"
 #include "flags.h"
+#include "ggc.h"
 
 
 /* Extract the real or imaginary part of a complex variable or constant.
@@ -509,25 +510,30 @@ build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value)
   return ret;
 }
 
+static GTY(()) tree vector_inner_type;
+static GTY(()) tree vector_last_type;
+static GTY(()) int vector_last_nunits;
+
 /* Return a suitable vector types made of SUBPARTS units each of mode
    "word_mode" (the global variable).  */
 static tree
 build_word_mode_vector_type (int nunits)
 {
-  static tree innertype;
-  static tree last;
-  static int last_nunits;
-
-  if (!innertype)
-    innertype = lang_hooks.types.type_for_mode (word_mode, 1);
-  else if (last_nunits == nunits)
-    return last;
+  if (!vector_inner_type)
+    vector_inner_type = lang_hooks.types.type_for_mode (word_mode, 1);
+  else if (vector_last_nunits == nunits)
+    {
+      gcc_assert (TREE_CODE (vector_last_type) == VECTOR_TYPE);
+      return vector_last_type;
+    }
 
   /* We build a new type, but we canonicalize it nevertheless,
      because it still saves some memory.  */
-  last_nunits = nunits;
-  last = type_hash_canon (nunits, build_vector_type (innertype, nunits));
-  return last;
+  vector_last_nunits = nunits;
+  vector_last_type = type_hash_canon (nunits,
+                                     build_vector_type (vector_inner_type,
+                                                        nunits));
+  return vector_last_type;
 }
 
 typedef tree (*elem_op_func) (block_stmt_iterator *,
@@ -953,3 +959,5 @@ struct tree_opt_pass pass_pre_expand =
     | TODO_verify_stmts,               /* todo_flags_finish */
   0                                    /* letter */
 };
+
+#include "gt-tree-complex.h"