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]

Re: [PATCH] Rename tree_ssa_useless_type_conversion_1


On Fri, 22 Jun 2007, Richard Guenther wrote:

> On Fri, 22 Jun 2007, Diego Novillo wrote:
> 
> > Renaming tree_ssa_useless_type_conversion comes in another
> > patch?
> 
> I still have to create it (as well as capturing the symmetric case of
> type_conversion_needed_p into sth like types_compatible_p).  But yes,
> that is the plan.

Which would be the following.  Renames tree_ssa_useless_type_conversion
to useless_type_conversion_p, adds types_compatible_p.

Richard.

2006-06-22  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (tree_ssa_useless_type_conversion): Rename to ...
	(useless_type_conversion_p): ... this.
	(types_compatible_p): Declare.
	* expr.c (array_ref_element_size): Adjust comment.
	(component_ref_field_offset): Likewise.
	* gimplify.c (gimplify_conversion): Use useless_type_conversion_p
	instead of tree_ssa_useless_type_conversion.
	(gimplify_addr_expr): Likewise.
	* tree.h (STRIP_USELESS_TYPE_CONVERSION): Likewise.
	* ipa-type-escape.c (discover_unique_type): Take advantage of
	types_compatible_p.
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Likewise.
	* tree-ssa-dom.c (avail_expr_eq): Likewise.
	* tree-vn.c (expressions_equal_p): Likewise.
	* tree.c (fields_compatible_p): Likewise.

Index: gcc/expr.c
===================================================================
*** gcc.orig/expr.c	2007-06-18 17:20:45.000000000 +0200
--- gcc/expr.c	2007-06-22 14:03:49.000000000 +0200
*************** array_ref_element_size (tree exp)
*** 5937,5943 ****
       in alignment units of the element type.  So multiply by that value.  */
    if (aligned_size)
      {
!       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
  	 sizetype from another type of the same width and signedness.  */
        if (TREE_TYPE (aligned_size) != sizetype)
  	aligned_size = fold_convert (sizetype, aligned_size);
--- 5937,5943 ----
       in alignment units of the element type.  So multiply by that value.  */
    if (aligned_size)
      {
!       /* ??? STRIP_USELESS_TYPE_CONVERSION will eliminate casts to
  	 sizetype from another type of the same width and signedness.  */
        if (TREE_TYPE (aligned_size) != sizetype)
  	aligned_size = fold_convert (sizetype, aligned_size);
*************** component_ref_field_offset (tree exp)
*** 6003,6009 ****
       value.  */
    if (aligned_offset)
      {
!       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
  	 sizetype from another type of the same width and signedness.  */
        if (TREE_TYPE (aligned_offset) != sizetype)
  	aligned_offset = fold_convert (sizetype, aligned_offset);
--- 6003,6009 ----
       value.  */
    if (aligned_offset)
      {
!       /* ??? STRIP_USELESS_TYPE_CONVERSION will eliminate casts to
  	 sizetype from another type of the same width and signedness.  */
        if (TREE_TYPE (aligned_offset) != sizetype)
  	aligned_offset = fold_convert (sizetype, aligned_offset);
Index: gcc/gimplify.c
===================================================================
*** gcc.orig/gimplify.c	2007-06-22 13:54:09.000000000 +0200
--- gcc/gimplify.c	2007-06-22 14:26:10.000000000 +0200
*************** gimplify_conversion (tree *expr_p)
*** 1625,1631 ****
    STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0));
  
    /* And remove the outermost conversion if it's useless.  */
!   if (tree_ssa_useless_type_conversion (*expr_p))
      *expr_p = TREE_OPERAND (*expr_p, 0);
  
    /* Attempt to avoid NOP_EXPR by producing reference to a subtype.
--- 1625,1631 ----
    STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0));
  
    /* And remove the outermost conversion if it's useless.  */
!   if (useless_type_conversion_p (*expr_p))
      *expr_p = TREE_OPERAND (*expr_p, 0);
  
    /* Attempt to avoid NOP_EXPR by producing reference to a subtype.
*************** gimplify_addr_expr (tree *expr_p, tree *
*** 3945,3951 ****
        /* If the operand is a useless conversion, look through it.  Doing so
  	 guarantees that the ADDR_EXPR and its operand will remain of the
  	 same type.  */
!       if (tree_ssa_useless_type_conversion (TREE_OPERAND (op0, 0)))
  	op0 = TREE_OPERAND (op0, 0);
  
        *expr_p = fold_convert (TREE_TYPE (expr),
--- 3945,3951 ----
        /* If the operand is a useless conversion, look through it.  Doing so
  	 guarantees that the ADDR_EXPR and its operand will remain of the
  	 same type.  */
!       if (useless_type_conversion_p (TREE_OPERAND (op0, 0)))
  	op0 = TREE_OPERAND (op0, 0);
  
        *expr_p = fold_convert (TREE_TYPE (expr),
Index: gcc/tree-flow.h
===================================================================
*** gcc.orig/tree-flow.h	2007-06-22 12:05:43.000000000 +0200
--- gcc/tree-flow.h	2007-06-22 14:31:15.000000000 +0200
*************** extern void strict_aliasing_warning_back
*** 867,874 ****
  extern void init_tree_ssa (void);
  extern edge ssa_redirect_edge (edge, basic_block);
  extern void flush_pending_stmts (edge);
! extern bool tree_ssa_useless_type_conversion (tree);
  extern bool type_conversion_needed_p (tree, tree);
  extern void verify_ssa (bool);
  extern void delete_tree_ssa (void);
  extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
--- 867,875 ----
  extern void init_tree_ssa (void);
  extern edge ssa_redirect_edge (edge, basic_block);
  extern void flush_pending_stmts (edge);
! extern bool useless_type_conversion_p (tree);
  extern bool type_conversion_needed_p (tree, tree);
+ extern bool types_compatible_p (tree, tree);
  extern void verify_ssa (bool);
  extern void delete_tree_ssa (void);
  extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
Index: gcc/tree.h
===================================================================
*** gcc.orig/tree.h	2007-06-22 11:50:26.000000000 +0200
--- gcc/tree.h	2007-06-22 14:23:31.000000000 +0200
*************** extern void omp_clause_range_check_faile
*** 1021,1030 ****
      (EXP) = TREE_OPERAND (EXP, 0)
  
  /* Remove unnecessary type conversions according to
!    tree_ssa_useless_type_conversion.  */
  
  #define STRIP_USELESS_TYPE_CONVERSION(EXP)				\
!       while (tree_ssa_useless_type_conversion (EXP))			\
  	EXP = TREE_OPERAND (EXP, 0)
  
  /* Nonzero if TYPE represents an integral type.  Note that we do not
--- 1021,1030 ----
      (EXP) = TREE_OPERAND (EXP, 0)
  
  /* Remove unnecessary type conversions according to
!    type_conversion_needed_p.  */
  
  #define STRIP_USELESS_TYPE_CONVERSION(EXP)				\
!       while (useless_type_conversion_p (EXP))				\
  	EXP = TREE_OPERAND (EXP, 0)
  
  /* Nonzero if TYPE represents an integral type.  Note that we do not
Index: gcc/ipa-type-escape.c
===================================================================
*** gcc.orig/ipa-type-escape.c	2007-06-22 13:54:09.000000000 +0200
--- gcc/ipa-type-escape.c	2007-06-22 14:27:36.000000000 +0200
*************** discover_unique_type (tree type)
*** 219,226 ****
  	  /* Create an alias since this is just the same as
  	     other_type.  */
  	  tree other_type = (tree) result->value;
! 	  if (!type_conversion_needed_p (type, other_type)
! 	      && !type_conversion_needed_p (other_type, type))
  	    {
  	      free (brand);
  	      /* Insert this new type as an alias for other_type.  */
--- 219,225 ----
  	  /* Create an alias since this is just the same as
  	     other_type.  */
  	  tree other_type = (tree) result->value;
! 	  if (types_compatible_p (type, other_type))
  	    {
  	      free (brand);
  	      /* Insert this new type as an alias for other_type.  */
Index: gcc/tree-ssa-copyrename.c
===================================================================
*** gcc.orig/tree-ssa-copyrename.c	2007-06-22 13:54:09.000000000 +0200
--- gcc/tree-ssa-copyrename.c	2007-06-22 14:28:28.000000000 +0200
*************** copy_rename_partition_coalesce (var_map 
*** 240,247 ****
      }
  
    /* Don't coalesce if the two variables aren't type compatible.  */
!   if (type_conversion_needed_p (TREE_TYPE (root1), TREE_TYPE (root2))
!       || type_conversion_needed_p (TREE_TYPE (root2), TREE_TYPE (root1)))
      {
        if (debug)
  	fprintf (debug, " : Incompatible types.  No coalesce.\n");
--- 240,246 ----
      }
  
    /* Don't coalesce if the two variables aren't type compatible.  */
!   if (!types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
      {
        if (debug)
  	fprintf (debug, " : Incompatible types.  No coalesce.\n");
Index: gcc/tree-ssa-dom.c
===================================================================
*** gcc.orig/tree-ssa-dom.c	2007-06-22 13:54:09.000000000 +0200
--- gcc/tree-ssa-dom.c	2007-06-22 14:29:26.000000000 +0200
*************** avail_expr_eq (const void *p1, const voi
*** 2048,2055 ****
  
    /* In case of a collision, both RHS have to be identical and have the
       same VUSE operands.  */
!   if (!type_conversion_needed_p (TREE_TYPE (rhs1), TREE_TYPE (rhs2))
!       && !type_conversion_needed_p (TREE_TYPE (rhs2), TREE_TYPE (rhs1))
        && operand_equal_p (rhs1, rhs2, OEP_PURE_SAME))
      {
        bool ret = compare_ssa_operands_equal (stmt1, stmt2, SSA_OP_VUSE);
--- 2048,2054 ----
  
    /* In case of a collision, both RHS have to be identical and have the
       same VUSE operands.  */
!   if (types_compatible_p (TREE_TYPE (rhs1), TREE_TYPE (rhs2))
        && operand_equal_p (rhs1, rhs2, OEP_PURE_SAME))
      {
        bool ret = compare_ssa_operands_equal (stmt1, stmt2, SSA_OP_VUSE);
Index: gcc/tree-vn.c
===================================================================
*** gcc.orig/tree-vn.c	2007-06-22 13:54:09.000000000 +0200
--- gcc/tree-vn.c	2007-06-22 14:30:20.000000000 +0200
*************** expressions_equal_p (tree e1, tree e2)
*** 124,131 ****
      }
    else if (TREE_CODE (e1) == TREE_CODE (e2) 
  	   && (te1 == te2
! 	       || (!type_conversion_needed_p (te1, te2)
! 		   && !type_conversion_needed_p (te2, te1)))
  	   && operand_equal_p (e1, e2, OEP_PURE_SAME))
      return true;
  
--- 124,130 ----
      }
    else if (TREE_CODE (e1) == TREE_CODE (e2) 
  	   && (te1 == te2
! 	       || types_compatible_p (te1, te2))
  	   && operand_equal_p (e1, e2, OEP_PURE_SAME))
      return true;
  
Index: gcc/tree.c
===================================================================
*** gcc.orig/tree.c	2007-06-22 13:54:09.000000000 +0200
--- gcc/tree.c	2007-06-22 14:30:46.000000000 +0200
*************** fields_compatible_p (tree f1, tree f2)
*** 7691,7698 ****
                          DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
      return false;
  
!   if (type_conversion_needed_p (TREE_TYPE (f1), TREE_TYPE (f2))
!       || type_conversion_needed_p (TREE_TYPE (f2), TREE_TYPE (f1)))
      return false;
  
    return true;
--- 7691,7697 ----
                          DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
      return false;
  
!   if (!types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2)))
      return false;
  
    return true;


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