On Tue, 28 Sep 2021, Richard Biener wrote:

> On Tue, 28 Sep 2021, Hongtao Liu wrote:
> 
> > On Tue, Sep 28, 2021 at 2:59 PM Richard Biener via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > On Mon, 27 Sep 2021, sunil.k.pandey wrote:
> > >
> > > > On Linux/x86_64,
> > > >
> > > > 6390c5047adb75960f86d56582e6322aaa4d9281 is the first bad commit
> > > > commit 6390c5047adb75960f86d56582e6322aaa4d9281
> > > > Author: Richard Biener <rguent...@suse.de>
> > > > Date:   Wed Nov 18 09:36:57 2020 +0100
> > > >
> > > >     Allow different vector types for stmt groups
> > > >
> > > > caused
> > > >
> > > > FAIL: gcc.dg/vect/bb-slp-17.c -flto -ffat-lto-objects  
> > > > scan-tree-dump-times slp2 "optimized: basic block" 1
> > > > FAIL: gcc.dg/vect/bb-slp-17.c scan-tree-dump-times slp2 "optimized: 
> > > > basic block" 1
> > >
> > > This shows that it is maybe a bad idea to support V2SImode vectorization
> > > with -m32 when we refuse to implement even plus.
> > >
> > > OTOH it's just the mode that's available, autovectorize_vector_modes
> > > doesn't include the corresponding mode but we still pick it up via
> > > the related vector mode for group-size == 2.
> 
> It looks like we could define the vectorize.related_mode hook to
> reject V2SImode when !TARGET_MMX_WITH_SSE - the default implementation
> just checks for vector_mode_supported_p.

Meh, that doesn't work.  We then fall through

  else if (SCALAR_INT_MODE_P (prevailing_mode)
           || !related_vector_mode (prevailing_mode,
                                    inner_mode, nunits).exists 
(&simd_mode))
    {
      /* Fall back to using mode_for_vector, mostly in the hope of being
         able to use an integer mode.  */
      if (known_eq (nunits, 0U)
          && !multiple_p (GET_MODE_SIZE (prevailing_mode), nbytes, 
&nunits))
        return NULL_TREE;

      if (!mode_for_vector (inner_mode, nunits).exists (&simd_mode))
        return NULL_TREE;

and return V2SImode anyway from mode_for_vector ...

So - should we only allow integer modes here as the comment suggests?
With that, thus

      if (!mode_for_vector (inner_mode, nunits).exists (&simd_mode)
          || GET_MODE_CLASS (simd_mode) != MODE_INT)
        return NULL_TREE;

we "properly" _not_ use V2SImode for vectorization on x86 when
!TARGET_MMX_WITH_SSE.  Note that will also not use V2SImode
for vectorizing copies (which are properly supported).  So I'm
not sure rejecting V2SImode outright is "proper" ...

Richard.

Reply via email to