This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR38723, missing default defs in AVAIL_OUT
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Mar 2009 17:57:17 +0100 (CET)
- Subject: [PATCH] Fix PR38723, missing default defs in AVAIL_OUT
This is another tiny merge from alias-improvements branch. We do not
optimize the testcase because the parameter is not in AVAIL_OUT of
the entry BB. The following patch fixes this by putting all default
defs into AVAIL_OUT of the entry block.
Bootstrapped on x86_64-unknown-linux-gnu, regtest in progress, I'll
commit if that succeeds.
Thanks,
Richard.
2009-01-04 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38723
* tree-ssa-pre.c (compute_avail): Add all default definitions to
the entry block.
* gcc.dg/tree-ssa/ssa-fre-22.c: New testcase.
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c.orig 2009-03-28 16:59:34.000000000 +0100
--- gcc/tree-ssa-pre.c 2009-03-28 17:55:38.000000000 +0100
*************** compute_avail (void)
*** 3564,3609 ****
basic_block block, son;
basic_block *worklist;
size_t sp = 0;
! tree param;
! /* For arguments with default definitions, we pretend they are
! defined in the entry block. */
! for (param = DECL_ARGUMENTS (current_function_decl);
! param;
! param = TREE_CHAIN (param))
! {
! if (gimple_default_def (cfun, param) != NULL)
! {
! tree def = gimple_default_def (cfun, param);
! pre_expr e = get_or_alloc_expr_for_name (def);
!
! add_to_value (get_expr_value_id (e), e);
! if (!in_fre)
! {
! bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), e);
! bitmap_value_insert_into_set (maximal_set, e);
! }
! bitmap_value_insert_into_set (AVAIL_OUT (ENTRY_BLOCK_PTR), e);
! }
! }
!
! /* Likewise for the static chain decl. */
! if (cfun->static_chain_decl)
! {
! param = cfun->static_chain_decl;
! if (gimple_default_def (cfun, param) != NULL)
{
! tree def = gimple_default_def (cfun, param);
! pre_expr e = get_or_alloc_expr_for_name (def);
!
! add_to_value (get_expr_value_id (e), e);
! if (!in_fre)
! {
! bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), e);
! bitmap_value_insert_into_set (maximal_set, e);
! }
! bitmap_value_insert_into_set (AVAIL_OUT (ENTRY_BLOCK_PTR), e);
}
}
/* Allocate the worklist. */
--- 3564,3591 ----
basic_block block, son;
basic_block *worklist;
size_t sp = 0;
! unsigned i;
! /* We pretend that default definitions are defined in the entry block.
! This includes function arguments and the static chain decl. */
! for (i = 1; i < num_ssa_names; ++i)
! {
! tree name = ssa_name (i);
! pre_expr e;
! if (!name
! || !SSA_NAME_IS_DEFAULT_DEF (name)
! || has_zero_uses (name)
! || !is_gimple_reg (name))
! continue;
!
! e = get_or_alloc_expr_for_name (name);
! add_to_value (get_expr_value_id (e), e);
! if (!in_fre)
{
! bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), e);
! bitmap_value_insert_into_set (maximal_set, e);
}
+ bitmap_value_insert_into_set (AVAIL_OUT (ENTRY_BLOCK_PTR), e);
}
/* Allocate the worklist. */
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-22.c
===================================================================
*** /dev/null 1970-01-01 00:00:00.000000000 +0000
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-22.c 2009-03-28 17:55:21.000000000 +0100
***************
*** 0 ****
--- 1,15 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -fdump-tree-fre" } */
+
+ int i;
+ int foo (void)
+ {
+ int j;
+ i = j;
+ return i;
+ }
+
+ /* We should eliminate the redundant load of i. */
+
+ /* { dg-final { scan-tree-dump-not "= i;" "fre" } } */
+ /* { dg-final { cleanup-tree-dump "fre" } } */