This is the mail archive of the gcc@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: attribute((mode)) pointers broken by STRIP_USELESS_TYPE_CONVERSION


Andrew Pinski wrote:

> Try removing the following condition:
>    /* Pointers and references are equivalent once we get to GENERIC,
>       so strip conversions that just switch between them.  */
>    else if (POINTER_TYPE_P (inner_type)
>             && POINTER_TYPE_P (outer_type)
>             && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
>                                               TREE_TYPE (outer_type)))
>      return true;
> 
> Note you might also have to fix the C++ front-end's types_compatible_p
> also, not to ignore modes.

I've not removed the condition, but simply added a test for equal modes
here and in the various types_compatible routines, see patch below.

That does indeed fix the problem for C.

For C++, there appears to be a completely different problem -- I do not
get an ICE either with or without my patch, but it appears the mode
attribute is simply completely ignored and the SImode pointer is always
accessed as DImode!  Any idea what could cause this?

Bye,
Ulrich


Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.392
diff -c -p -r1.392 c-typeck.c
*** gcc/c-typeck.c	17 Oct 2004 22:01:19 -0000	1.392
--- gcc/c-typeck.c	20 Oct 2004 15:19:06 -0000
*************** comptypes (tree type1, tree type2)
*** 659,664 ****
--- 659,667 ----
  	   protocol qualifiers may be involved.  */
        if (c_dialect_objc () && (val = objc_comptypes (t1, t2, 0)) >= 0)
  	break;
+       /* Do not remove __attribute__ ((mode)) conversions.  */
+       if (TYPE_MODE (t1) != TYPE_MODE (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.49
diff -c -p -r2.49 tree-ssa.c
*** gcc/tree-ssa.c	18 Oct 2004 18:01:10 -0000	2.49
--- gcc/tree-ssa.c	20 Oct 2004 15:19:07 -0000
*************** tree_ssa_useless_type_conversion_1 (tree
*** 814,819 ****
--- 814,820 ----
       implement the ABI.  */
    else if (POINTER_TYPE_P (inner_type)
             && POINTER_TYPE_P (outer_type)
+ 	   && TYPE_MODE (inner_type) == TYPE_MODE (outer_type)
  	   && TREE_CODE (TREE_TYPE (outer_type)) == VOID_TYPE)
      return true;
  
*************** tree_ssa_useless_type_conversion_1 (tree
*** 821,826 ****
--- 822,828 ----
       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)
             && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
  					     TREE_TYPE (outer_type)))
      return true;
Index: gcc/cp/cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.95
diff -c -p -r1.95 cp-lang.c
*** gcc/cp/cp-lang.c	22 Sep 2004 06:11:20 -0000	1.95
--- gcc/cp/cp-lang.c	20 Oct 2004 15:19:08 -0000
*************** static int cxx_types_compatible_p (tree 
*** 112,117 ****
--- 112,118 ----
       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)
        && 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.583
diff -c -p -r1.583 typeck.c
*** gcc/cp/typeck.c	18 Oct 2004 17:21:29 -0000	1.583
--- gcc/cp/typeck.c	20 Oct 2004 15:19:09 -0000
*************** comptypes (tree t1, tree t2, int strict)
*** 1034,1040 ****
  
      case POINTER_TYPE:
      case REFERENCE_TYPE:
!       return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
  
      case METHOD_TYPE:
      case FUNCTION_TYPE:
--- 1034,1041 ----
  
      case POINTER_TYPE:
      case REFERENCE_TYPE:
!       return TYPE_MODE (t1) == TYPE_MODE (t2)
! 	     && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
  
      case METHOD_TYPE:
      case FUNCTION_TYPE:


-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


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