+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
+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.
--- /dev/null
+! { 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
+
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)
{
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;
}
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;
}
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)