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] Remove middle-end callers to lang_hooks.types_compatible_p


This patch removes middle-end calls to lang_hooks.types_compatible_p
in favor of useless_type_conversion_p (which was renamed from
tree_ssa_useless_type_conversion_1) where appropriate or the new
predicate types_compatible_p (which is implemented in terms of
useless_type_conversion_p (T1, T2) && useless_type_conversion_p (T2, T1)).

Re-bootstrapped and re-tested on i686-pc-linux-gnu, applied to mainline.

Richard.


2007-07-02  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (types_compatible_p): Declare.
	* tree-ssa.c (types_compatible_p): New function.
	* ipa-type-escape.c (discover_unique_type): Use
	types_compatible_p instead of lang_hooks.types_compatible_p.
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Likewise.
	* tree-vn.c (expressions_equal_p): Likewise.
	* tree.c (fields_compatible_p): Likewise.
	* tree-ssa-dom.c (avail_expr_eq): Likewise.
	(cprop_operand): Use useless_type_conversion_p 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-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.
	* 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 and checking for
	error_mark_node.  Convert only if the conversion is necessary.


Index: tree-tailcall.c
===================================================================
*** tree-tailcall.c	(revision 126193)
--- tree-tailcall.c	(working copy)
*************** 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))
! 		  || !useless_type_conversion_p (TREE_TYPE (param),
! 					        TREE_TYPE (arg)))
  		break;
  
  	      /* The parameter should be a real operand, so that phi node
Index: tree.c
===================================================================
*** tree.c	(revision 126194)
--- tree.c	(working copy)
*************** fields_compatible_p (tree f1, tree f2)
*** 7714,7720 ****
                          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;
--- 7714,7720 ----
                          DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
      return false;
  
!   if (!types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2)))
      return false;
  
    return true;
Index: fold-const.c
===================================================================
*** fold-const.c	(revision 126193)
--- fold-const.c	(working copy)
*************** fold_convert (tree type, tree arg)
*** 2262,2270 ****
        || 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))
--- 2262,2268 ----
        || 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: tree-ssa-copyrename.c
===================================================================
*** tree-ssa-copyrename.c	(revision 126193)
--- tree-ssa-copyrename.c	(working copy)
*************** 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,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: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c	(revision 126194)
--- tree-ssa-ccp.c	(working copy)
*************** maybe_fold_offset_to_array_ref (tree bas
*** 1575,1581 ****
    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.  */
--- 1575,1581 ----
    if (TREE_CODE (array_type) != ARRAY_TYPE)
      return NULL_TREE;
    elt_type = TREE_TYPE (array_type);
!   if (!useless_type_conversion_p (orig_type, elt_type))
      return NULL_TREE;
  
    /* Use signed size type for intermediate computation on the index.  */
*************** maybe_fold_offset_to_component_ref (tree
*** 1666,1672 ****
      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;
--- 1666,1672 ----
      return NULL_TREE;
  
    /* Short-circuit silly cases.  */
!   if (useless_type_conversion_p (record_type, orig_type))
      return NULL_TREE;
  
    tail_array_field = NULL_TREE;
*************** maybe_fold_offset_to_component_ref (tree
*** 1704,1710 ****
        /* 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);
--- 1704,1710 ----
        /* Here we exactly match the offset being checked.  If the types match,
  	 then we can return that field.  */
        if (cmp == 0
! 	  && useless_type_conversion_p (orig_type, field_type))
  	{
  	  if (base_is_ptr)
  	    base = build1 (INDIRECT_REF, record_type, base);
*************** maybe_fold_offset_to_reference (tree bas
*** 1809,1815 ****
  					  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);
--- 1809,1815 ----
  					  sub_offset / BITS_PER_UNIT), 1);
  	    }
  	}
!       if (useless_type_conversion_p (orig_type, TREE_TYPE (base))
  	  && integer_zerop (offset))
  	return base;
        type = TREE_TYPE (base);
Index: tree-ssa-dom.c
===================================================================
*** tree-ssa-dom.c	(revision 126194)
--- tree-ssa-dom.c	(working copy)
*************** 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 (!useless_type_conversion_p (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,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: tree-nrv.c
===================================================================
*** tree-nrv.c	(revision 126193)
--- tree-nrv.c	(working copy)
*************** 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)
! 		  || !useless_type_conversion_p (result_type,
! 					        TREE_TYPE (found)))
  		return 0;
  	    }
  	  else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
Index: tree-vn.c
===================================================================
*** tree-vn.c	(revision 126193)
--- tree-vn.c	(working copy)
*************** expressions_equal_p (tree e1, tree e2)
*** 84,90 ****
  
      }
    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;
  
--- 84,91 ----
  
      }
    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: ipa-type-escape.c
===================================================================
*** ipa-type-escape.c	(revision 126193)
--- ipa-type-escape.c	(working copy)
*************** 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,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: gimplify.c
===================================================================
*** gimplify.c	(revision 126193)
--- gimplify.c	(working copy)
*************** canonicalize_addr_expr (tree *expr_p)
*** 1599,1611 ****
    /* 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.  */
--- 1599,1611 ----
    /* Both cast and addr_expr types should address the same object type.  */
    dctype = TREE_TYPE (ctype);
    ddatype = TREE_TYPE (datype);
!   if (!useless_type_conversion_p (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 (!useless_type_conversion_p (datype, otype))
      return;
  
    /* The lower bound and element sizes must be constant.  */
*************** fold_indirect_ref_rhs (tree t)
*** 3304,3314 ****
        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;
--- 3304,3314 ----
        tree op = TREE_OPERAND (sub, 0);
        tree optype = TREE_TYPE (op);
        /* *&p => p */
!       if (useless_type_conversion_p (type, optype))
          return op;
        /* *(foo *)&fooarray => fooarray[0] */
        else if (TREE_CODE (optype) == ARRAY_TYPE
! 	       && useless_type_conversion_p (type, TREE_TYPE (optype)))
         {
           tree type_domain = TYPE_DOMAIN (optype);
           tree min_val = size_zero_node;
*************** fold_indirect_ref_rhs (tree t)
*** 3320,3326 ****
  
    /* *(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;
--- 3320,3326 ----
  
    /* *(foo *)fooarrptr => (*fooarrptr)[0] */
    if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
!       && useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (subtype))))
      {
        tree type_domain;
        tree min_val = size_zero_node;
*************** gimplify_addr_expr (tree *expr_p, tree *
*** 3974,3987 ****
  	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
--- 3974,3988 ----
  	tree t_expr = TREE_TYPE (expr);
  	tree t_op00 = TREE_TYPE (op00);
  
!         if (!useless_type_conversion_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_TYPE (t_expr), t_op0)
! 			    || (TREE_CODE (t_op0) == ARRAY_TYPE
! 				&& cpt_same_type (TREE_TYPE (t_expr),
! 						  TREE_TYPE (t_op0))))
  			&& POINTER_TYPE_P (t_op00)
  			&& cpt_same_type (t_op0, TREE_TYPE (t_op00)));
  #endif
*************** gimplify_one_sizepos (tree *expr_p, tree
*** 6385,6391 ****
  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
--- 6386,6392 ----
  static bool
  cpt_same_type (tree a, tree b)
  {
!   if (useless_type_conversion_p (a, b))
      return true;
  
    /* ??? The C++ FE decomposes METHOD_TYPES to FUNCTION_TYPES and doesn't
*************** check_pointer_types_r (tree *tp, int *wa
*** 6436,6442 ****
        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
--- 6437,6443 ----
        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
*** 6444,6450 ****
  	     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;
--- 6445,6451 ----
  	     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: tree-ssa-phiopt.c
===================================================================
*** tree-ssa-phiopt.c	(revision 126193)
--- tree-ssa-phiopt.c	(working copy)
*************** 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,407 ----
    cond = COND_EXPR_COND (last_stmt (cond_bb));
    result = PHI_RESULT (phi);
    if (TREE_CODE (cond) != SSA_NAME
!       && !useless_type_conversion_p (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
--- 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 (!useless_type_conversion_p (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: tree-ssa-copy.c
===================================================================
*** tree-ssa-copy.c	(revision 126194)
--- tree-ssa-copy.c	(working copy)
*************** 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 (!useless_type_conversion_p (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 (useless_type_conversion_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
Index: tree-ssa-forwprop.c
===================================================================
*** tree-ssa-forwprop.c	(revision 126194)
--- tree-ssa-forwprop.c	(working copy)
*************** 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.  */
!       && useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (name)))
      {
        bool res;
        
Index: tree-ssa.c
===================================================================
*** tree-ssa.c	(revision 126194)
--- tree-ssa.c	(working copy)
*************** useless_type_conversion_p (tree outer_ty
*** 971,976 ****
--- 971,987 ----
    return false;
  }
  
+ /* Return true if a conversion from either type of TYPE1 and TYPE2
+    to the other is not required.  Otherwise return false.  */
+ 
+ bool
+ types_compatible_p (tree type1, tree type2)
+ {
+   return (type1 == type2
+ 	  || (useless_type_conversion_p (type1, type2)
+ 	      && useless_type_conversion_p (type2, type1)));
+ }
+ 
  /* Return true if EXPR is a useless type conversion, otherwise return
     false.  */
  
Index: tree-inline.c
===================================================================
*** tree-inline.c	(revision 126193)
--- tree-inline.c	(working copy)
*************** setup_one_parameter (copy_body_data *id,
*** 1278,1287 ****
    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);
  
    /* If the parameter is never assigned to, has no SSA_NAMEs created,
       we may not need to create a new variable here at all.  Instead, we may
       be able to just use the argument value.  */
--- 1278,1292 ----
    tree init_stmt;
    tree var;
    tree var_sub;
!   tree rhs = value;
    tree def = (gimple_in_ssa_p (cfun)
  	      ? gimple_default_def (id->src_cfun, p) : NULL);
  
+   if (value
+       && value != error_mark_node
+       && !useless_type_conversion_p (TREE_TYPE (p), TREE_TYPE (value)))
+     rhs = fold_build1 (NOP_EXPR, TREE_TYPE (p), value);
+ 
    /* If the parameter is never assigned to, has no SSA_NAMEs created,
       we may not need to create a new variable here at all.  Instead, we may
       be able to just use the argument value.  */
*************** 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
--- 1300,1307 ----
  	 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)
! 	  && useless_type_conversion_p (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 
*** 1573,1579 ****
        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
--- 1579,1585 ----
        bool use_it = false;
  
        /* We can't use MODIFY_DEST if there's type promotion involved.  */
!       if (!useless_type_conversion_p (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 
*** 1637,1643 ****
    /* 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);
--- 1643,1649 ----
    /* Build the use expr.  If the return type of the function was
       promoted, convert it back to the expected type.  */
    use = var;
!   if (!useless_type_conversion_p (caller_type, TREE_TYPE (var)))
      use = fold_convert (caller_type, var);
      
    STRIP_USELESS_TYPE_CONVERSION (use);
Index: tree-vect-generic.c
===================================================================
*** tree-vect-generic.c	(revision 126193)
--- tree-vect-generic.c	(working copy)
*************** 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 (useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs)))
      *p_rhs = rhs;
    else
      *p_rhs = gimplify_build1 (bsi, VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs);
Index: tree-flow.h
===================================================================
*** tree-flow.h	(revision 126194)
--- tree-flow.h	(working copy)
*************** extern edge ssa_redirect_edge (edge, bas
*** 869,874 ****
--- 869,875 ----
  extern void flush_pending_stmts (edge);
  extern bool tree_ssa_useless_type_conversion (tree);
  extern bool useless_type_conversion_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: tree-ssa-reassoc.c
===================================================================
*** tree-ssa-reassoc.c	(revision 126193)
--- tree-ssa-reassoc.c	(working copy)
*************** 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)
! 	  && useless_type_conversion_p (TREE_TYPE (oelm1->op),
! 				       TREE_TYPE (oelast->op)))
  	{
  	  tree folded = fold_binary (opcode, TREE_TYPE (oelm1->op),
  				     oelm1->op, oelast->op);


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