On Thu, 25 Sep 2025, Avinash Jayakar wrote:

> On Wed, 2025-09-24 at 08:30 +0200, Richard Biener via Gcc wrote:
> > 
> >  
> > > 2. Implement mulv2di3 for this specific target (which does exactly
> > > what
> > > scalar code would do), and let expand pass (expand_mult) take care
> > > of
> > > converting mult to shift/add/sub.
> > 
> > The expand pass wouldn't do this when the target implements mulv2di3.
> > 
> 
> Actually I tried it by adding define_expand "mulv2di3", and the
> following code in expmed.cc from the function expand_mult
> 3550         {
> 3551           int shift = wi::exact_log2 (rtx_mode_t (scalar_op1,
> mode));
> 3552           /* Perfect power of 2 (other than 1, which is handled
> above).  */
> 3553           if (shift > 0)
> 3554             return expand_shift (LSHIFT_EXPR, mode, op0,
> 3555                                  shift, target, unsignedp);
> 3556           else
> 3557             goto skip_synth;
> 
> Does a shift if operand 1 is power of 2. Also there are other
> optimizations applied similar to vector pattern recog. 
> So instead of adding similar thing in expand_vector_operations, I was
> thinking of adding mulv2di3 define_expand so that it goes through the
> vectorizer and let expand pass handle the optimization of
> multiplication.

I think it's fragile to rely on this.  It's not only the vectorizer
that creates vector multiplications but the user can do so by itself
and that relies on vector lowering to detect the operation isn't
implemeted.

Richard.

> > 
> Thanks and regards,
> Avinash Jayakar
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to