OSDN Git Service

PR tree-optimization/37353
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Sep 2008 08:00:40 +0000 (08:00 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Sep 2008 08:00:40 +0000 (08:00 +0000)
* tree-call-cdce.c (cond_dead_built_in_calls): Remove.
(shrink_wrap_conditional_dead_built_in_calls): Add calls argument, use
calls instead of cond_dead_built_in_calls.
(tree_call_cdce): Add cond_dead_built_in_calls automatic variable,
initalize the vector only before adding first entry.  Use VEC_safe_push
instead of VEC_quick_push.  Pass cond_dead_built_in_calls to
shrink_wrap_conditional_dead_built_in_calls call.

* gcc.dg/pr37353.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr37353.c [new file with mode: 0644]
gcc/tree-call-cdce.c

index 93421f7..8c231a2 100644 (file)
@@ -1,3 +1,14 @@
+2008-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/37353
+       * tree-call-cdce.c (cond_dead_built_in_calls): Remove.
+       (shrink_wrap_conditional_dead_built_in_calls): Add calls argument, use
+       calls instead of cond_dead_built_in_calls.
+       (tree_call_cdce): Add cond_dead_built_in_calls automatic variable,
+       initalize the vector only before adding first entry.  Use VEC_safe_push
+       instead of VEC_quick_push.  Pass cond_dead_built_in_calls to
+       shrink_wrap_conditional_dead_built_in_calls call.
+
 2008-09-10  Ira Rosen  <irar@il.ibm.com>
 
        PR tree-optimization/37385
index b9e4442..51332f3 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/37353
+       * gcc.dg/pr37353.c: New test.
+
 2008-09-10  Martin Michlmayr <tbm@cyrius.com>
            Ira Rosen  <irar@il.ibm.com>
 
diff --git a/gcc/testsuite/gcc.dg/pr37353.c b/gcc/testsuite/gcc.dg/pr37353.c
new file mode 100644 (file)
index 0000000..07d73d0
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR tree-optimization/37353 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern double exp (double);
+
+#define A exp (arg);
+#define B A A A A A A A A A A
+#define C B B B B B B B B B B
+
+void
+foo (double arg)
+{
+  C
+}
index f59f083..da66138 100644 (file)
@@ -99,8 +99,6 @@ typedef struct input_domain
   bool is_ub_inclusive;
 } inp_domain;
 
-static VEC (gimple, heap) *cond_dead_built_in_calls;
-
 /* A helper function to construct and return an input
    domain object.  LB is the lower bound, HAS_LB is 
    a boolean flag indicating if the lower bound exists,
@@ -844,18 +842,18 @@ shrink_wrap_one_built_in_call (gimple bi_call)
    wrapping transformation.  */
 
 static bool
-shrink_wrap_conditional_dead_built_in_calls (void)
+shrink_wrap_conditional_dead_built_in_calls (VEC (gimple, heap) *calls)
 {
   bool changed = false;
   unsigned i = 0;
 
-  unsigned n = VEC_length (gimple, cond_dead_built_in_calls);
+  unsigned n = VEC_length (gimple, calls);
   if (n == 0) 
     return false;
 
   for (; i < n ; i++)
     {
-      gimple bi_call = VEC_index (gimple, cond_dead_built_in_calls, i);
+      gimple bi_call = VEC_index (gimple, calls, i);
       changed |= shrink_wrap_one_built_in_call (bi_call);
     }
 
@@ -870,8 +868,7 @@ tree_call_cdce (void)
   basic_block bb;
   gimple_stmt_iterator i;
   bool something_changed = false;
-  cond_dead_built_in_calls = VEC_alloc (gimple, heap, 64);
-
+  VEC (gimple, heap) *cond_dead_built_in_calls = NULL;
   FOR_EACH_BB (bb)
     {
       /* Collect dead call candidates.  */
@@ -887,12 +884,18 @@ tree_call_cdce (void)
                   print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
                   fprintf (dump_file, "\n");
                 }
-              VEC_quick_push (gimple, cond_dead_built_in_calls, stmt);
+             if (cond_dead_built_in_calls == NULL)
+               cond_dead_built_in_calls = VEC_alloc (gimple, heap, 64);
+             VEC_safe_push (gimple, heap, cond_dead_built_in_calls, stmt);
             }
        }
     }
 
-  something_changed = shrink_wrap_conditional_dead_built_in_calls ();
+  if (cond_dead_built_in_calls == NULL)
+    return 0;
+
+  something_changed
+    = shrink_wrap_conditional_dead_built_in_calls (cond_dead_built_in_calls);
 
   VEC_free (gimple, heap, cond_dead_built_in_calls);