This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR39643
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Apr 2009 16:13:47 +0200 (CEST)
- Subject: [PATCH] Fix PR39643
This fixes PR39643, a fallout from a-i merge on !TARGET_C99_FUNCTIONS
targets wrt constant folding of sincos and following constant comparisons.
The issue is that we no loger promote memory to registers after
fold-all-builtins. The following re-instantiates this and also makes
sure we only need 2 CCP passes to catch all optimizations on
TARGET_C99_FUNCTIONS targets.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2009-04-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/39643
* tree-ssa-ccp.c (ccp_fold): Fold REALPART_EXPRs and
IMAGPART_EXPRs of complex constants.
(execute_fold_all_builtins): If we folded a call queue
TODO_update_address_taken.
Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc/tree-ssa-ccp.c.orig 2009-04-06 14:58:31.000000000 +0200
--- gcc/tree-ssa-ccp.c 2009-04-06 15:28:38.000000000 +0200
*************** ccp_fold (gimple stmt)
*** 949,960 ****
if (kind == tcc_reference)
{
! if (TREE_CODE (rhs) == VIEW_CONVERT_EXPR
&& TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME)
{
prop_value_t *val = get_value (TREE_OPERAND (rhs, 0));
if (val->lattice_val == CONSTANT)
! return fold_unary (VIEW_CONVERT_EXPR,
TREE_TYPE (rhs), val->value);
}
else if (TREE_CODE (rhs) == INDIRECT_REF
--- 949,962 ----
if (kind == tcc_reference)
{
! if ((TREE_CODE (rhs) == VIEW_CONVERT_EXPR
! || TREE_CODE (rhs) == REALPART_EXPR
! || TREE_CODE (rhs) == IMAGPART_EXPR)
&& TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME)
{
prop_value_t *val = get_value (TREE_OPERAND (rhs, 0));
if (val->lattice_val == CONSTANT)
! return fold_unary (TREE_CODE (rhs),
TREE_TYPE (rhs), val->value);
}
else if (TREE_CODE (rhs) == INDIRECT_REF
*************** execute_fold_all_builtins (void)
*** 3270,3276 ****
push_stmt_changes (gsi_stmt_ptr (&i));
if (!update_call_from_tree (&i, result))
! gimplify_and_update_call_from_tree (&i, result);
stmt = gsi_stmt (i);
pop_stmt_changes (gsi_stmt_ptr (&i));
--- 3272,3281 ----
push_stmt_changes (gsi_stmt_ptr (&i));
if (!update_call_from_tree (&i, result))
! {
! gimplify_and_update_call_from_tree (&i, result);
! todoflags |= TODO_update_address_taken;
! }
stmt = gsi_stmt (i);
pop_stmt_changes (gsi_stmt_ptr (&i));