summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-07 17:02:43 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-07 17:02:43 +0000
commitcc8f004218833cb71ffab940477815cae33d7d28 (patch)
treec12c6c473ae4311d839b3b503f10c0d0d6515be6
parentc30d5c8703e14d380b8df9a76824e50c53573ffa (diff)
downloadppe42-gcc-cc8f004218833cb71ffab940477815cae33d7d28.tar.gz
ppe42-gcc-cc8f004218833cb71ffab940477815cae33d7d28.zip
2009-08-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40999 * tree-ssa-ccp.c (get_symbol_constant_value): Handle CONST_DECLs. (maybe_fold_reference): Lookup constant initializers. (fold_gimple_assign): Likewise. * gfortran.dg/pr40999.f: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150572 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr40999.f11
-rw-r--r--gcc/tree-ssa-ccp.c25
4 files changed, 46 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b9304a156bc..3a43fe3dd8e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2009-08-07 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/40999
+ * tree-ssa-ccp.c (get_symbol_constant_value): Handle CONST_DECLs.
+ (maybe_fold_reference): Lookup constant initializers.
+ (fold_gimple_assign): Likewise.
+
+2009-08-07 Richard Guenther <rguenther@suse.de>
+
* tree-ssa.c (useless_type_conversion_p_1): Only for types
that require structural equality defer to the langhook.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4d3f9b0077a..cbaf780b5f8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-08-07 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/40999
+ * gfortran.dg/pr40999.f: New testcase.
+
2009-08-07 Jakub Jelinek <jakub@redhat.com>
* g++.dg/tree-prof/partition1.C: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr40999.f b/gcc/testsuite/gfortran.dg/pr40999.f
new file mode 100644
index 00000000000..0d93069c592
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr40999.f
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-O3 -fwhole-file" }
+
+ SUBROUTINE ZLARFG( ALPHA )
+ ALPHA = ZLADIV( DCMPLX( 1.0D+0 ) )
+ END
+ COMPLEX*16 FUNCTION ZLADIV( X )
+ COMPLEX*16 X
+ CALL DLADIV( DBLE( X ), DIMAG( X ) )
+ END
+
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index c507f4572e6..f39d272964b 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -276,7 +276,8 @@ tree
get_symbol_constant_value (tree sym)
{
if (TREE_STATIC (sym)
- && TREE_READONLY (sym))
+ && (TREE_READONLY (sym)
+ || TREE_CODE (sym) == CONST_DECL))
{
tree val = DECL_INITIAL (sym);
if (val)
@@ -288,7 +289,11 @@ get_symbol_constant_value (tree sym)
{
tree base = get_base_address (TREE_OPERAND (val, 0));
if (base && TREE_CODE (base) == VAR_DECL)
- add_referenced_var (base);
+ {
+ TREE_ADDRESSABLE (base) = 1;
+ if (gimple_referenced_vars (cfun))
+ add_referenced_var (base);
+ }
}
return val;
}
@@ -2337,6 +2342,19 @@ maybe_fold_reference (tree expr, bool is_lhs)
return expr;
}
}
+ else if (!is_lhs
+ && DECL_P (*t))
+ {
+ tree tem = get_symbol_constant_value (*t);
+ if (tem)
+ {
+ *t = tem;
+ tem = maybe_fold_reference (expr, is_lhs);
+ if (tem)
+ return tem;
+ return expr;
+ }
+ }
return NULL_TREE;
}
@@ -2739,6 +2757,9 @@ fold_gimple_assign (gimple_stmt_iterator *si)
CONSTRUCTOR_ELTS (rhs));
}
+ else if (DECL_P (rhs))
+ return get_symbol_constant_value (rhs);
+
/* If we couldn't fold the RHS, hand over to the generic
fold routines. */
if (result == NULL_TREE)
OpenPOWER on IntegriCloud