OSDN Git Service

PR tree-optimization/52318
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Feb 2012 09:24:42 +0000 (09:24 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Feb 2012 09:24:42 +0000 (09:24 +0000)
* gimple-fold.c (gimplify_and_update_call_from_tree): Add
vdef also to non-pure/const call stmts in the sequence.

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

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

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr52318.c [new file with mode: 0644]

index df2419a..ea84649 100644 (file)
@@ -1,3 +1,9 @@
+2012-02-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/52318
+       * gimple-fold.c (gimplify_and_update_call_from_tree): Add
+       vdef also to non-pure/const call stmts in the sequence.
+
 2012-02-20  David S. Miller  <davem@davemloft.net>
 
        * config/sparc/sparc.md (load_pcrel_sym<P:mode>): Explain why we
index 935bbda..eae4cbe 100644 (file)
@@ -1,5 +1,5 @@
 /* Statement simplification on GIMPLE.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
    Split out from tree-ssa-ccp.c.
 
 This file is part of GCC.
@@ -591,8 +591,11 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
   for (i = gsi_last (stmts); !gsi_end_p (i); gsi_prev (&i))
     {
       new_stmt = gsi_stmt (i);
-      if (gimple_assign_single_p (new_stmt)
-         && !is_gimple_reg (gimple_assign_lhs (new_stmt)))
+      if ((gimple_assign_single_p (new_stmt)
+          && !is_gimple_reg (gimple_assign_lhs (new_stmt)))
+         || (is_gimple_call (new_stmt)
+             && (gimple_call_flags (new_stmt)
+                 & (ECF_NOVOPS | ECF_PURE | ECF_CONST | ECF_NORETURN)) == 0))
        {
          tree vdef;
          if (!laststore)
index df818af..2bbb672 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/52318
+       * gcc.dg/pr52318.c: New test.
+
 2012-02-20  Kai Tietz  <ktietz@redhat.com>
 
        * gcc.dg/bf-ms-layout-3.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/pr52318.c b/gcc/testsuite/gcc.dg/pr52318.c
new file mode 100644 (file)
index 0000000..4f367aa
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR tree-optimization/52318 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftracer -fno-tree-ccp -fno-tree-copy-prop -fno-tree-dce" } */
+
+int c;
+char *p;
+
+void
+foo (int i)
+{
+  char a[2];
+  char b[20];
+  p = __builtin___stpcpy_chk (a, "", 2);
+  p = __builtin___stpcpy_chk (&b[16], i ? "e" : "jkl", 4);
+  if (c)
+    foo (i);
+}