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] Trivial improvement to dominator optimizer


This patch allows the dominator optimizer to eliminate a few more
ABS expressions and convert a few more DIV/MOD operations into SHIFT
or AND operations.  Basically we failed to note that an unsigned value
is always >= 0.  Opps.

[ This is the last queued patch I had from before my last trip.  Like the
  rest of the team I'll be immersed in strictly in reaching our goals for
  integration into the mainline for the immediate future. ]

Bootstrapped and regression tested i686-pc-linux-gnu.  The patch appears
larger than it really is due to indention changes.

	* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): If an
	operand is unsigned, then we can eliminate more ABS expressions
	and turned div/mod expression into shift/and expressions.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.141
diff -c -p -r1.1.2.141 tree-ssa-dom.c
*** tree-ssa-dom.c	25 Feb 2004 03:22:47 -0000	1.1.2.141
--- tree-ssa-dom.c	26 Feb 2004 19:15:51 -0000
*************** simplify_rhs_and_lookup_avail_expr (stru
*** 1711,1735 ****
      {
        tree val;
        tree op = TREE_OPERAND (rhs, 0);
-       tree dummy_cond = walk_data->global_data;
  
!       if (! dummy_cond)
  	{
! 	  dummy_cond = build (GT_EXPR, boolean_type_node,
! 			      op, integer_zero_node);
! 	  dummy_cond = build (COND_EXPR, void_type_node,
! 			      dummy_cond, NULL, NULL);
! 	  walk_data->global_data = dummy_cond;
  	}
        else
  	{
! 	  TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), GT_EXPR);
! 	  TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
! 	  TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1) = integer_zero_node;
  	}
-       val = simplify_cond_and_lookup_avail_expr (dummy_cond,
- 						 &bd->avail_exprs,
- 						 NULL, false);
  
        if (val && integer_onep (val))
  	{
--- 1711,1744 ----
      {
        tree val;
        tree op = TREE_OPERAND (rhs, 0);
  
!       if (TREE_UNSIGNED (TREE_TYPE (op)))
  	{
! 	  val = integer_one_node;
  	}
        else
  	{
! 	  tree dummy_cond = walk_data->global_data;
! 
! 	  if (! dummy_cond)
! 	    {
! 	      dummy_cond = build (GT_EXPR, boolean_type_node,
! 				  op, integer_zero_node);
! 	      dummy_cond = build (COND_EXPR, void_type_node,
! 				  dummy_cond, NULL, NULL);
! 	      walk_data->global_data = dummy_cond;
! 	    }
!           else
! 	    {
! 	      TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), GT_EXPR);
! 	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
! 	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 		= integer_zero_node;
! 	    }
! 	  val = simplify_cond_and_lookup_avail_expr (dummy_cond,
! 						     &bd->avail_exprs,
! 						     NULL, false);
  	}
  
        if (val && integer_onep (val))
  	{
*************** simplify_rhs_and_lookup_avail_expr (stru
*** 1758,1789 ****
        tree val;
        tree op = TREE_OPERAND (rhs, 0);
        tree type = TREE_TYPE (op);
-       tree dummy_cond = walk_data->global_data;
  
!       if (! dummy_cond)
  	{
! 	  dummy_cond = build (GT_EXPR, boolean_type_node,
! 			      op, integer_zero_node);
! 	  dummy_cond = build (COND_EXPR, void_type_node,
! 			      dummy_cond, NULL, NULL);
! 	  walk_data->global_data = dummy_cond;
  	}
        else
  	{
! 	  TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LT_EXPR);
! 	  TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
! 	  TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 	    = convert (type, integer_zero_node);
  	}
-       val = simplify_cond_and_lookup_avail_expr (dummy_cond,
- 						 &bd->avail_exprs,
- 						 NULL, false);
  
!       if (val && (integer_onep (val) || integer_zerop (val)))
  	{
  	  tree t;
  
! 	  if (integer_onep (val))
  	    t = build1 (NEGATE_EXPR, TREE_TYPE (op), op);
  	  else
  	    t = op;
--- 1767,1807 ----
        tree val;
        tree op = TREE_OPERAND (rhs, 0);
        tree type = TREE_TYPE (op);
  
!       if (TREE_UNSIGNED (type))
  	{
! 	  val = integer_zero_node;
  	}
        else
  	{
! 	  tree dummy_cond = walk_data->global_data;
! 
! 	  if (! dummy_cond)
! 	    {
! 	      dummy_cond = build (GT_EXPR, boolean_type_node,
! 				  op, integer_zero_node);
! 	      dummy_cond = build (COND_EXPR, void_type_node,
! 				  dummy_cond, NULL, NULL);
! 	      walk_data->global_data = dummy_cond;
! 	    }
! 	  else
! 	    {
! 	      TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LT_EXPR);
! 	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
! 	      TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
! 		= convert (type, integer_zero_node);
! 	    }
! 	  val = simplify_cond_and_lookup_avail_expr (dummy_cond,
! 						     &bd->avail_exprs,
! 						     NULL, false);
  	}
  
!       if (val
! 	  && (integer_onep (val) || integer_zerop (val)))
  	{
  	  tree t;
  
! 	  if (val && integer_onep (val))
  	    t = build1 (NEGATE_EXPR, TREE_TYPE (op), op);
  	  else
  	    t = op;




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