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]

[PATCH] Replace calls to types_compatible_p langhook by calls to tree_ssa_useless_type_conversion_1


This consolidates all calls to types_compatible_p to
tree_ssa_useless_type_conversion_1, so that will be the only place we
need to fix to get rid of it.  Calls from the C family of frontends
(and rs6000.c) remain, one in c-convert.c and one in c-format.c.

I had to move the fix for PR15988 to tree-inline.c where this bug
was exposed.  But as Andrew mentions, this is really a C++ frontend
bug.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

I plan to commit this (or a variant of it) after we go out of the 
freezing.  Note that you are actively discuraged of introducing
more calls to this langhook ;)

Thanks,
Richard.


2007-06-20  Richard Guenther  <rguenther@suse.de>

	* ipa-type-escape.c (discover_unique_type): Use
	tree_ssa_useless_type_conversion_1 instead of
	lang_hooks.types_compatible_p.
	* tree-inline.c (setup_one_parameter): Likewise.
	(declare_return_variable): Likewise.
	* tree-nrv.c (tree_nrv): Likewise.
	* tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
	(maybe_fold_offset_to_component_ref): Likewise.
	(maybe_fold_offset_to_reference): Likewise.
	* tree-ssa-copy.c (may_propagate_copy): Likewise.
	(merge_alias_info): Likewise.
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce):
	Likewise.
	* tree-ssa-dom.c (cprop_operand): Likewise.
	(avail_expr_eq): Likewise.
	* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Likewise.
	* tree-ssa-phiopt.c (conditional_replacement): Likewise.
	* tree-ssa-reassoc.c (optimize_ops_list): Likewise.
	* tree-tailcall.c (find_tail_calls): Likewise.
	* tree-vect-generic.c (expand_vector_operations_1): Likewise.
	* tree-vn.c (expressions_equal_p): Likewise.
	* tree.c (fields_compatible_p): Likewise.
	* gimplify.c (canonicalize_addr_expr): Likewise.
	(fold_indirect_ref_rhs): Likewise.
	(gimplify_addr_expr): Likewise.  Swap parameters to cpt_same_type.
	(cpt_same_type): Likewise.
	(check_pointer_types_r): Swap parameters to cpt_same_type
	where appropriate.
	* fold-const.c (fold_convert): Revert fix for PR15988.
	* tree-inline.c (setup_one_parameter): Instead fix it here by
	using fold_build1 instead of fold_convert.

Index: gcc/ipa-type-escape.c
===================================================================
*** gcc.orig/ipa-type-escape.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/ipa-type-escape.c	2007-06-19 18:03:26.000000000 +0200
*************** discover_unique_type (tree type)
*** 219,225 ****
  	  /* Create an alias since this is just the same as
  	     other_type.  */
  	  tree other_type = (tree) result->value;
! 	  if (lang_hooks.types_compatible_p (type, other_type) == 1)
  	    {
  	      free (brand);
  	      /* Insert this new type as an alias for other_type.  */
--- 219,226 ----
  	  /* Create an alias since this is just the same as
  	     other_type.  */
  	  tree other_type = (tree) result->value;
! 	  if (tree_ssa_useless_type_conversion_1 (type, other_type)
! 	      && tree_ssa_useless_type_conversion_1 (other_type, type))
  	    {
  	      free (brand);
  	      /* Insert this new type as an alias for other_type.  */
Index: gcc/tree-inline.c
===================================================================
*** gcc.orig/tree-inline.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-inline.c	2007-06-20 13:32:52.000000000 +0200
*************** setup_one_parameter (copy_body_data *id,
*** 1278,1284 ****
    tree init_stmt;
    tree var;
    tree var_sub;
!   tree rhs = value ? fold_convert (TREE_TYPE (p), value) : NULL;
    tree def = (gimple_in_ssa_p (cfun)
  	      ? gimple_default_def (id->src_cfun, p) : NULL);
  
--- 1278,1284 ----
    tree init_stmt;
    tree var;
    tree var_sub;
!   tree rhs = value ? fold_build1 (NOP_EXPR, TREE_TYPE (p), value) : NULL;
    tree def = (gimple_in_ssa_p (cfun)
  	      ? gimple_default_def (id->src_cfun, p) : NULL);
  
*************** setup_one_parameter (copy_body_data *id,
*** 1295,1301 ****
  	 It is not big deal to prohibit constant propagation here as
  	 we will constant propagate in DOM1 pass anyway.  */
        if (is_gimple_min_invariant (value)
! 	  && lang_hooks.types_compatible_p (TREE_TYPE (value), TREE_TYPE (p))
  	  /* We have to be very careful about ADDR_EXPR.  Make sure
  	     the base variable isn't a local variable of the inlined
  	     function, e.g., when doing recursive inlining, direct or
--- 1295,1302 ----
  	 It is not big deal to prohibit constant propagation here as
  	 we will constant propagate in DOM1 pass anyway.  */
        if (is_gimple_min_invariant (value)
! 	  && tree_ssa_useless_type_conversion_1 (TREE_TYPE (p),
! 						 TREE_TYPE (value))
  	  /* We have to be very careful about ADDR_EXPR.  Make sure
  	     the base variable isn't a local variable of the inlined
  	     function, e.g., when doing recursive inlining, direct or
*************** declare_return_variable (copy_body_data 
*** 1584,1590 ****
        bool use_it = false;
  
        /* We can't use MODIFY_DEST if there's type promotion involved.  */
!       if (!lang_hooks.types_compatible_p (caller_type, callee_type))
  	use_it = false;
  
        /* ??? If we're assigning to a variable sized type, then we must
--- 1585,1591 ----
        bool use_it = false;
  
        /* We can't use MODIFY_DEST if there's type promotion involved.  */
!       if (!tree_ssa_useless_type_conversion_1 (callee_type, caller_type))
  	use_it = false;
  
        /* ??? If we're assigning to a variable sized type, then we must
*************** declare_return_variable (copy_body_data 
*** 1648,1654 ****
    /* Build the use expr.  If the return type of the function was
       promoted, convert it back to the expected type.  */
    use = var;
!   if (!lang_hooks.types_compatible_p (TREE_TYPE (var), caller_type))
      use = fold_convert (caller_type, var);
      
    STRIP_USELESS_TYPE_CONVERSION (use);
--- 1649,1655 ----
    /* Build the use expr.  If the return type of the function was
       promoted, convert it back to the expected type.  */
    use = var;
!   if (!tree_ssa_useless_type_conversion_1 (caller_type, TREE_TYPE (var)))
      use = fold_convert (caller_type, var);
      
    STRIP_USELESS_TYPE_CONVERSION (use);
Index: gcc/tree-nrv.c
===================================================================
*** gcc.orig/tree-nrv.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-nrv.c	2007-06-19 18:03:26.000000000 +0200
*************** tree_nrv (void)
*** 159,166 ****
  		  || TREE_STATIC (found)
  		  || TREE_ADDRESSABLE (found)
  		  || DECL_ALIGN (found) > DECL_ALIGN (result)
! 		  || !lang_hooks.types_compatible_p (TREE_TYPE (found), 
! 						     result_type))
  		return 0;
  	    }
  	  else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
--- 159,166 ----
  		  || TREE_STATIC (found)
  		  || TREE_ADDRESSABLE (found)
  		  || DECL_ALIGN (found) > DECL_ALIGN (result)
! 		  || !tree_ssa_useless_type_conversion_1 (result_type,
! 							  TREE_TYPE (found)))
  		return 0;
  	    }
  	  else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc.orig/tree-ssa-ccp.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-ccp.c	2007-06-20 11:19:44.000000000 +0200
*************** maybe_fold_offset_to_array_ref (tree bas
*** 1576,1582 ****
    if (TREE_CODE (array_type) != ARRAY_TYPE)
      return NULL_TREE;
    elt_type = TREE_TYPE (array_type);
!   if (!lang_hooks.types_compatible_p (orig_type, elt_type))
      return NULL_TREE;
  
    /* Use signed size type for intermediate computation on the index.  */
--- 1576,1582 ----
    if (TREE_CODE (array_type) != ARRAY_TYPE)
      return NULL_TREE;
    elt_type = TREE_TYPE (array_type);
!   if (!tree_ssa_useless_type_conversion_1 (orig_type, elt_type))
      return NULL_TREE;
  
    /* Use signed size type for intermediate computation on the index.  */
*************** maybe_fold_offset_to_component_ref (tree
*** 1667,1673 ****
      return NULL_TREE;
  
    /* Short-circuit silly cases.  */
!   if (lang_hooks.types_compatible_p (record_type, orig_type))
      return NULL_TREE;
  
    tail_array_field = NULL_TREE;
--- 1667,1673 ----
      return NULL_TREE;
  
    /* Short-circuit silly cases.  */
!   if (tree_ssa_useless_type_conversion_1 (record_type, orig_type))
      return NULL_TREE;
  
    tail_array_field = NULL_TREE;
*************** maybe_fold_offset_to_component_ref (tree
*** 1705,1711 ****
        /* Here we exactly match the offset being checked.  If the types match,
  	 then we can return that field.  */
        if (cmp == 0
! 	  && lang_hooks.types_compatible_p (orig_type, field_type))
  	{
  	  if (base_is_ptr)
  	    base = build1 (INDIRECT_REF, record_type, base);
--- 1705,1711 ----
        /* Here we exactly match the offset being checked.  If the types match,
  	 then we can return that field.  */
        if (cmp == 0
! 	  && tree_ssa_useless_type_conversion_1 (orig_type, field_type))
  	{
  	  if (base_is_ptr)
  	    base = build1 (INDIRECT_REF, record_type, base);
*************** maybe_fold_offset_to_reference (tree bas
*** 1810,1816 ****
  					  sub_offset / BITS_PER_UNIT), 1);
  	    }
  	}
!       if (lang_hooks.types_compatible_p (orig_type, TREE_TYPE (base))
  	  && integer_zerop (offset))
  	return base;
        type = TREE_TYPE (base);
--- 1810,1816 ----
  					  sub_offset / BITS_PER_UNIT), 1);
  	    }
  	}
!       if (tree_ssa_useless_type_conversion_1 (orig_type, TREE_TYPE (base))
  	  && integer_zerop (offset))
  	return base;
        type = TREE_TYPE (base);
Index: gcc/tree-ssa-copy.c
===================================================================
*** gcc.orig/tree-ssa-copy.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-copy.c	2007-06-19 18:03:26.000000000 +0200
*************** may_propagate_copy (tree dest, tree orig
*** 130,136 ****
        tree mt_orig = symbol_mem_tag (SSA_NAME_VAR (orig));
        if (mt_dest && mt_orig && mt_dest != mt_orig)
  	return false;
!       else if (!lang_hooks.types_compatible_p (type_d, type_o))
  	return false;
        else if (get_alias_set (TREE_TYPE (type_d)) != 
  	       get_alias_set (TREE_TYPE (type_o)))
--- 130,136 ----
        tree mt_orig = symbol_mem_tag (SSA_NAME_VAR (orig));
        if (mt_dest && mt_orig && mt_dest != mt_orig)
  	return false;
!       else if (!tree_ssa_useless_type_conversion_1 (type_d, type_o))
  	return false;
        else if (get_alias_set (TREE_TYPE (type_d)) != 
  	       get_alias_set (TREE_TYPE (type_o)))
*************** merge_alias_info (tree orig_name, tree n
*** 222,229 ****
    gcc_assert (POINTER_TYPE_P (TREE_TYPE (new_name)));
  
  #if defined ENABLE_CHECKING
!   gcc_assert (lang_hooks.types_compatible_p (TREE_TYPE (orig_name),
! 					     TREE_TYPE (new_name)));
  
    /* If the pointed-to alias sets are different, these two pointers
       would never have the same memory tag.  In this case, NEW should
--- 222,229 ----
    gcc_assert (POINTER_TYPE_P (TREE_TYPE (new_name)));
  
  #if defined ENABLE_CHECKING
!   gcc_assert (tree_ssa_useless_type_conversion_1 (TREE_TYPE (orig_name),
! 						  TREE_TYPE (new_name)));
  
    /* If the pointed-to alias sets are different, these two pointers
       would never have the same memory tag.  In this case, NEW should
Index: gcc/tree-ssa-copyrename.c
===================================================================
*** gcc.orig/tree-ssa-copyrename.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-copyrename.c	2007-06-19 18:03:26.000000000 +0200
*************** copy_rename_partition_coalesce (var_map 
*** 240,246 ****
      }
  
    /* Don't coalesce if the two variables aren't type compatible.  */
!   if (!lang_hooks.types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
      {
        if (debug)
  	fprintf (debug, " : Incompatible types.  No coalesce.\n");
--- 240,248 ----
      }
  
    /* Don't coalesce if the two variables aren't type compatible.  */
!   if (!tree_ssa_useless_type_conversion_1 (TREE_TYPE (root1), TREE_TYPE (root2))
!       || !tree_ssa_useless_type_conversion_1 (TREE_TYPE (root2),
! 					      TREE_TYPE (root1)))
      {
        if (debug)
  	fprintf (debug, " : Incompatible types.  No coalesce.\n");
Index: gcc/tree-ssa-dom.c
===================================================================
*** gcc.orig/tree-ssa-dom.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-dom.c	2007-06-19 18:03:26.000000000 +0200
*************** cprop_operand (tree stmt, use_operand_p 
*** 1680,1686 ****
  	 propagation opportunity.  */
        if (TREE_CODE (val) != SSA_NAME)
  	{
! 	  if (!lang_hooks.types_compatible_p (op_type, val_type))
  	    {
  	      val = fold_convert (TREE_TYPE (op), val);
  	      if (!is_gimple_min_invariant (val))
--- 1680,1686 ----
  	 propagation opportunity.  */
        if (TREE_CODE (val) != SSA_NAME)
  	{
! 	  if (!tree_ssa_useless_type_conversion_1 (op_type, val_type))
  	    {
  	      val = fold_convert (TREE_TYPE (op), val);
  	      if (!is_gimple_min_invariant (val))
*************** 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 ((TREE_TYPE (rhs1) == TREE_TYPE (rhs2)
!        || lang_hooks.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);
--- 2048,2055 ----
  
    /* In case of a collision, both RHS have to be identical and have the
       same VUSE operands.  */
!   if (tree_ssa_useless_type_conversion_1 (TREE_TYPE (rhs1), TREE_TYPE (rhs2))
!       && tree_ssa_useless_type_conversion_1 (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);
Index: gcc/tree-ssa-forwprop.c
===================================================================
*** gcc.orig/tree-ssa-forwprop.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-forwprop.c	2007-06-19 18:03:26.000000000 +0200
*************** forward_propagate_addr_expr_1 (tree name
*** 670,676 ****
        && TREE_CODE (TREE_OPERAND (rhs, 1)) == SSA_NAME
        /* Avoid problems with IVopts creating PLUS_EXPRs with a
  	 different type than their operands.  */
!       && lang_hooks.types_compatible_p (TREE_TYPE (name), TREE_TYPE (rhs)))
      {
        bool res;
        
--- 670,676 ----
        && TREE_CODE (TREE_OPERAND (rhs, 1)) == SSA_NAME
        /* Avoid problems with IVopts creating PLUS_EXPRs with a
  	 different type than their operands.  */
!       && tree_ssa_useless_type_conversion_1 (TREE_TYPE (rhs), TREE_TYPE (name)))
      {
        bool res;
        
Index: gcc/tree-ssa-phiopt.c
===================================================================
*** gcc.orig/tree-ssa-phiopt.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-phiopt.c	2007-06-19 18:03:26.000000000 +0200
*************** conditional_replacement (basic_block con
*** 401,407 ****
    cond = COND_EXPR_COND (last_stmt (cond_bb));
    result = PHI_RESULT (phi);
    if (TREE_CODE (cond) != SSA_NAME
!       && !lang_hooks.types_compatible_p (TREE_TYPE (cond), TREE_TYPE (result)))
      {
        tree tmp;
  
--- 401,408 ----
    cond = COND_EXPR_COND (last_stmt (cond_bb));
    result = PHI_RESULT (phi);
    if (TREE_CODE (cond) != SSA_NAME
!       && !tree_ssa_useless_type_conversion_1 (TREE_TYPE (result),
! 					      TREE_TYPE (cond)))
      {
        tree tmp;
  
*************** conditional_replacement (basic_block con
*** 418,424 ****
    /* If the condition was a naked SSA_NAME and the type is not the
       same as the type of the result, then convert the type of the
       condition.  */
!   if (!lang_hooks.types_compatible_p (TREE_TYPE (cond), TREE_TYPE (result)))
      cond = fold_convert (TREE_TYPE (result), cond);
  
    /* We need to know which is the true edge and which is the false
--- 419,426 ----
    /* If the condition was a naked SSA_NAME and the type is not the
       same as the type of the result, then convert the type of the
       condition.  */
!   if (!tree_ssa_useless_type_conversion_1 (TREE_TYPE (result),
! 					   TREE_TYPE (cond)))
      cond = fold_convert (TREE_TYPE (result), cond);
  
    /* We need to know which is the true edge and which is the false
Index: gcc/tree-ssa-reassoc.c
===================================================================
*** gcc.orig/tree-ssa-reassoc.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-ssa-reassoc.c	2007-06-19 18:03:26.000000000 +0200
*************** optimize_ops_list (enum tree_code opcode
*** 727,734 ****
  
        if (oelm1->rank == 0
  	  && is_gimple_min_invariant (oelm1->op)
! 	  && lang_hooks.types_compatible_p (TREE_TYPE (oelm1->op),
! 					    TREE_TYPE (oelast->op)))
  	{
  	  tree folded = fold_binary (opcode, TREE_TYPE (oelm1->op),
  				     oelm1->op, oelast->op);
--- 727,734 ----
  
        if (oelm1->rank == 0
  	  && is_gimple_min_invariant (oelm1->op)
! 	  && tree_ssa_useless_type_conversion_1 (TREE_TYPE (oelm1->op),
! 						 TREE_TYPE (oelast->op)))
  	{
  	  tree folded = fold_binary (opcode, TREE_TYPE (oelm1->op),
  				     oelm1->op, oelast->op);
Index: gcc/tree-tailcall.c
===================================================================
*** gcc.orig/tree-tailcall.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-tailcall.c	2007-06-19 18:03:26.000000000 +0200
*************** find_tail_calls (basic_block bb, struct 
*** 448,455 ****
  	         equivalent types.  The latter requirement could be relaxed if
  	         we emitted a suitable type conversion statement.  */
  	      if (!is_gimple_reg_type (TREE_TYPE (param))
! 		  || !lang_hooks.types_compatible_p (TREE_TYPE (param),
! 						     TREE_TYPE (arg)))
  		break;
  
  	      /* The parameter should be a real operand, so that phi node
--- 448,455 ----
  	         equivalent types.  The latter requirement could be relaxed if
  	         we emitted a suitable type conversion statement.  */
  	      if (!is_gimple_reg_type (TREE_TYPE (param))
! 		  || !tree_ssa_useless_type_conversion_1 (TREE_TYPE (param),
! 							  TREE_TYPE (arg)))
  		break;
  
  	      /* The parameter should be a real operand, so that phi node
Index: gcc/tree-vect-generic.c
===================================================================
*** gcc.orig/tree-vect-generic.c	2007-06-19 18:03:17.000000000 +0200
--- gcc/tree-vect-generic.c	2007-06-19 18:03:26.000000000 +0200
*************** expand_vector_operations_1 (block_stmt_i
*** 469,475 ****
  
    gcc_assert (code != VEC_LSHIFT_EXPR && code != VEC_RSHIFT_EXPR);
    rhs = expand_vector_operation (bsi, type, compute_type, rhs, code);
!   if (lang_hooks.types_compatible_p (TREE_TYPE (lhs), TREE_TYPE (rhs)))
      *p_rhs = rhs;
    else
      *p_rhs = gimplify_build1 (bsi, VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs);
--- 469,475 ----
  
    gcc_assert (code != VEC_LSHIFT_EXPR && code != VEC_RSHIFT_EXPR);
    rhs = expand_vector_operation (bsi, type, compute_type, rhs, code);
!   if (tree_ssa_useless_type_conversion_1 (TREE_TYPE (lhs), TREE_TYPE (rhs)))
      *p_rhs = rhs;
    else
      *p_rhs = gimplify_build1 (bsi, VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs);
Index: gcc/gimplify.c
===================================================================
*** gcc.orig/gimplify.c	2007-06-19 18:00:51.000000000 +0200
--- gcc/gimplify.c	2007-06-20 11:32:30.000000000 +0200
*************** canonicalize_addr_expr (tree *expr_p)
*** 1588,1600 ****
    /* Both cast and addr_expr types should address the same object type.  */
    dctype = TREE_TYPE (ctype);
    ddatype = TREE_TYPE (datype);
!   if (!lang_hooks.types_compatible_p (ddatype, dctype))
      return;
  
    /* The addr_expr and the object type should match.  */
    obj_expr = TREE_OPERAND (addr_expr, 0);
    otype = TREE_TYPE (obj_expr);
!   if (!lang_hooks.types_compatible_p (otype, datype))
      return;
  
    /* The lower bound and element sizes must be constant.  */
--- 1588,1600 ----
    /* Both cast and addr_expr types should address the same object type.  */
    dctype = TREE_TYPE (ctype);
    ddatype = TREE_TYPE (datype);
!   if (!tree_ssa_useless_type_conversion_1 (dctype, ddatype))
      return;
  
    /* The addr_expr and the object type should match.  */
    obj_expr = TREE_OPERAND (addr_expr, 0);
    otype = TREE_TYPE (obj_expr);
!   if (!tree_ssa_useless_type_conversion_1 (datype, otype))
      return;
  
    /* The lower bound and element sizes must be constant.  */
*************** fold_indirect_ref_rhs (tree t)
*** 3246,3256 ****
        tree op = TREE_OPERAND (sub, 0);
        tree optype = TREE_TYPE (op);
        /* *&p => p */
!       if (lang_hooks.types_compatible_p (type, optype))
          return op;
        /* *(foo *)&fooarray => fooarray[0] */
        else if (TREE_CODE (optype) == ARRAY_TYPE
! 	       && lang_hooks.types_compatible_p (type, TREE_TYPE (optype)))
         {
           tree type_domain = TYPE_DOMAIN (optype);
           tree min_val = size_zero_node;
--- 3246,3256 ----
        tree op = TREE_OPERAND (sub, 0);
        tree optype = TREE_TYPE (op);
        /* *&p => p */
!       if (tree_ssa_useless_type_conversion_1 (type, optype))
          return op;
        /* *(foo *)&fooarray => fooarray[0] */
        else if (TREE_CODE (optype) == ARRAY_TYPE
! 	       && tree_ssa_useless_type_conversion_1 (type, TREE_TYPE (optype)))
         {
           tree type_domain = TYPE_DOMAIN (optype);
           tree min_val = size_zero_node;
*************** fold_indirect_ref_rhs (tree t)
*** 3262,3268 ****
  
    /* *(foo *)fooarrptr => (*fooarrptr)[0] */
    if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
!       && lang_hooks.types_compatible_p (type, TREE_TYPE (TREE_TYPE (subtype))))
      {
        tree type_domain;
        tree min_val = size_zero_node;
--- 3262,3268 ----
  
    /* *(foo *)fooarrptr => (*fooarrptr)[0] */
    if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
!       && tree_ssa_useless_type_conversion_1 (type, TREE_TYPE (TREE_TYPE (subtype))))
      {
        tree type_domain;
        tree min_val = size_zero_node;
*************** gimplify_addr_expr (tree *expr_p, tree *
*** 3916,3929 ****
  	tree t_expr = TREE_TYPE (expr);
  	tree t_op00 = TREE_TYPE (op00);
  
!         if (!lang_hooks.types_compatible_p (t_expr, t_op00))
  	  {
  #ifdef ENABLE_CHECKING
  	    tree t_op0 = TREE_TYPE (op0);
  	    gcc_assert (POINTER_TYPE_P (t_expr)
! 			&& cpt_same_type (TREE_CODE (t_op0) == ARRAY_TYPE
! 					  ? TREE_TYPE (t_op0) : t_op0,
! 					  TREE_TYPE (t_expr))
  			&& POINTER_TYPE_P (t_op00)
  			&& cpt_same_type (t_op0, TREE_TYPE (t_op00)));
  #endif
--- 3916,3929 ----
  	tree t_expr = TREE_TYPE (expr);
  	tree t_op00 = TREE_TYPE (op00);
  
!         if (!tree_ssa_useless_type_conversion_1 (t_expr, t_op00))
  	  {
  #ifdef ENABLE_CHECKING
  	    tree t_op0 = TREE_TYPE (op0);
  	    gcc_assert (POINTER_TYPE_P (t_expr)
! 			&& cpt_same_type (TREE_TYPE (t_expr),
! 					  TREE_CODE (t_op0) == ARRAY_TYPE
! 					  ? TREE_TYPE (t_op0) : t_op0)
  			&& POINTER_TYPE_P (t_op00)
  			&& cpt_same_type (t_op0, TREE_TYPE (t_op00)));
  #endif
*************** gimplify_one_sizepos (tree *expr_p, tree
*** 6300,6306 ****
  static bool
  cpt_same_type (tree a, tree b)
  {
!   if (lang_hooks.types_compatible_p (a, b))
      return true;
  
    /* ??? The C++ FE decomposes METHOD_TYPES to FUNCTION_TYPES and doesn't
--- 6300,6306 ----
  static bool
  cpt_same_type (tree a, tree b)
  {
!   if (tree_ssa_useless_type_conversion_1 (a, b))
      return true;
  
    /* ??? The C++ FE decomposes METHOD_TYPES to FUNCTION_TYPES and doesn't
*************** check_pointer_types_r (tree *tp, int *wa
*** 6351,6357 ****
        ptype = TREE_TYPE (t);
        otype = TREE_TYPE (TREE_OPERAND (t, 0));
        dtype = TREE_TYPE (ptype);
!       if (!cpt_same_type (otype, dtype))
  	{
  	  /* &array is allowed to produce a pointer to the element, rather than
  	     a pointer to the array type.  We must allow this in order to
--- 6351,6357 ----
        ptype = TREE_TYPE (t);
        otype = TREE_TYPE (TREE_OPERAND (t, 0));
        dtype = TREE_TYPE (ptype);
!       if (!cpt_same_type (dtype, otype))
  	{
  	  /* &array is allowed to produce a pointer to the element, rather than
  	     a pointer to the array type.  We must allow this in order to
*************** check_pointer_types_r (tree *tp, int *wa
*** 6359,6365 ****
  	     pointer to the element type.  */
  	  gcc_assert (TREE_CODE (otype) == ARRAY_TYPE
  		      && POINTER_TYPE_P (ptype)
! 		      && cpt_same_type (TREE_TYPE (otype), dtype));
  	  break;
  	}
        break;
--- 6359,6365 ----
  	     pointer to the element type.  */
  	  gcc_assert (TREE_CODE (otype) == ARRAY_TYPE
  		      && POINTER_TYPE_P (ptype)
! 		      && cpt_same_type (dtype, TREE_TYPE (otype)));
  	  break;
  	}
        break;
Index: gcc/fold-const.c
===================================================================
*** gcc.orig/fold-const.c	2007-06-19 18:00:51.000000000 +0200
--- gcc/fold-const.c	2007-06-20 13:18:18.000000000 +0200
*************** fold_convert (tree type, tree arg)
*** 2228,2236 ****
        || TREE_CODE (orig) == ERROR_MARK)
      return error_mark_node;
  
!   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig)
!       || lang_hooks.types_compatible_p (TYPE_MAIN_VARIANT (type),
! 					TYPE_MAIN_VARIANT (orig)))
      return fold_build1 (NOP_EXPR, type, arg);
  
    switch (TREE_CODE (type))
--- 2228,2234 ----
        || TREE_CODE (orig) == ERROR_MARK)
      return error_mark_node;
  
!   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig))
      return fold_build1 (NOP_EXPR, type, arg);
  
    switch (TREE_CODE (type))
Index: gcc/tree-vn.c
===================================================================
*** gcc.orig/tree-vn.c	2007-02-20 21:08:26.000000000 +0100
--- gcc/tree-vn.c	2007-06-20 11:44:58.000000000 +0200
*************** expressions_equal_p (tree e1, tree e2)
*** 123,129 ****
  
      }
    else if (TREE_CODE (e1) == TREE_CODE (e2) 
! 	   && (te1 == te2 || lang_hooks.types_compatible_p (te1, te2))
  	   && operand_equal_p (e1, e2, OEP_PURE_SAME))
      return true;
  
--- 123,131 ----
  
      }
    else if (TREE_CODE (e1) == TREE_CODE (e2) 
! 	   && (te1 == te2
! 	       || (tree_ssa_useless_type_conversion_1 (te1, te2)
! 		   && tree_ssa_useless_type_conversion_1 (te2, te1)))
  	   && operand_equal_p (e1, e2, OEP_PURE_SAME))
      return true;
  
Index: gcc/tree.c
===================================================================
*** gcc.orig/tree.c	2007-06-13 12:12:07.000000000 +0200
--- gcc/tree.c	2007-06-20 11:44:12.000000000 +0200
*************** fields_compatible_p (tree f1, tree f2)
*** 7692,7698 ****
                          DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
      return false;
  
!   if (!lang_hooks.types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2)))
      return false;
  
    return true;
--- 7692,7699 ----
                          DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
      return false;
  
!   if (!tree_ssa_useless_type_conversion_1 (TREE_TYPE (f1), TREE_TYPE (f2))
!       || !tree_ssa_useless_type_conversion_1 (TREE_TYPE (f2), TREE_TYPE (f1)))
      return false;
  
    return true;


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