On Tue, Aug 8, 2023 at 3:06 PM Robin Dapp <rdapp....@gmail.com> wrote:
>
> > Hmm, the conversion should be a separate statement so I wonder
> > why it would go wrong?
>
> It is indeed.  Yet, lhs_type is the lhs type of the conversion
> and not the call and consequently we compare the precision of
> the converted type with the popcount input.
>
> So we should probably rather do something like:
>
> +  tree call_lhs = gimple_call_lhs (call_stmt);
> +
>    /* Input and output of .POPCOUNT should be same-precision integer.  */
> -  if (TYPE_PRECISION (unprom_diff.type) != TYPE_PRECISION (lhs_type))
> +  if (TYPE_PRECISION (unprom_diff.type) != TYPE_PRECISION (TREE_TYPE 
> (call_lhs)))
>      return NULL;

We seem to be looking at promotions of the call argument, lhs_type
is the same as the type of the call LHS.  But the comment mentions .POPCOUNT
and the following code also handles others, so maybe handling should be
moved.  Also when we look to vectorize popcount (x) instead of popcount((T)x)
we can simply promote the result accordingly.

It looks like vect_recog_popcount_clz_ctz_ffs_pattern is specifcally for
the conversions, so your fallback should possibly apply even when not
matching them.

> Regards
>  Robin

Reply via email to