https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108583

--- Comment #12 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
(In reply to rguent...@suse.de from comment #11)
> On Tue, 31 Jan 2023, tnfchris at gcc dot gnu.org wrote:
> 
> 
> I don't think passing in for example the tree operand 0 helps, the
> target appearantly wants to not specialize by the constant divided by
> but instead also by the number divided (of we already know its type).
> 

The target wants to specialize division by a specific constant.  It just
happens that there is an additional specialization when certain bits are known
to be free in operand0.

> Do you plan to do SSA def pattern matching in the hook for this at
> expand time?
> 

My intention was to only look if the DEF_STMT is a gimple assign, and then the
operands to it are half the precision of the result.  This catches *w, *>> and
any other case.  It doesn't need to know further up because it's harder to
track non-zero bits across different math operations.  and this is enough for
the use case we're interested in.

> As said, recognizing the special case and open-coding the full divison
> in the vectorizer (or possibly even from RTL expansion) would be
> another option here.

open-coding in the vectorizer will require 4 new IFNs and 4 new optabs as it
requires 4 different instructions. 2 for neon, 2 for SVE, which are
semantically different as permutes work different across SVE and NEON.  So if
you're happy with that I will do that.

> (or possibly even from RTL expansion) would be another option here.

I don't really follow this one. The open coding at expand time is what I was
trying to do before.  The issue is there's no longer a single statement if we
don't stop the vectorizer from decomposing it into shifts and multiplies.

As long as the vectorizer does this decomposition there's not much to do at
expand time.  Additionally the number of widening operations after
vectorization is large. So to semantically match them with the decomposed shift
seems impossible..

But those are only my thoughts :) ultimately I'll do the approach you two want.
 If you want me to revert to using IFNs I can do that.

Reply via email to