[PATCH][alias-improvements] Fix PR38723 and loadpre8.c

Richard Guenther rguenther@suse.de
Sun Jan 4 21:39:00 GMT 2009


This fixes PR38723 which together with the ability to skip loops in
maybe_skip_until fixes the loadpre8.c regression.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
branch.

Richard.

2009-01-04  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/38723
	* tree-ssa-alias.c (maybe_skip_until): Use get_continuation_for_phi.
	* tree-ssa-pre.c (compute_avail): Add all default definitions to
	the entry block.

Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c	(revision 143055)
--- gcc/tree-ssa-alias.c	(working copy)
*************** stmt_may_clobber_ref_p (gimple stmt, tre
*** 498,503 ****
--- 498,505 ----
    return false;
  }
  
+ static tree get_continuation_for_phi (gimple, tree);
+ 
  /* Walk the virtual use-def chain of VUSE until hitting the virtual operand
     TARGET or a statement clobbering the memory reference REF in which
     case false is returned.  The walk starts with VUSE, one argument of PHI.  */
*************** maybe_skip_until (gimple phi, tree targe
*** 511,517 ****
        gimple def_stmt = SSA_NAME_DEF_STMT (vuse);
        /* The original PHI node ends the walk successfully.  */
        if (gimple_code (def_stmt) == GIMPLE_PHI)
! 	return (def_stmt == phi);
        /* A clobbering statement or the end of the IL ends it failing.  */
        else if (gimple_nop_p (def_stmt)
  	       || stmt_may_clobber_ref_p (def_stmt, ref))
--- 513,526 ----
        gimple def_stmt = SSA_NAME_DEF_STMT (vuse);
        /* The original PHI node ends the walk successfully.  */
        if (gimple_code (def_stmt) == GIMPLE_PHI)
! 	{
! 	  if (def_stmt == phi)
! 	    return true;
! 	  vuse = get_continuation_for_phi (def_stmt, ref);
! 	  if (!vuse)
! 	    return false;
! 	  continue;
! 	}
        /* A clobbering statement or the end of the IL ends it failing.  */
        else if (gimple_nop_p (def_stmt)
  	       || stmt_may_clobber_ref_p (def_stmt, ref))
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c	(revision 143055)
--- gcc/tree-ssa-pre.c	(working copy)
*************** compute_avail (void)
*** 3527,3572 ****
    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.  */
--- 3527,3553 ----
    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))
! 	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.  */



More information about the Gcc-patches mailing list