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] Fix for pr 14341


As I mentioned in the notes for 14341, the underlying issue is that we have
two expressions which appear to be identical (i_2 <= 99999999), but which
have differing types.

Luckily, in the case of expressions we place into the true/false expression
table we can basically ignore the type of the expression and concentrate solely
on the opcode and operands of each expression.

Our ability to ignore the expression's type is strictly due to the limited
kinds of expressions we put in the table to start with -- we only place
relational operations from COND_EXPRs in the table (thus we know they
always have a boolean type and thus the values 0..1 inclusive).

When looking up values in the table, we may be presented with an expression
of a different type -- integers, FP, etc.  However, all we care about is
knowing if the non-typed expression is in the table.  If it is, then we
convert the result (1 for true_exprs, 0 for false_exprs) to the desired type
and get on with our lives.

Bootstrapped and regression tested.

	* tree-ssa-dom.c (true_false_expr_hash): Update comments slightly.
	(true_false_expr_eq): Update comments slightly.  Avoid using
	operand_equal_p, instead check the code and operands directly.

	* gcc.dg/tree-ssa/20040211-1.c: Update.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.143
diff -c -p -r1.1.2.143 tree-ssa-dom.c
*** tree-ssa-dom.c	28 Feb 2004 01:06:20 -0000	1.1.2.143
--- tree-ssa-dom.c	1 Mar 2004 14:22:58 -0000
*************** get_eq_expr_value (tree if_stmt,
*** 2950,2957 ****
    return retval;
  }
  
! /* Hashing for expressions which are going to be entered into the true/false
!    hash tables.  */
  
  static hashval_t
  true_false_expr_hash (const void *p)
--- 2950,2957 ----
    return retval;
  }
  
! /* Hashing for relational expressions which are going to be entered into the
!    true/false hash tables.  */
  
  static hashval_t
  true_false_expr_hash (const void *p)
*************** true_false_expr_hash (const void *p)
*** 2960,2967 ****
    return iterative_hash_expr (rhs, 0);
  }
  
! /* Given two expressions from the true/false hash tables, return nonzero
!    if they are equivalent.  */
  
  static int
  true_false_expr_eq (const void *p1, const void *p2)
--- 2960,2969 ----
    return iterative_hash_expr (rhs, 0);
  }
  
! /* Given two relational expressions from the true/false hash tables, return
!    nonzero if they are equivalent.   Note that since we are working with
!    nodes which are known to be relational expressions we can be a little
!    more lenient in regards to type checking.  */
  
  static int
  true_false_expr_eq (const void *p1, const void *p2)
*************** true_false_expr_eq (const void *p1, cons
*** 2973,2983 ****
    if (rhs1 == rhs2)
      return true;
  
!   if (TREE_CODE (rhs1) == TREE_CODE (rhs2)
!       && (TREE_TYPE (rhs1) == TREE_TYPE (rhs2)
! 	  || (TYPE_MAIN_VARIANT (TREE_TYPE (rhs1))
! 	      == TYPE_MAIN_VARIANT (TREE_TYPE (rhs2))))
!       && operand_equal_p (rhs1, rhs2, 0))
      {
  #ifdef ENABLE_CHECKING
  	  if (true_false_expr_hash (rhs1) != true_false_expr_hash (rhs2))
--- 2975,2994 ----
    if (rhs1 == rhs2)
      return true;
  
!   /* If the codes are not the same, then they clearly can not be equal.  */
!   if (TREE_CODE (rhs1) != TREE_CODE (rhs2))
!     return false;
! 
!   /* We know both expressions are relationals.  Just check their operands
!      for equality.  If the operator is commutative, then check the
!      operands in reverse order as well.  */
!   if ((operand_equal_p (TREE_OPERAND (rhs1, 0), TREE_OPERAND (rhs2, 0), 0)
!        && operand_equal_p (TREE_OPERAND (rhs1, 1), TREE_OPERAND (rhs2, 1), 
0))
!       || (commutative_tree_code (TREE_CODE (rhs1))
! 	  && operand_equal_p (TREE_OPERAND (rhs1, 0),
! 			      TREE_OPERAND (rhs2, 1), 0)
! 	  && operand_equal_p (TREE_OPERAND (rhs1, 1),
! 			      TREE_OPERAND (rhs2, 0), 0)))
      {
  #ifdef ENABLE_CHECKING
  	  if (true_false_expr_hash (rhs1) != true_false_expr_hash (rhs2))

Index: testsuite/gcc.dg/tree-ssa/20040211-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/Attic/20040211-1.c,v
retrieving revision 1.1.2.1
diff -c -p -r1.1.2.1 20040211-1.c
*** testsuite/gcc.dg/tree-ssa/20040211-1.c	16 Feb 2004 22:42:07 -0000	1.1.2.1
--- testsuite/gcc.dg/tree-ssa/20040211-1.c	1 Mar 2004 14:25:07 -0000
***************
*** 1,5 ****
  /* { dg-do compile } */
! /* { dg-options "-O2 -fdump-tree-forwprop1-details -fdump-tree-cddce" } */
    
  
   
--- 1,5 ----
  /* { dg-do compile } */
! /* { dg-options "-O2 -fdump-tree-cddce" } */
    
  
   
*************** com (rtx insn, int blah)
*** 34,43 ****
    if (!can_move_up (insn, blah))
      foo ();
  }
- 
- /* We should replace one expression within an IF statement with the
-    statement that feeds the IF statement.  */
- /* { dg-final { scan-tree-dump-times "Replaced" 1 "forwprop1"} } */
  
  /* After cddce we should have no IF statements remaining since this
     whole function collapses down to a simple return.  */
--- 34,39 ----














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