[RFA/dwarf-2] Avoid unnecessary subrange_type (3/3)

Jason Merrill jason@redhat.com
Wed Mar 17 08:40:00 GMT 2004


Two things.

1) Why do the affected types look like subrange types to begin with?  Why
   do they have a TREE_TYPE?

On Wed, 17 Mar 2004 00:00:59 -0800, Joel Brobecker <brobecker@gnat.com> wrote:

> --- dwarf2out.c.1.reorg	2004-03-16 23:24:05.000000000 -0800
> +++ dwarf2out.c	2004-03-16 21:55:36.000000000 -0800
> @@ -8012,6 +8012,33 @@ is_subrange_type (tree type)
>        && TREE_CODE (subtype) != ENUMERAL_TYPE)
>      return false;
>  
> +  if (TREE_CODE (type) == TREE_CODE (subtype)
> +      && int_size_in_bytes (type) == int_size_in_bytes (subtype)
> +      && TYPE_MIN_VALUE (type) != NULL
> +      && TYPE_MIN_VALUE (subtype) != NULL
> +      && tree_int_cst_equal (TYPE_MIN_VALUE (type), TYPE_MIN_VALUE (subtype))
> +      && TYPE_MAX_VALUE (type) != NULL
> +      && TYPE_MAX_VALUE (subtype) != NULL
> +      && tree_int_cst_equal (TYPE_MAX_VALUE (type), TYPE_MAX_VALUE (subtype)))
> +    {
> +      /* The type and its subtype have the same representation.  If in
> +         addition the two types also have the same name, then the given
> +         type is not a subrange type, but rather a plain base type.  */
> +      tree type_name = TYPE_NAME (type);
> +      tree subtype_name = TYPE_NAME (subtype);
> +
> +      if (type_name != NULL && TREE_CODE (type_name) == TYPE_DECL)
> +        type_name = DECL_NAME (type_name);
> +
> +      if (subtype_name != NULL && TREE_CODE (subtype_name) == TYPE_DECL)
> +        subtype_name = DECL_NAME (subtype_name);
> +
> +      if (type_name != NULL && subtype_name != NULL
> +          &&strcmp (IDENTIFIER_POINTER (type_name),
> +                    IDENTIFIER_POINTER (subtype_name)) == 0)
> +        return false;

2) Why not just compare type_name == subtype_name?
   Identifiers are unique.

Jason



More information about the Gcc-patches mailing list