Commit 106f5de5 by Ulrich Weigand Committed by Ulrich Weigand

re PR tree-optimization/18184 (Tree optimizers ignore pointer modes)

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
parent ac8b3d9d
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> 2004-11-04 Joseph S. Myers <joseph@codesourcery.com>
* doc/gty.texi, doc/makefile.texi, doc/sourcebuild.texi: Don't * doc/gty.texi, doc/makefile.texi, doc/sourcebuild.texi: Don't
......
...@@ -659,6 +659,10 @@ comptypes (tree type1, tree type2) ...@@ -659,6 +659,10 @@ comptypes (tree type1, tree type2)
protocol qualifiers may be involved. */ protocol qualifiers may be involved. */
if (c_dialect_objc () && (val = objc_comptypes (t1, t2, 0)) >= 0) if (c_dialect_objc () && (val = objc_comptypes (t1, t2, 0)) >= 0)
break; 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) val = (TREE_TYPE (t1) == TREE_TYPE (t2)
? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2))); ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2)));
break; break;
......
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> 2004-11-04 Giovanni Bajo <giovannibajo@gcc.gnu.org>
DR 49, 100 DR 49, 100
......
...@@ -162,6 +162,8 @@ cxx_types_compatible_p (tree x, tree y) ...@@ -162,6 +162,8 @@ cxx_types_compatible_p (tree x, tree y)
interchangeable. FIXME should we try to replace all references with interchangeable. FIXME should we try to replace all references with
pointers? */ pointers? */
if (POINTER_TYPE_P (x) && POINTER_TYPE_P (y) 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))) && same_type_p (TREE_TYPE (x), TREE_TYPE (y)))
return 1; return 1;
......
...@@ -1030,11 +1030,13 @@ comptypes (tree t1, tree t2, int strict) ...@@ -1030,11 +1030,13 @@ comptypes (tree t1, tree t2, int strict)
if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2), if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2),
strict & ~COMPARE_REDECLARATION)) strict & ~COMPARE_REDECLARATION))
return false; return false;
/* Fall through. */ return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
case POINTER_TYPE: case POINTER_TYPE:
case REFERENCE_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 METHOD_TYPE:
case FUNCTION_TYPE: case FUNCTION_TYPE:
......
...@@ -834,6 +834,9 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type) ...@@ -834,6 +834,9 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type)
implement the ABI. */ implement the ABI. */
else if (POINTER_TYPE_P (inner_type) else if (POINTER_TYPE_P (inner_type)
&& POINTER_TYPE_P (outer_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) && TREE_CODE (TREE_TYPE (outer_type)) == VOID_TYPE)
return true; return true;
...@@ -841,6 +844,9 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type) ...@@ -841,6 +844,9 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type)
so strip conversions that just switch between them. */ so strip conversions that just switch between them. */
else if (POINTER_TYPE_P (inner_type) else if (POINTER_TYPE_P (inner_type)
&& POINTER_TYPE_P (outer_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), && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
TREE_TYPE (outer_type))) TREE_TYPE (outer_type)))
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment