On Thu, Apr 17, 2025 at 10:19 AM Eric Botcazou <botca...@adacore.com> wrote:
>
> > LGTM. I do wonder if this could be documented somewhere if not
> > already. Because I suspect there are other places which miss that if
> > TYPE_PRECISION are equal, you might still need a cast for boolean
> > types. Maybe a helper function might be useful too.
>
> The knowledge is indeed encoded in useless_type_conversion_p, int_fits_type_p,
> fits_to_tree_p (which ought to be called fits_to_type_p AFAICS) but I'm not
> sure how to factor it out in a predicate.  But we can certainly add a blurb in
> tree.def for BOOLEAN_TYPE, for example:

That looks like a good place - can we possibly say sth about signedness a well?
IIRC all languages have unsigned bools but vector mask components are
signed bools?

> diff --git a/gcc/tree.def b/gcc/tree.def
> index c4ad8d08f10..19533cfe77c 100644
> --- a/gcc/tree.def
> +++ b/gcc/tree.def
> @@ -135,7 +135,9 @@ DEFTREECODE (OFFSET_TYPE, "offset_type", tcc_type, 0)
>  DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0)
>
>  /* Boolean type (true or false are the only values).  Looks like an
> -   INTEGRAL_TYPE.  */
> +   INTEGER_TYPE, but must be dealt with specially because TYPE_PRECISION
> +   may be arbitrary despite the restricted set of valid values (in other
> +   words, boolean types with TYPE_PRECISION > 1 exist in some languages).
>  DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0)
>
>  /* Integer types in all languages, including char in C.
>
> --
> Eric Botcazou
>
>

Reply via email to