On Tue, 23 Sep 2025, Avinash Jayakar wrote:
> Hi,
>
> I had a question regarding the function vect_pattern_recog that is
> triggered in the slp/vectorization pass.
> In case the original code is already in vector form, for example below
> is the original gimple dump of a vector function
>
>
> ;; Function lshift1_64 (null)
> ;; enabled by -tree-original
>
>
> {
> __vector unsigned long long D.4059 = { 2, 2 };
>
> return <<< Unknown tree: compound_literal_expr
> __vector unsigned long long D.4059 = { 2, 2 }; >>> * a;
> }
>
>
> This however does not go through the pattern recognition since
> 1. It is already in vector form
> 2. This check fails in slp pass
> if (bb_vinfo->grouped_stores.is_empty ()
> && bb_vinfo->roots.is_empty ())
>
> So my main question is, suppose this line of code (in this example v1 *
> {2, 2}) do go through the pattern recognition, it could have generated
> better code like v1 + v1 or v1 << {1,1}) which could result in
> vectorization in certain target which does not have native double word
> multiplication support, but might have double word shift or add.
> Is this intended or is there a way have this code pattern recognized?
The vectorizer is currently not set up for re-vectorizing already
vectorized code. Instead for the situation you describe, a target
without vector multiplication support, it would be the task of the
vector lowering pass (tree-vect-generic.cc) to turn this into a
supported operation.
Richard.
> cc'ing the maintainers for vectorization component.
>
> 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)