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]

[tree-ssa] Pick up a few more jump threading opportunities


I must have been on drugs when I forgot to include both the true and
false expressions when threading across edges.  As a result we were
missing a few jump threading opportunities.

I also took the liberty to kill an unused argument.

Bootstrapped and regression tested i686-pc-linux-gnu.

	* tree-ssa-dom.c (thread_across_edge): Lose block_avail_exprs argument.
	Callers updated.  Pass NULL for block_avail_exprs in call to
	lookup_avail_expr.  Record both the condition and the inverted
	condition when threading across an edge.
	
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.78
diff -c -3 -p -r1.1.2.78 tree-ssa-dom.c
*** tree-ssa-dom.c	16 Nov 2003 11:00:40 -0000	1.1.2.78
--- tree-ssa-dom.c	18 Nov 2003 05:57:00 -0000
*************** static void record_equivalences_from_inc
*** 201,207 ****
  static bool eliminate_redundant_computations (tree, varray_type *, 
stmt_ann_t);
  static void record_equivalences_from_stmt (tree, varray_type *,
  					   int, stmt_ann_t);
! static void thread_across_edge (edge, varray_type *);
  static void dom_opt_finalize_block (struct dom_walk_data *, basic_block, 
tree);
  static void dom_opt_initialize_block (struct dom_walk_data *,
  				      basic_block, tree);
--- 201,207 ----
  static bool eliminate_redundant_computations (tree, varray_type *, 
stmt_ann_t);
  static void record_equivalences_from_stmt (tree, varray_type *,
  					   int, stmt_ann_t);
! static void thread_across_edge (edge);
  static void dom_opt_finalize_block (struct dom_walk_data *, basic_block, 
tree);
  static void dom_opt_initialize_block (struct dom_walk_data *,
  				      basic_block, tree);
*************** tree_ssa_dominator_optimize_1 (tree fnde
*** 486,492 ****
     jump which has a known value when reached via BB.  */
  
  static void
! thread_across_edge (edge e, varray_type *block_avail_exprs)
  {
    /* If we have a single successor, then we may be able to thread
       the edge out of our block to a destination of our successor.
--- 486,492 ----
     jump which has a known value when reached via BB.  */
  
  static void
! thread_across_edge (edge e)
  {
    /* If we have a single successor, then we may be able to thread
       the edge out of our block to a destination of our successor.
*************** thread_across_edge (edge e, varray_type 
*** 528,534 ****
  		}
  	    }
  
! 	  cached_lhs = lookup_avail_expr (stmt, block_avail_exprs, false);
  	  if (cached_lhs)
  	    {
  	      edge taken_edge = find_taken_edge (e->dest, cached_lhs);
--- 528,534 ----
  		}
  	    }
  
! 	  cached_lhs = lookup_avail_expr (stmt, NULL, false);
  	  if (cached_lhs)
  	    {
  	      edge taken_edge = find_taken_edge (e->dest, cached_lhs);
*************** dom_opt_finalize_block (struct dom_walk_
*** 633,639 ****
        && (! dom_children (bb)
  	  || ! bitmap_bit_p (dom_children (bb), bb->succ->dest->index)))
      {
!       thread_across_edge (bb->succ, NULL);
      }
    else if ((last = last_stmt (bb))
  	   && TREE_CODE (last) == COND_EXPR
--- 633,639 ----
        && (! dom_children (bb)
  	  || ! bitmap_bit_p (dom_children (bb), bb->succ->dest->index)))
      {
!       thread_across_edge (bb->succ);
      }
    else if ((last = last_stmt (bb))
  	   && TREE_CODE (last) == COND_EXPR
*************** dom_opt_finalize_block (struct dom_walk_
*** 646,651 ****
--- 646,652 ----
      {
        edge e = bb->succ;
        edge true_edge, false_edge;
+       tree cond, inverted;
  
        if (e->flags & EDGE_TRUE_VALUE)
  	{
*************** dom_opt_finalize_block (struct dom_walk_
*** 658,671 ****
  	  true_edge = e->succ_next;
  	}
  
        /* If the THEN arm is the end of a dominator tree, then try to thread
  	 through its edge.  */
        if (! dom_children (bb)
  	  || ! bitmap_bit_p (dom_children (bb), true_edge->dest->index))
  	{
  	  unsigned limit = VARRAY_ACTIVE_SIZE (bd->avail_exprs);
! 	  record_cond_is_true (COND_EXPR_COND (last), &bd->avail_exprs);
! 	  thread_across_edge (true_edge, NULL);
  	  if (limit != VARRAY_ACTIVE_SIZE (bd->avail_exprs))
  	    {
  	      htab_remove_elt (avail_exprs, VARRAY_TOP_TREE (bd->avail_exprs));
--- 659,676 ----
  	  true_edge = e->succ_next;
  	}
  
+       cond = COND_EXPR_COND (last);
+       inverted = invert_truthvalue (cond);
+ 
        /* If the THEN arm is the end of a dominator tree, then try to thread
  	 through its edge.  */
        if (! dom_children (bb)
  	  || ! bitmap_bit_p (dom_children (bb), true_edge->dest->index))
  	{
  	  unsigned limit = VARRAY_ACTIVE_SIZE (bd->avail_exprs);
! 	  record_cond_is_true (cond, &bd->avail_exprs);
! 	  record_cond_is_false (inverted, &bd->avail_exprs);
! 	  thread_across_edge (true_edge);
  	  if (limit != VARRAY_ACTIVE_SIZE (bd->avail_exprs))
  	    {
  	      htab_remove_elt (avail_exprs, VARRAY_TOP_TREE (bd->avail_exprs));
*************** dom_opt_finalize_block (struct dom_walk_
*** 678,685 ****
  	  || ! bitmap_bit_p (dom_children (bb), false_edge->dest->index))
  	{
  	  unsigned limit = VARRAY_ACTIVE_SIZE (bd->avail_exprs);
! 	  record_cond_is_false (COND_EXPR_COND (last), &bd->avail_exprs);
! 	  thread_across_edge (false_edge, NULL);
  	  if (limit != VARRAY_ACTIVE_SIZE (bd->avail_exprs))
  	    {
  	      htab_remove_elt (avail_exprs, VARRAY_TOP_TREE (bd->avail_exprs));
--- 683,691 ----
  	  || ! bitmap_bit_p (dom_children (bb), false_edge->dest->index))
  	{
  	  unsigned limit = VARRAY_ACTIVE_SIZE (bd->avail_exprs);
! 	  record_cond_is_false (cond, &bd->avail_exprs);
! 	  record_cond_is_true (inverted, &bd->avail_exprs);
! 	  thread_across_edge (false_edge);
  	  if (limit != VARRAY_ACTIVE_SIZE (bd->avail_exprs))
  	    {
  	      htab_remove_elt (avail_exprs, VARRAY_TOP_TREE (bd->avail_exprs));




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