OSDN Git Service

* gcc.dg/tree-ssa/local-pure-const.c: New testcase.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Jul 2009 15:16:08 +0000 (15:16 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Jul 2009 15:16:08 +0000 (15:16 +0000)
* ipa-pure-const.c (check_op): Use PTA info to see if indirect_ref is
local.

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

gcc/ChangeLog
gcc/ipa-pure-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c [new file with mode: 0644]

index d57902b..41642b5 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-02  Jan Hubicka  <jh@suse.cz>
+
+       * ipa-pure-const.c (check_op): Use PTA info to see if indirect_ref is
+       local.
+
 2009-07-02  Paolo Bonzini  <bonzini@gnu.org>
 
        * expmed.c (emit_cstore, emit_store_flag_1): Accept target_mode
index 8faa00c..ba4782b 100644 (file)
@@ -213,13 +213,23 @@ check_decl (funct_state local,
 static inline void 
 check_op (funct_state local, tree t, bool checking_write)
 {
-  if (TREE_THIS_VOLATILE (t))
+  t = get_base_address (t);
+  if (t && TREE_THIS_VOLATILE (t))
     {
       local->pure_const_state = IPA_NEITHER;
       if (dump_file)
        fprintf (dump_file, "    Volatile indirect ref is not const/pure\n");
       return;
     }
+  else if (t
+          && INDIRECT_REF_P (t)
+          && TREE_CODE (TREE_OPERAND (t, 0)) == SSA_NAME
+          && !ptr_deref_may_alias_global_p (TREE_OPERAND (t, 0)))
+    {
+      if (dump_file)
+       fprintf (dump_file, "    Indirect ref to local memory is OK\n");
+      return;
+    }
   else if (checking_write)
     {
       local->pure_const_state = IPA_NEITHER;
index 6eea718..acd53b0 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-02  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/tree-ssa/local-pure-const.c: New testcase.
+
 2009-07-01  Adam Nemet  <anemet@caviumnetworks.com>
 
        * gcc.target/mips/truncate-4.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c b/gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c
new file mode 100644 (file)
index 0000000..2c7353d
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-local-pure-const1" } */
+t(int a, int b, int c)
+{
+  int *p;
+  if (a)
+    p = &a;
+  else
+    p = &c;
+  return *p;
+}
+/* { dg-final { scan-tree-dump-times "local memory is OK" 1 "local-pure-const1"} } */
+/* { dg-final { scan-tree-dump-times "found to be const" 1 "local-pure-const1"} } */
+/* { dg-final { cleanup-tree-dump "local-pure-const1" } } */