aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa-pure-const.c12
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/local-pure-const.c14
4 files changed, 34 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d57902b..41642b5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 8faa00c..ba4782b 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 6eea718..acd53b0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..2c7353d
--- /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" } } */