On Tue, Oct 25, 2016 at 10:17 AM, Eric Botcazou <ebotca...@adacore.com> wrote:
>> Is the change to pass wi::to_widest really necessary?  I think it has a
>> runtime penalty.
>
> Yes, because there is no == operator for a (tree, int) pair.

Ah, yes.  But operator== simply maps to wi::eq_p, so ...

>  Is there a cheap
> way to convert a tree back into a wide_int?  wi::to_wide?  Or a combination
> with decompose?  Otherwise you can use eq_p, but this means that all other
> callers of fits_to_tree_p are affected:
>
> template <typename T>
> bool
> wi::fits_to_tree_p (const T &x, const_tree type)
> {
>   /* Short-circuit boolean types since various transformations assume that
>      they can only take values 0 and 1.  */
>   if (TREE_CODE (type) == BOOLEAN_TYPE)
>     return eq_p (x, 0) || eq_p (x, 1);
>
> instead of just int_fits_type_p (but I don't really know if there is a penalty
> associated with eq_p here).

... this variant is fine it doesn't have any extra cost (the to_widest
in int_fits_type_p has).

I'm not sure what you mean with "all other callers of fits_to_tree_p
are affected" - that was desired.

Thanks,
Richard.


> --
> Eric Botcazou

Reply via email to