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] Fix PR tree-optimization/18184 (take 3)


Hello,

this is the third attempt to fix PR 18184 by preventing removal
of type conversions between pointers differing in their mode.

The only difference to take 2 is that the patch is adapted to the
recent move of cxx_types_compatible_p to cp-objcp-common.c.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
OK for mainline?

Bye,
Ulrich


ChangeLog:

	PR tree-optimization/18184
	* c-typeck.c (comptypes): Do not treat pointers of different
	modes or alias-all flags as equivalent.
	* tree-ssa.c (tree_ssa_useless_type_conversion_1): Likewise.

cp/ChangeLog:
	
	PR tree-optimization/18184
	* cp-objcp-common.c (cxx_types_compatible_p): Do not treat pointers
	of different modes or alias-all flags as equivalent.
	* cp-typeck.c (comptypes): Likewise.

Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.394
diff -c -p -r1.394 c-typeck.c
*** gcc/c-typeck.c	31 Oct 2004 06:17:49 -0000	1.394
--- gcc/c-typeck.c	4 Nov 2004 00:27:44 -0000
*************** comptypes (tree type1, tree type2)
*** 659,664 ****
--- 659,668 ----
  	   protocol qualifiers may be involved.  */
        if (c_dialect_objc () && (val = objc_comptypes (t1, t2, 0)) >= 0)
  	break;
+       /* Do not remove mode or aliasing information.  */
+       if (TYPE_MODE (t1) != TYPE_MODE (t2)
+ 	  || TYPE_REF_CAN_ALIAS_ALL (t1) != TYPE_REF_CAN_ALIAS_ALL (t2))
+ 	break;
        val = (TREE_TYPE (t1) == TREE_TYPE (t2)
  	     ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2)));
        break;
Index: gcc/tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.54
diff -c -p -r2.54 tree-ssa.c
*** gcc/tree-ssa.c	2 Nov 2004 16:38:12 -0000	2.54
--- gcc/tree-ssa.c	4 Nov 2004 00:27:46 -0000
*************** tree_ssa_useless_type_conversion_1 (tree
*** 834,839 ****
--- 834,842 ----
       implement the ABI.  */
    else if (POINTER_TYPE_P (inner_type)
             && POINTER_TYPE_P (outer_type)
+ 	   && TYPE_MODE (inner_type) == TYPE_MODE (outer_type)
+ 	   && TYPE_REF_CAN_ALIAS_ALL (inner_type)
+ 	      == TYPE_REF_CAN_ALIAS_ALL (outer_type)
  	   && TREE_CODE (TREE_TYPE (outer_type)) == VOID_TYPE)
      return true;
  
*************** tree_ssa_useless_type_conversion_1 (tree
*** 841,846 ****
--- 844,852 ----
       so strip conversions that just switch between them.  */
    else if (POINTER_TYPE_P (inner_type)
             && POINTER_TYPE_P (outer_type)
+ 	   && TYPE_MODE (inner_type) == TYPE_MODE (outer_type)
+ 	   && TYPE_REF_CAN_ALIAS_ALL (inner_type)
+ 	      == TYPE_REF_CAN_ALIAS_ALL (outer_type)
             && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
  					     TREE_TYPE (outer_type)))
      return true;
Index: gcc/cp/cp-objcp-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-objcp-common.c,v
retrieving revision 1.3
diff -c -p -r1.3 cp-objcp-common.c
*** gcc/cp/cp-objcp-common.c	2 Nov 2004 20:29:21 -0000	1.3
--- gcc/cp/cp-objcp-common.c	4 Nov 2004 00:27:48 -0000
*************** cxx_types_compatible_p (tree x, tree y)
*** 162,167 ****
--- 162,169 ----
       interchangeable.  FIXME should we try to replace all references with
       pointers?  */
    if (POINTER_TYPE_P (x) && POINTER_TYPE_P (y)
+       && TYPE_MODE (x) == TYPE_MODE (y)
+       && TYPE_REF_CAN_ALIAS_ALL (x) == TYPE_REF_CAN_ALIAS_ALL (y)
        && same_type_p (TREE_TYPE (x), TREE_TYPE (y)))
      return 1;
  
Index: gcc/cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.592
diff -c -p -r1.592 typeck.c
*** gcc/cp/typeck.c	3 Nov 2004 02:48:39 -0000	1.592
--- gcc/cp/typeck.c	4 Nov 2004 00:27:49 -0000
*************** comptypes (tree t1, tree t2, int strict)
*** 1030,1040 ****
        if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2),
  		      strict & ~COMPARE_REDECLARATION))
  	return false;
!       /* Fall through.  */
  
      case POINTER_TYPE:
      case REFERENCE_TYPE:
!       return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
  
      case METHOD_TYPE:
      case FUNCTION_TYPE:
--- 1030,1042 ----
        if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2),
  		      strict & ~COMPARE_REDECLARATION))
  	return false;
!       return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
  
      case POINTER_TYPE:
      case REFERENCE_TYPE:
!       return TYPE_MODE (t1) == TYPE_MODE (t2)
! 	     && TYPE_REF_CAN_ALIAS_ALL (t1) == TYPE_REF_CAN_ALIAS_ALL (t2)
! 	     && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
  
      case METHOD_TYPE:
      case FUNCTION_TYPE:
-- 
  Dr. Ulrich Weigand
  Linux on zSeries Development
  Ulrich.Weigand@de.ibm.com


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