------- Comment #6 from ebotcazou at gcc dot gnu dot org  2010-02-26 17:46 
-------
> We might be able to save the day with the help of TYPE_CANONICAL in this case
> since the size is fixed.

TYPE_CANONICAL is too strong, it will cause useless_type_conversion_p to return
true for conversions between type and subtypes and, even with fixed size, these
conversions aren't useless.  So we need this for Ada:

Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c    (revision 156989)
+++ tree-ssa-alias.c    (working copy)
@@ -544,13 +544,15 @@ same_type_for_tbaa (tree type1, tree typ
       && TREE_CODE (type2) == ARRAY_TYPE)
     return -1;

-  /* In Ada, an lvalue of unconstrained type can be used to access an object
-     of one of its constrained subtypes, for example when a function with an
-     unconstrained parameter passed by reference is called on a constrained
-     object and inlined.  In this case, the types have the same alias set.  */
-  if (TYPE_SIZE (type1) && TYPE_SIZE (type2)
-      && TREE_CONSTANT (TYPE_SIZE (type1)) != TREE_CONSTANT (TYPE_SIZE
(type2))
-      && get_alias_set (type1) == get_alias_set (type2))
+  /* ??? In Ada, an lvalue of an unconstrained type can be used to access an
+     object of one of its constrained subtypes, e.g. when a function with an
+     unconstrained parameter passed by reference is called on an object and
+     inlined.  But, even in the case of a fixed size, type and subtypes are
+     not equivalent enough as to share the same TYPE_CANONICAL, since this
+     would mean that conversions between them are useless, whereas they are
+     not (e.g. type and subtypes can have different modes).  So, in the end,
+     they are only guaranteed to have the same alias set.  */
+  if (get_alias_set (type1) == get_alias_set (type2))
     return -1;

   /* The types are known to be not equal.  */


The change doesn't introduce any regressions in the C/C++ testsuite on x86 so
it might not be a big pessimization.

Richard, what do you think?


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43096

Reply via email to