public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove more TRUTH_*_EXPR handling from tree opts
@ 2011-07-19 14:05 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2011-07-19 14:05 UTC (permalink / raw)
  To: gcc-patches


This removes the easy cases that seem no longer necessary.  I left
the building of TRUHT_*_EXPRs for the sake of chaining conditions
in place.  Fold is used as simplification machinery here and
it likely can handle TRUTH_*_EXPRs best.  In the end this really
asks for a tree-affine.c like machinery to collect and simplify
predicates (and to simplify expressions against).

Bootstrap & regtest pending.

Richard.

2011-07-19  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-forwprop.c (lookup_logical_inverted_value): Remove
	TRUTH_*_EXPR handling.
	* tree-ssa-operands.c (get_expr_operands): Likewise.
	* tree-ssa-pre.c (fully_constant_expression): Likewise.
	* tree-ssa-uninit.c (use_pred_not_overlap_with_undef_path_pre):
	Likewise.
	(is_and_or_or): Likewise.
	(is_norm_cond_subset_of): Likewise.

Index: trunk/gcc/tree-ssa-forwprop.c
===================================================================
*** trunk.orig/gcc/tree-ssa-forwprop.c	2011-07-19 14:09:05.000000000 +0200
--- trunk/gcc/tree-ssa-forwprop.c	2011-07-19 14:41:29.000000000 +0200
*************** lookup_logical_inverted_value (tree name
*** 1622,1637 ****
    op2 = NULL_TREE;
  
    /* Get for EQ_EXPR or BIT_XOR_EXPR operation the second operand.
!      If CODE isn't an EQ_EXPR, BIT_XOR_EXPR, TRUTH_NOT_EXPR,
!      or BIT_NOT_EXPR, then return.  */
    if (code == EQ_EXPR || code == NE_EXPR
        || code == BIT_XOR_EXPR)
      op2 = gimple_assign_rhs2 (def);
  
    switch (code)
      {
-     case TRUTH_NOT_EXPR:
-       return op1;
      case BIT_NOT_EXPR:
        if (truth_valued_ssa_name (name))
  	return op1;
--- 1622,1634 ----
    op2 = NULL_TREE;
  
    /* Get for EQ_EXPR or BIT_XOR_EXPR operation the second operand.
!      If CODE isn't an EQ_EXPR, BIT_XOR_EXPR, or BIT_NOT_EXPR, then return.  */
    if (code == EQ_EXPR || code == NE_EXPR
        || code == BIT_XOR_EXPR)
      op2 = gimple_assign_rhs2 (def);
  
    switch (code)
      {
      case BIT_NOT_EXPR:
        if (truth_valued_ssa_name (name))
  	return op1;
Index: trunk/gcc/tree-ssa-operands.c
===================================================================
*** trunk.orig/gcc/tree-ssa-operands.c	2011-07-11 17:02:51.000000000 +0200
--- trunk/gcc/tree-ssa-operands.c	2011-07-19 14:38:45.000000000 +0200
*************** get_expr_operands (gimple stmt, tree *ex
*** 968,982 ****
  	gimple_set_has_volatile_ops (stmt, true);
        /* FALLTHRU */
  
-     case TRUTH_NOT_EXPR:
      case VIEW_CONVERT_EXPR:
      do_unary:
        get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags);
        return;
  
-     case TRUTH_AND_EXPR:
-     case TRUTH_OR_EXPR:
-     case TRUTH_XOR_EXPR:
      case COMPOUND_EXPR:
      case OBJ_TYPE_REF:
      case ASSERT_EXPR:
--- 968,978 ----
Index: trunk/gcc/tree-ssa-pre.c
===================================================================
*** trunk.orig/gcc/tree-ssa-pre.c	2011-07-11 17:02:51.000000000 +0200
--- trunk/gcc/tree-ssa-pre.c	2011-07-19 14:38:26.000000000 +0200
*************** fully_constant_expression (pre_expr e)
*** 1150,1163 ****
  	vn_nary_op_t nary = PRE_EXPR_NARY (e);
  	switch (TREE_CODE_CLASS (nary->opcode))
  	  {
- 	  case tcc_expression:
- 	    if (nary->opcode == TRUTH_NOT_EXPR)
- 	      goto do_unary;
- 	    if (nary->opcode != TRUTH_AND_EXPR
- 		&& nary->opcode != TRUTH_OR_EXPR
- 		&& nary->opcode != TRUTH_XOR_EXPR)
- 	      return e;
- 	    /* Fallthrough.  */
  	  case tcc_binary:
  	  case tcc_comparison:
  	    {
--- 1150,1155 ----
Index: trunk/gcc/tree-ssa-uninit.c
===================================================================
*** trunk.orig/gcc/tree-ssa-uninit.c	2011-07-11 17:02:51.000000000 +0200
--- trunk/gcc/tree-ssa-uninit.c	2011-07-19 14:37:21.000000000 +0200
*************** use_pred_not_overlap_with_undef_path_pre
*** 1088,1096 ****
  static inline bool
  is_and_or_or (enum tree_code tc, tree typ)
  {
!   return (tc == TRUTH_AND_EXPR
!           || tc == TRUTH_OR_EXPR
!           || tc == BIT_IOR_EXPR
            || (tc == BIT_AND_EXPR
                && (typ == 0 || TREE_CODE (typ) == BOOLEAN_TYPE)));
  }
--- 1088,1094 ----
  static inline bool
  is_and_or_or (enum tree_code tc, tree typ)
  {
!   return (tc == BIT_IOR_EXPR
            || (tc == BIT_AND_EXPR
                && (typ == 0 || TREE_CODE (typ) == BOOLEAN_TYPE)));
  }
*************** is_norm_cond_subset_of (norm_cond_t norm
*** 1415,1429 ****
    code1 = norm_cond1->cond_code;
    code2 = norm_cond2->cond_code;
  
!   if (code1 == TRUTH_AND_EXPR || code1 == BIT_AND_EXPR)
      {
        /* Both conditions are AND expressions.  */
!       if (code2 == TRUTH_AND_EXPR || code2 == BIT_AND_EXPR)
          return is_and_set_subset_of (norm_cond1, norm_cond2);
        /* NORM_COND1 is an AND expression, and NORM_COND2 is an OR
           expression. In this case, returns true if any subexpression
           of NORM_COND1 is a subset of any subexpression of NORM_COND2.  */
!       else if (code2 == TRUTH_OR_EXPR || code2 == BIT_IOR_EXPR)
          {
            size_t len1;
            len1 = VEC_length (gimple, norm_cond1->conds);
--- 1413,1427 ----
    code1 = norm_cond1->cond_code;
    code2 = norm_cond2->cond_code;
  
!   if (code1 == BIT_AND_EXPR)
      {
        /* Both conditions are AND expressions.  */
!       if (code2 == BIT_AND_EXPR)
          return is_and_set_subset_of (norm_cond1, norm_cond2);
        /* NORM_COND1 is an AND expression, and NORM_COND2 is an OR
           expression. In this case, returns true if any subexpression
           of NORM_COND1 is a subset of any subexpression of NORM_COND2.  */
!       else if (code2 == BIT_IOR_EXPR)
          {
            size_t len1;
            len1 = VEC_length (gimple, norm_cond1->conds);
*************** is_norm_cond_subset_of (norm_cond_t norm
*** 1444,1450 ****
          }
      }
    /* NORM_COND1 is an OR expression  */
!   else if (code1 == TRUTH_OR_EXPR || code1 == BIT_IOR_EXPR)
      {
        if (code2 != code1)
          return false;
--- 1442,1448 ----
          }
      }
    /* NORM_COND1 is an OR expression  */
!   else if (code1 == BIT_IOR_EXPR)
      {
        if (code2 != code1)
          return false;
*************** is_norm_cond_subset_of (norm_cond_t norm
*** 1457,1466 ****
        gcc_assert (VEC_length (gimple, norm_cond1->conds) == 1);
        /* Conservatively returns false if NORM_COND1 is non-decomposible
           and NORM_COND2 is an AND expression.  */
!       if (code2 == TRUTH_AND_EXPR || code2 == BIT_AND_EXPR)
          return false;
  
!       if (code2 == TRUTH_OR_EXPR || code2 == BIT_IOR_EXPR)
          return is_subset_of_any (VEC_index (gimple, norm_cond1->conds, 0),
                                   norm_cond1->invert, norm_cond2, false);
  
--- 1455,1464 ----
        gcc_assert (VEC_length (gimple, norm_cond1->conds) == 1);
        /* Conservatively returns false if NORM_COND1 is non-decomposible
           and NORM_COND2 is an AND expression.  */
!       if (code2 == BIT_AND_EXPR)
          return false;
  
!       if (code2 == BIT_IOR_EXPR)
          return is_subset_of_any (VEC_index (gimple, norm_cond1->conds, 0),
                                   norm_cond1->invert, norm_cond2, false);
  

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-19 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-19 14:05 [PATCH] Remove more TRUTH_*_EXPR handling from tree opts Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).