]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/18184 (Tree optimizers ignore pointer modes)
authorUlrich Weigand <uweigand@de.ibm.com>
Thu, 4 Nov 2004 20:11:13 +0000 (20:11 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Thu, 4 Nov 2004 20:11:13 +0000 (20:11 +0000)
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.
* typeck.c (comptypes): Likewise.

From-SVN: r90078

gcc/ChangeLog
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/cp/typeck.c
gcc/tree-ssa.c

index 83c68ddd4f92f7d443a8ac24ffc804d86c651a6b..23123f29e97c437727be07330aa0a914217e47d3 100644 (file)
@@ -1,3 +1,10 @@
+2004-11-04  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       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.
+
 2004-11-04  Joseph S. Myers  <joseph@codesourcery.com>
 
        * doc/gty.texi, doc/makefile.texi, doc/sourcebuild.texi: Don't
index 728e768a7f63ee23218a60b055353c6d830af7e5..723bd5affc11902592a850511b32859046041a5b 100644 (file)
@@ -659,6 +659,10 @@ comptypes (tree type1, tree type2)
           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 a531bf00c3503fba286672ffbbcf2e942091e0d2..73fba486a0e22c7eae8e33e3773c99b891cba3c7 100644 (file)
@@ -1,3 +1,10 @@
+2004-11-04  Ulrich Weigand  <uweigand@de.ibm.com>
+       
+       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.
+       * typeck.c (comptypes): Likewise.
+
 2004-11-04  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        DR 49, 100
index a58549b7326894c3921813eb2be7bf37e663c01e..9938b98f535e6723945d2e4a8a6b07280d1311c8 100644 (file)
@@ -162,6 +162,8 @@ cxx_types_compatible_p (tree x, tree y)
      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 325dd5682f227b04d98c0a960931ad70763f5a80..384b1d13bd6174b22a72e6dcfad90d1e82754dd0 100644 (file)
@@ -1030,11 +1030,13 @@ comptypes (tree t1, tree t2, int strict)
       if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2),
                      strict & ~COMPARE_REDECLARATION))
        return false;
-      /* Fall through.  */
+      return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
 
     case POINTER_TYPE:
     case REFERENCE_TYPE:
-      return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+      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:
index 8002565d3437d835e368306d106fe1758afeb5f0..0e15eee2edf06d84c13ee804700b6e377fde49eb 100644 (file)
@@ -834,6 +834,9 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type)
      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;
 
@@ -841,6 +844,9 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type)
      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;