This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Some DCE cleanup


As the oracle now provides a generic decomposed reference thing (ao_ref)
DCE doesn't need to implement its own variant.

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

Richard.

2009-06-30  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-alias.c (walk_aliased_vdefs_1): Change interface to
	use ao_ref references.
	(walk_aliased_vdefs): Likewise.
	* tree-ssa-alias.h (walk_aliased_vdefs): Adjust prototype.
	* tree-ssa-dce.c (struct ref_data): Remove.
	(mark_aliased_reaching_defs_necessary_1): Use the ao_ref argument.
	(mark_aliased_reaching_defs_necessary): Adjust.
	(mark_all_reaching_defs_necessary_1): Likewise.

Index: trunk/gcc/tree-ssa-alias.c
===================================================================
*** trunk.orig/gcc/tree-ssa-alias.c	2009-06-29 14:37:17.000000000 +0200
--- trunk/gcc/tree-ssa-alias.c	2009-06-29 15:09:39.000000000 +0200
*************** walk_non_aliased_vuses (ao_ref *ref, tre
*** 1427,1434 ****
     The function returns the number of statements walked.  */
  
  static unsigned int
! walk_aliased_vdefs_1 (tree ref, tree vdef,
! 		      bool (*walker)(tree, tree, void *), void *data,
  		      bitmap *visited, unsigned int cnt)
  {
    do
--- 1427,1434 ----
     The function returns the number of statements walked.  */
  
  static unsigned int
! walk_aliased_vdefs_1 (ao_ref *ref, tree vdef,
! 		      bool (*walker)(ao_ref *, tree, void *), void *data,
  		      bitmap *visited, unsigned int cnt)
  {
    do
*************** walk_aliased_vdefs_1 (tree ref, tree vde
*** 1455,1461 ****
        /* ???  Do we want to account this to TV_ALIAS_STMT_WALK?  */
        cnt++;
        if ((!ref
! 	   || stmt_may_clobber_ref_p (def_stmt, ref))
  	  && (*walker) (ref, vdef, data))
  	return cnt;
  
--- 1455,1461 ----
        /* ???  Do we want to account this to TV_ALIAS_STMT_WALK?  */
        cnt++;
        if ((!ref
! 	   || stmt_may_clobber_ref_p_1 (def_stmt, ref))
  	  && (*walker) (ref, vdef, data))
  	return cnt;
  
*************** walk_aliased_vdefs_1 (tree ref, tree vde
*** 1465,1472 ****
  }
  
  unsigned int
! walk_aliased_vdefs (tree ref, tree vdef,
! 		    bool (*walker)(tree, tree, void *), void *data,
  		    bitmap *visited)
  {
    bitmap local_visited = NULL;
--- 1465,1472 ----
  }
  
  unsigned int
! walk_aliased_vdefs (ao_ref *ref, tree vdef,
! 		    bool (*walker)(ao_ref *, tree, void *), void *data,
  		    bitmap *visited)
  {
    bitmap local_visited = NULL;
Index: trunk/gcc/tree-ssa-alias.h
===================================================================
*** trunk.orig/gcc/tree-ssa-alias.h	2009-06-29 14:20:56.000000000 +0200
--- trunk/gcc/tree-ssa-alias.h	2009-06-29 15:02:57.000000000 +0200
*************** extern bool stmt_may_clobber_ref_p_1 (gi
*** 100,108 ****
  extern void *walk_non_aliased_vuses (ao_ref *, tree,
  				     void *(*)(ao_ref *, tree, void *),
  				     void *(*)(ao_ref *, tree, void *), void *);
! extern unsigned int walk_aliased_vdefs (tree, tree,
! 					bool (*)(tree, tree, void *), void *,
! 					bitmap *);
  extern struct ptr_info_def *get_ptr_info (tree);
  extern void dump_alias_info (FILE *);
  extern void debug_alias_info (void);
--- 100,108 ----
  extern void *walk_non_aliased_vuses (ao_ref *, tree,
  				     void *(*)(ao_ref *, tree, void *),
  				     void *(*)(ao_ref *, tree, void *), void *);
! extern unsigned int walk_aliased_vdefs (ao_ref *, tree,
! 					bool (*)(ao_ref *, tree, void *),
! 					void *, bitmap *);
  extern struct ptr_info_def *get_ptr_info (tree);
  extern void dump_alias_info (FILE *);
  extern void debug_alias_info (void);
Index: trunk/gcc/tree-ssa-dce.c
===================================================================
*** trunk.orig/gcc/tree-ssa-dce.c	2009-06-29 14:37:17.000000000 +0200
--- trunk/gcc/tree-ssa-dce.c	2009-06-29 16:04:46.000000000 +0200
*************** ref_may_be_aliased (tree ref)
*** 452,464 ****
  	   && !may_be_aliased (ref));
  }
  
- struct ref_data {
-   tree base;
-   HOST_WIDE_INT size;
-   HOST_WIDE_INT offset;
-   HOST_WIDE_INT max_size;
- };
- 
  static bitmap visited = NULL;
  static unsigned int longest_chain = 0;
  static unsigned int total_chain = 0;
--- 469,474 ----
*************** static bool chain_ovfl = false;
*** 471,480 ****
     anymore.  DATA points to cached get_ref_base_and_extent data for REF.  */
  
  static bool
! mark_aliased_reaching_defs_necessary_1 (tree ref, tree vdef, void *data)
  {
    gimple def_stmt = SSA_NAME_DEF_STMT (vdef);
-   struct ref_data *refd = (struct ref_data *)data;
  
    /* All stmts we visit are necessary.  */
    mark_operand_necessary (vdef);
--- 481,490 ----
     anymore.  DATA points to cached get_ref_base_and_extent data for REF.  */
  
  static bool
! mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef,
! 					void *data ATTRIBUTE_UNUSED)
  {
    gimple def_stmt = SSA_NAME_DEF_STMT (vdef);
  
    /* All stmts we visit are necessary.  */
    mark_operand_necessary (vdef);
*************** mark_aliased_reaching_defs_necessary_1 (
*** 485,506 ****
      {
        tree base, lhs = gimple_get_lhs (def_stmt);
        HOST_WIDE_INT size, offset, max_size;
        base = get_ref_base_and_extent (lhs, &offset, &size, &max_size);
        /* We can get MEM[symbol: sZ, index: D.8862_1] here,
  	 so base == refd->base does not always hold.  */
!       if (base == refd->base)
  	{
  	  /* For a must-alias check we need to be able to constrain
  	     the accesses properly.  */
  	  if (size != -1 && size == max_size
! 	      && refd->max_size != -1)
  	    {
! 	      if (offset <= refd->offset
! 		  && offset + size >= refd->offset + refd->max_size)
  		return true;
  	    }
  	  /* Or they need to be exactly the same.  */
! 	  else if (operand_equal_p (ref, lhs, 0))
  	    return true;
  	}
      }
--- 495,518 ----
      {
        tree base, lhs = gimple_get_lhs (def_stmt);
        HOST_WIDE_INT size, offset, max_size;
+       ao_ref_base (ref);
        base = get_ref_base_and_extent (lhs, &offset, &size, &max_size);
        /* We can get MEM[symbol: sZ, index: D.8862_1] here,
  	 so base == refd->base does not always hold.  */
!       if (base == ref->base)
  	{
  	  /* For a must-alias check we need to be able to constrain
  	     the accesses properly.  */
  	  if (size != -1 && size == max_size
! 	      && ref->max_size != -1)
  	    {
! 	      if (offset <= ref->offset
! 		  && offset + size >= ref->offset + ref->max_size)
  		return true;
  	    }
  	  /* Or they need to be exactly the same.  */
! 	  else if (ref->ref
! 		   && operand_equal_p (ref->ref, lhs, 0))
  	    return true;
  	}
      }
*************** mark_aliased_reaching_defs_necessary_1 (
*** 512,525 ****
  static void
  mark_aliased_reaching_defs_necessary (gimple stmt, tree ref)
  {
-   struct ref_data refd;
    unsigned int chain;
    gcc_assert (!chain_ovfl);
!   refd.base = get_ref_base_and_extent (ref, &refd.offset, &refd.size,
! 				       &refd.max_size);
!   chain = walk_aliased_vdefs (ref, gimple_vuse (stmt),
  			      mark_aliased_reaching_defs_necessary_1,
! 			      &refd, NULL);
    if (chain > longest_chain)
      longest_chain = chain;
    total_chain += chain;
--- 524,536 ----
  static void
  mark_aliased_reaching_defs_necessary (gimple stmt, tree ref)
  {
    unsigned int chain;
+   ao_ref refd;
    gcc_assert (!chain_ovfl);
!   ao_ref_init (&refd, ref);
!   chain = walk_aliased_vdefs (&refd, gimple_vuse (stmt),
  			      mark_aliased_reaching_defs_necessary_1,
! 			      NULL, NULL);
    if (chain > longest_chain)
      longest_chain = chain;
    total_chain += chain;
*************** mark_aliased_reaching_defs_necessary (gi
*** 532,539 ****
     a non-aliased decl.  */
  
  static bool
! mark_all_reaching_defs_necessary_1 (tree ref ATTRIBUTE_UNUSED,
! 				tree vdef, void *data ATTRIBUTE_UNUSED)
  {
    gimple def_stmt = SSA_NAME_DEF_STMT (vdef);
  
--- 543,550 ----
     a non-aliased decl.  */
  
  static bool
! mark_all_reaching_defs_necessary_1 (ao_ref *ref ATTRIBUTE_UNUSED,
! 				    tree vdef, void *data ATTRIBUTE_UNUSED)
  {
    gimple def_stmt = SSA_NAME_DEF_STMT (vdef);
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]