From 3ae61172cd20dc57e056145d719633b9799e229d Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 2 Jul 2009 15:16:08 +0000 Subject: [PATCH] * gcc.dg/tree-ssa/local-pure-const.c: New testcase. * 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 | 5 +++++ gcc/ipa-pure-const.c | 12 +++++++++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d57902b386d..41642b5417b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-07-02 Jan Hubicka + + * ipa-pure-const.c (check_op): Use PTA info to see if indirect_ref is + local. + 2009-07-02 Paolo Bonzini * expmed.c (emit_cstore, emit_store_flag_1): Accept target_mode diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 8faa00c3b0e..ba4782bc5f3 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6eea718e7c8..acd53b023ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-07-02 Jan Hubicka + + * gcc.dg/tree-ssa/local-pure-const.c: New testcase. + 2009-07-01 Adam Nemet * 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 index 00000000000..2c7353dbdbc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c @@ -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" } } */ -- 2.11.0