OSDN Git Service

* gcc.dg/tree-ssa/foldconst-1.c: New testcase.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 4 Sep 2010 16:02:38 +0000 (16:02 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 4 Sep 2010 16:02:38 +0000 (16:02 +0000)
* tree-switch-conversion.c (build_one_array): Set constructor to be
static.
* varpool.c (varpool_finalize_decl): Compute const_value_known.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/foldconst-1.c [new file with mode: 0644]
gcc/tree-switch-conversion.c
gcc/varpool.c

index d0ac706..feece9e 100644 (file)
@@ -1,3 +1,9 @@
+2010-09-04  Jan Hubicka  <jh@suse.cz>
+
+       * tree-switch-conversion.c (build_one_array): Set constructor to be
+       static.
+       * varpool.c (varpool_finalize_decl): Compute const_value_known.
+
 2010-09-04  Richard Guenther  <rguenther@suse.de>
 
        PR bootstrap/45519
index 52dd4e8..9e3da03 100644 (file)
@@ -1,3 +1,7 @@
+2010-09-04  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/tree-ssa/foldconst-1.c: New testcase.
+
 2010-09-04  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/45507
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/foldconst-1.c b/gcc/testsuite/gcc.dg/tree-ssa/foldconst-1.c
new file mode 100644 (file)
index 0000000..10414a2
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+void bar (unsigned int);
+
+void
+foo (void)
+{
+  char buf[1] = { 3 };
+  const char *p = buf;
+  const char **q = &p;
+  unsigned int ch;
+  switch (**q)
+    {
+    case 1:  ch = 5; break;
+    case 2:  ch = 4; break;
+    case 3:  ch = 3; break;
+    case 4:  ch = 2; break;
+    case 5:  ch = 1; break;
+    default: ch = 0; break;
+    }
+  bar (ch);
+}
+/* The switch should be switch converted and later constant propagated.  */
+/* { dg-final { scan-tree-dump-not "CSWTCH" "optimized"} } */
+/* { dg-final { scan-tree-dump-not "switch" "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index 7072af8..05c0a65 100644 (file)
@@ -518,6 +518,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
       array_type = build_array_type (value_type, arr_index_type);
       ctor = build_constructor (array_type, info.constructors[num]);
       TREE_CONSTANT (ctor) = true;
+      TREE_STATIC (ctor) = true;
 
       decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type);
       TREE_STATIC (decl) = 1;
index eac488f..2b08094 100644 (file)
@@ -423,6 +423,7 @@ varpool_finalize_decl (tree decl)
      there.  */
   else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
     varpool_mark_needed_node (node);
+  node->const_value_known |= varpool_decide_const_value_known (node);
   if (cgraph_global_info_ready)
     varpool_assemble_pending_decls ();
 }