[PATCH] Adjust testcase for O2 vect.

2021-10-31 Thread liuhongt via Gcc-patches
> (I'm assuming the difference is due to some architectural
> constraints as opposed to arbitrary limitations in the code
There're 2 difference:
1. target support unaligned store or not.
2. target support move by piece or not(which will enable block move in gimple 
level).

Updated patch.

Adjust code in check_vect_slp_store_usage to make it an exact
pattern match of the corresponding testcases.
These new target/xfail selectors are added as a temporary solution,
and should be removed after real issue is fixed for Wstringop-overflow.

gcc/ChangeLog:

* doc/sourcebuild.texi (vect_slp_v4qi_store_unalign,
vect_slp_v2hi_store_unalign, vect_slp_v4hi_store_unalign,
vect_slp_v4si_store_unalign): Document efficient target.
(vect_slp_v4qi_store_unalign_1, vect_slp_v8qi_store_unalign_1,
vect_slp_v16qi_store_unalign_1): Ditto.
(vect_slp_v2hi_store_align,vect_slp_v2qi_store_align,
vect_slp_v2si_store_align, vect_slp_v4qi_store_align): Ditto.
(struct_4char_block_move, struct_8char_block_move,
struct_16char_block_move): Ditto.

gcc/testsuite/ChangeLog:

PR testsuite/102944
* c-c++-common/Wstringop-overflow-2.c: Adjust target/xfail
selector.
* gcc.dg/Warray-bounds-48.c: Ditto.
* gcc.dg/Warray-bounds-51.c: Ditto.
* gcc.dg/Warray-parameter-3.c: Ditto.
* gcc.dg/Wstringop-overflow-14.c: Ditto.
* gcc.dg/Wstringop-overflow-21.c: Ditto.
* gcc.dg/Wstringop-overflow-68.c: Ditto
* gcc.dg/Wstringop-overflow-76.c: Ditto
* gcc.dg/Wzero-length-array-bounds-2.c: Ditto.
* lib/target-supports.exp (vect_slp_v4qi_store_unalign): New
efficient target.
(vect_slp_v4qi_store_unalign_1): Ditto.
(struct_4char_block_move): Ditto.
(struct_8char_block_move): Ditto.
(stryct_16char_block_move): Ditto.
(vect_slp_v2hi_store_align): Ditto.
(vect_slp_v2qi_store): Rename to ..
(vect_slp_v2qi_store_align): .. this.
(vect_slp_v4qi_store): Rename to ..
(vect_slp_v4qi_store_align): .. This.
(vect_slp_v8qi_store): Rename to ..
(vect_slp_v8qi_store_unalign_1): .. This.
(vect_slp_v16qi_store): Rename to ..
(vect_slp_v16qi_store_unalign_1): .. This.
(vect_slp_v2hi_store): Rename to ..
(vect_slp_v2hi_store_unalign): .. This.
(vect_slp_v4hi_store): Rename to ..
(vect_slp_v4hi_store_unalign): This.
(vect_slp_v2si_store): Rename to ..
(vect_slp_v2si_store_align): .. This.
(vect_slp_v4si_store): Rename to ..
(vect_slp_v4si_store_unalign): Ditto.
(check_vect_slp_aligned_store_usage): Rename to ..
(check_vect_slp_store_usage): .. this and adjust code to make
it an exact pattern match of corresponding testcase.
---
 gcc/doc/sourcebuild.texi  |  59 ++--
 .../c-c++-common/Wstringop-overflow-2.c   |  20 +-
 gcc/testsuite/gcc.dg/Warray-bounds-48.c   |   4 +-
 gcc/testsuite/gcc.dg/Warray-bounds-51.c   |   2 +-
 gcc/testsuite/gcc.dg/Warray-parameter-3.c |   2 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-14.c  |   4 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-21.c  |   8 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-68.c  |  10 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-76.c  |  16 +-
 .../gcc.dg/Wzero-length-array-bounds-2.c  |   2 +-
 gcc/testsuite/lib/target-supports.exp | 313 +-
 11 files changed, 302 insertions(+), 138 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 6a165767630..de055d71654 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1846,37 +1846,58 @@ Target supports loop vectorization with partial vectors 
and
 Target supports loop vectorization with partial vectors and
 @code{vect-partial-vector-usage} is nonzero.
 
-@item vect_slp_v2qi_store
+@item vect_slp_v2qi_store_align
 Target supports vectorization of 2-byte char stores with 2-byte aligned
 address at plain @option{-O2}.
 
-@item vect_slp_v4qi_store
+@item vect_slp_v4qi_store_align
 Target supports vectorization of 4-byte char stores with 4-byte aligned
 address at plain @option{-O2}.
 
-@item vect_slp_v8qi_store
-Target supports vectorization of 8-byte char stores with 8-byte aligned
-address at plain @option{-O2}.
+@item vect_slp_v4qi_store_unalign
+Target supports vectorization of 4-byte char stores with unaligned address
+at plain @option{-O2}.
 
-@item vect_slp_v16qi_store
-Target supports vectorization of 16-byte char stores with 16-byte aligned
-address at plain @option{-O2}.
+@item struct_4char_block_move
+Target supports block move for 8-byte aligned 4-byte size struct 
initialization.
+
+@item vect_slp_v4qi_store_unalign_1
+Target supports vectorization of 4-byte char stores with unaligned address
+or store them with constant pool at plain @option{-O2}.
+
+@item struct_8char_block_move
+Target supports block move 

Re: [PATCH] Adjust testcase for O2 vect.

2021-10-28 Thread Hongtao Liu via Gcc-patches
On Fri, Oct 29, 2021 at 10:34 AM Martin Sebor  wrote:
>
> On 10/28/21 7:47 PM, Hongtao Liu wrote:
> > On Fri, Oct 29, 2021 at 12:20 AM Martin Sebor via Gcc-patches
> >  wrote:
> >>
> >> On 10/28/21 1:23 AM, liuhongt via Gcc-patches wrote:
> >>> Adjust code in check_vect_slp_aligned_store_usage to make it an exact
> >>> pattern match of the corresponding testcases.
> >>> These new target/xfail selectors are added as a temporary solution,
> >>> and should be removed after real issue is fixed for Wstringop-overflow.
> >>
> >> Thanks for all the work you're putting into this!  I can't say
> >> I understand the conditions under which to use which selector
> >> in what case but hopefully we will be able to remove them all
> >> from the tests once the warnings are moved to a better pass.
> >> If that's a safe assumption I'm okay with the changes to
> >> the tests.  I do have a question/comment on the .exp changes.
> >>
> >>>
> >>> gcc/ChangeLog:
> >>>
> >>>* doc/sourcebuild.texi (vect_slp_v4qi_store_2): Document
> >>>efficient target.
> >>>(vect_slp_v4qi_store_3): Ditto.
> >>>(vect_slp_v2hi_store_2): Ditto.
> >>>
> >>> gcc/testsuite/ChangeLog:
> >>>
> >>>PR testsuite/102944
> >>>* gcc.dg/Warray-bounds-48.c: Adjust target/xfail selector.
> >>>* gcc.dg/Warray-parameter-3.c: Ditto.
> >>>* gcc.dg/Wstringop-overflow-68.c: Ditto
> >>>* gcc.dg/Wstringop-overflow-76.c: Ditto
> >>>* lib/target-supports.exp (vect_slp_v4qi_store_2): New
> >>>efficient target.
> >>>(vect_slp_v4qi_store_3): Ditto.
> >>>(vect_slp_v2hi_store_2): Ditto.
> >>>(check_vect_slp_aligned_store_usage): Adjust code to make it
> >>>an exact pattern match of corresponding testcase.
> >>> ---
> >>>gcc/doc/sourcebuild.texi |  12 ++
> >>>gcc/testsuite/gcc.dg/Warray-bounds-48.c  |   4 +-
> >>>gcc/testsuite/gcc.dg/Warray-parameter-3.c|   2 +-
> >>>gcc/testsuite/gcc.dg/Wstringop-overflow-68.c |   4 +-
> >>>gcc/testsuite/gcc.dg/Wstringop-overflow-76.c |  16 +-
> >>>gcc/testsuite/lib/target-supports.exp| 201 ++-
> >>>6 files changed, 179 insertions(+), 60 deletions(-)
> >>>
> >>> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> >>> index 6a165767630..2bb3cb3a9be 100644
> >>> --- a/gcc/doc/sourcebuild.texi
> >>> +++ b/gcc/doc/sourcebuild.texi
> >>> @@ -1854,6 +1854,14 @@ address at plain @option{-O2}.
> >>>Target supports vectorization of 4-byte char stores with 4-byte aligned
> >>>address at plain @option{-O2}.
> >>>
> >>> +@item vect_slp_v4qi_store_2
> >>> +Target supports vectorization of 4-byte char stores with 4-byte aligned
> >>> +address at plain @option{-O2}.
> >>> +
> >>> +@item vect_slp_v4qi_store_3
> >>> +Target supports vectorization of 4-byte char stores with 4-byte aligned
> >>> +address at plain @option{-O2}.
> >>
> >> The description is the same for both of these targets as well
> >> as for vect_slp_v2qi_store.
> >>
> >> I think if anyone other than a vectorization expert is to have
> >> a chance of using these in the future without reverse engineering
> >> the code the descriptions need to capture the differences between
> >> them.  I.e., make it clear when vect_slp_v4qi_store is appropriate
> >> and when either vect_slp_v4qi_store_2 or vect_slp_v4qi_store_3
> >> should be used instead.
> > It's hard to describe vectorization difference like
> > vect_slp_v4qi_store
> > struct A1
> > {
> >  char n;
> >  char a[3];
> > };
> >
> > extern void sink (void*);
> > void
> > foo2 ()
> > {
> >  struct A1 a = { 0, {  } };
> >  a.a[0] = 3;
> >  a.a[1] = 4;
> >  a.a[2] = 5;
> >  sink ();
> > }
> >
> > from
> >
> > vect_slp_v4qi_store_2
> > extern char p[4];
> > void
> > foo2_2 ()
> > {
> >  p[0] = 0;
> >  p[1] = 1;
> >  p[2] = 2;
> >  p[3] = 3;
> > }
> >
> > and
> >
> > vect_slp_v4qi_store_3
> > typedef struct AC4 { char a[4]; } AC4;
> > extern char a[4];
> > void
> > foo ()
> > {
> >  *(AC4*)a = Ac4;
> > }
> >
> > They're all 4 continuous byte-stores, but with minor differences in
> > data reference.
> > Those efficient targets are an exact match of the corresponding
> > testcases, and maybe too special to be used in other places.(I have
> > tried to write them as general cases, but failed as PR102944
> > indicates)
> > The reuse of those targets do need reverse engineering.
>
> Then there must be another variable (or several) besides size
> and alignment that determines whether such stores can be
> vectorized and that reflects the minor differences.   Can you
> explain (at least roughly, in email) what it is?  I'd like to
> understand this enough not just so I have an idea what to look
> for if I have to tweak the tests, but also when I add new ones
> that might have the same issue.
>
> (I'm assuming the difference is due to some architectural
> constraints as opposed to arbitrary 

Re: [PATCH] Adjust testcase for O2 vect.

2021-10-28 Thread Martin Sebor via Gcc-patches

On 10/28/21 7:47 PM, Hongtao Liu wrote:

On Fri, Oct 29, 2021 at 12:20 AM Martin Sebor via Gcc-patches
 wrote:


On 10/28/21 1:23 AM, liuhongt via Gcc-patches wrote:

Adjust code in check_vect_slp_aligned_store_usage to make it an exact
pattern match of the corresponding testcases.
These new target/xfail selectors are added as a temporary solution,
and should be removed after real issue is fixed for Wstringop-overflow.


Thanks for all the work you're putting into this!  I can't say
I understand the conditions under which to use which selector
in what case but hopefully we will be able to remove them all
from the tests once the warnings are moved to a better pass.
If that's a safe assumption I'm okay with the changes to
the tests.  I do have a question/comment on the .exp changes.



gcc/ChangeLog:

   * doc/sourcebuild.texi (vect_slp_v4qi_store_2): Document
   efficient target.
   (vect_slp_v4qi_store_3): Ditto.
   (vect_slp_v2hi_store_2): Ditto.

gcc/testsuite/ChangeLog:

   PR testsuite/102944
   * gcc.dg/Warray-bounds-48.c: Adjust target/xfail selector.
   * gcc.dg/Warray-parameter-3.c: Ditto.
   * gcc.dg/Wstringop-overflow-68.c: Ditto
   * gcc.dg/Wstringop-overflow-76.c: Ditto
   * lib/target-supports.exp (vect_slp_v4qi_store_2): New
   efficient target.
   (vect_slp_v4qi_store_3): Ditto.
   (vect_slp_v2hi_store_2): Ditto.
   (check_vect_slp_aligned_store_usage): Adjust code to make it
   an exact pattern match of corresponding testcase.
---
   gcc/doc/sourcebuild.texi |  12 ++
   gcc/testsuite/gcc.dg/Warray-bounds-48.c  |   4 +-
   gcc/testsuite/gcc.dg/Warray-parameter-3.c|   2 +-
   gcc/testsuite/gcc.dg/Wstringop-overflow-68.c |   4 +-
   gcc/testsuite/gcc.dg/Wstringop-overflow-76.c |  16 +-
   gcc/testsuite/lib/target-supports.exp| 201 ++-
   6 files changed, 179 insertions(+), 60 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 6a165767630..2bb3cb3a9be 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1854,6 +1854,14 @@ address at plain @option{-O2}.
   Target supports vectorization of 4-byte char stores with 4-byte aligned
   address at plain @option{-O2}.

+@item vect_slp_v4qi_store_2
+Target supports vectorization of 4-byte char stores with 4-byte aligned
+address at plain @option{-O2}.
+
+@item vect_slp_v4qi_store_3
+Target supports vectorization of 4-byte char stores with 4-byte aligned
+address at plain @option{-O2}.


The description is the same for both of these targets as well
as for vect_slp_v2qi_store.

I think if anyone other than a vectorization expert is to have
a chance of using these in the future without reverse engineering
the code the descriptions need to capture the differences between
them.  I.e., make it clear when vect_slp_v4qi_store is appropriate
and when either vect_slp_v4qi_store_2 or vect_slp_v4qi_store_3
should be used instead.

It's hard to describe vectorization difference like
vect_slp_v4qi_store
struct A1
{
 char n;
 char a[3];
};

extern void sink (void*);
void
foo2 ()
{
 struct A1 a = { 0, {  } };
 a.a[0] = 3;
 a.a[1] = 4;
 a.a[2] = 5;
 sink ();
}

from

vect_slp_v4qi_store_2
extern char p[4];
void
foo2_2 ()
{
 p[0] = 0;
 p[1] = 1;
 p[2] = 2;
 p[3] = 3;
}

and

vect_slp_v4qi_store_3
typedef struct AC4 { char a[4]; } AC4;
extern char a[4];
void
foo ()
{
 *(AC4*)a = Ac4;
}

They're all 4 continuous byte-stores, but with minor differences in
data reference.
Those efficient targets are an exact match of the corresponding
testcases, and maybe too special to be used in other places.(I have
tried to write them as general cases, but failed as PR102944
indicates)
The reuse of those targets do need reverse engineering.


Then there must be another variable (or several) besides size
and alignment that determines whether such stores can be
vectorized and that reflects the minor differences.   Can you
explain (at least roughly, in email) what it is?  I'd like to
understand this enough not just so I have an idea what to look
for if I have to tweak the tests, but also when I add new ones
that might have the same issue.

(I'm assuming the difference is due to some architectural
constraints as opposed to arbitrary limitations in the code
for the various targets that keep one other other from handling
this or that IL.)

In any event, this isn't an objection to your fix (though
I do think we should try harder to capture the differences
between the selectors).  Just questions to help me understand
why and when it's needed.

Thanks
Martin





Martin


+
   @item vect_slp_v8qi_store
   Target supports vectorization of 8-byte char stores with 8-byte aligned
   address at plain @option{-O2}.
@@ -1874,6 +1882,10 @@ address at plain @option{-O2}.
   Target supports vectorization of 8-byte int stores with 8-byte aligned
   address at plain @option{-O2}.

+@item 

Re: [PATCH] Adjust testcase for O2 vect.

2021-10-28 Thread Hongtao Liu via Gcc-patches
On Fri, Oct 29, 2021 at 12:20 AM Martin Sebor via Gcc-patches
 wrote:
>
> On 10/28/21 1:23 AM, liuhongt via Gcc-patches wrote:
> > Adjust code in check_vect_slp_aligned_store_usage to make it an exact
> > pattern match of the corresponding testcases.
> > These new target/xfail selectors are added as a temporary solution,
> > and should be removed after real issue is fixed for Wstringop-overflow.
>
> Thanks for all the work you're putting into this!  I can't say
> I understand the conditions under which to use which selector
> in what case but hopefully we will be able to remove them all
> from the tests once the warnings are moved to a better pass.
> If that's a safe assumption I'm okay with the changes to
> the tests.  I do have a question/comment on the .exp changes.
>
> >
> > gcc/ChangeLog:
> >
> >   * doc/sourcebuild.texi (vect_slp_v4qi_store_2): Document
> >   efficient target.
> >   (vect_slp_v4qi_store_3): Ditto.
> >   (vect_slp_v2hi_store_2): Ditto.
> >
> > gcc/testsuite/ChangeLog:
> >
> >   PR testsuite/102944
> >   * gcc.dg/Warray-bounds-48.c: Adjust target/xfail selector.
> >   * gcc.dg/Warray-parameter-3.c: Ditto.
> >   * gcc.dg/Wstringop-overflow-68.c: Ditto
> >   * gcc.dg/Wstringop-overflow-76.c: Ditto
> >   * lib/target-supports.exp (vect_slp_v4qi_store_2): New
> >   efficient target.
> >   (vect_slp_v4qi_store_3): Ditto.
> >   (vect_slp_v2hi_store_2): Ditto.
> >   (check_vect_slp_aligned_store_usage): Adjust code to make it
> >   an exact pattern match of corresponding testcase.
> > ---
> >   gcc/doc/sourcebuild.texi |  12 ++
> >   gcc/testsuite/gcc.dg/Warray-bounds-48.c  |   4 +-
> >   gcc/testsuite/gcc.dg/Warray-parameter-3.c|   2 +-
> >   gcc/testsuite/gcc.dg/Wstringop-overflow-68.c |   4 +-
> >   gcc/testsuite/gcc.dg/Wstringop-overflow-76.c |  16 +-
> >   gcc/testsuite/lib/target-supports.exp| 201 ++-
> >   6 files changed, 179 insertions(+), 60 deletions(-)
> >
> > diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> > index 6a165767630..2bb3cb3a9be 100644
> > --- a/gcc/doc/sourcebuild.texi
> > +++ b/gcc/doc/sourcebuild.texi
> > @@ -1854,6 +1854,14 @@ address at plain @option{-O2}.
> >   Target supports vectorization of 4-byte char stores with 4-byte aligned
> >   address at plain @option{-O2}.
> >
> > +@item vect_slp_v4qi_store_2
> > +Target supports vectorization of 4-byte char stores with 4-byte aligned
> > +address at plain @option{-O2}.
> > +
> > +@item vect_slp_v4qi_store_3
> > +Target supports vectorization of 4-byte char stores with 4-byte aligned
> > +address at plain @option{-O2}.
>
> The description is the same for both of these targets as well
> as for vect_slp_v2qi_store.
>
> I think if anyone other than a vectorization expert is to have
> a chance of using these in the future without reverse engineering
> the code the descriptions need to capture the differences between
> them.  I.e., make it clear when vect_slp_v4qi_store is appropriate
> and when either vect_slp_v4qi_store_2 or vect_slp_v4qi_store_3
> should be used instead.
It's hard to describe vectorization difference like
vect_slp_v4qi_store
struct A1
{
char n;
char a[3];
};

extern void sink (void*);
void
foo2 ()
{
struct A1 a = { 0, {  } };
a.a[0] = 3;
a.a[1] = 4;
a.a[2] = 5;
sink ();
}

from

vect_slp_v4qi_store_2
extern char p[4];
void
foo2_2 ()
{
p[0] = 0;
p[1] = 1;
p[2] = 2;
p[3] = 3;
}

and

vect_slp_v4qi_store_3
typedef struct AC4 { char a[4]; } AC4;
extern char a[4];
void
foo ()
{
*(AC4*)a = Ac4;
}

They're all 4 continuous byte-stores, but with minor differences in
data reference.
Those efficient targets are an exact match of the corresponding
testcases, and maybe too special to be used in other places.(I have
tried to write them as general cases, but failed as PR102944
indicates)
The reuse of those targets do need reverse engineering.

>
> Martin
>
> > +
> >   @item vect_slp_v8qi_store
> >   Target supports vectorization of 8-byte char stores with 8-byte aligned
> >   address at plain @option{-O2}.
> > @@ -1874,6 +1882,10 @@ address at plain @option{-O2}.
> >   Target supports vectorization of 8-byte int stores with 8-byte aligned
> >   address at plain @option{-O2}.
> >
> > +@item vect_slp_v2si_store_2
> > +Target supports vectorization of 8-byte int stores with 8-byte aligned
> > +address at plain @option{-O2}.
> > +
> >   @item vect_slp_v4si_store
> >   Target supports vectorization of 16-byte int stores with 16-byte aligned
> >   address at plain @option{-O2}.
> > diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-48.c 
> > b/gcc/testsuite/gcc.dg/Warray-bounds-48.c
> > index 19b7634c063..32c0df843d2 100644
> > --- a/gcc/testsuite/gcc.dg/Warray-bounds-48.c
> > +++ b/gcc/testsuite/gcc.dg/Warray-bounds-48.c
> > @@ -30,7 +30,7 @@ static void nowarn_ax_extern (struct AX *p)
> >
> >   static void warn_ax_local_buf (struct AX *p)
> >   {
> 

Re: [PATCH] Adjust testcase for O2 vect.

2021-10-28 Thread Martin Sebor via Gcc-patches

On 10/28/21 1:23 AM, liuhongt via Gcc-patches wrote:

Adjust code in check_vect_slp_aligned_store_usage to make it an exact
pattern match of the corresponding testcases.
These new target/xfail selectors are added as a temporary solution,
and should be removed after real issue is fixed for Wstringop-overflow.


Thanks for all the work you're putting into this!  I can't say
I understand the conditions under which to use which selector
in what case but hopefully we will be able to remove them all
from the tests once the warnings are moved to a better pass.
If that's a safe assumption I'm okay with the changes to
the tests.  I do have a question/comment on the .exp changes.



gcc/ChangeLog:

* doc/sourcebuild.texi (vect_slp_v4qi_store_2): Document
efficient target.
(vect_slp_v4qi_store_3): Ditto.
(vect_slp_v2hi_store_2): Ditto.

gcc/testsuite/ChangeLog:

PR testsuite/102944
* gcc.dg/Warray-bounds-48.c: Adjust target/xfail selector.
* gcc.dg/Warray-parameter-3.c: Ditto.
* gcc.dg/Wstringop-overflow-68.c: Ditto
* gcc.dg/Wstringop-overflow-76.c: Ditto
* lib/target-supports.exp (vect_slp_v4qi_store_2): New
efficient target.
(vect_slp_v4qi_store_3): Ditto.
(vect_slp_v2hi_store_2): Ditto.
(check_vect_slp_aligned_store_usage): Adjust code to make it
an exact pattern match of corresponding testcase.
---
  gcc/doc/sourcebuild.texi |  12 ++
  gcc/testsuite/gcc.dg/Warray-bounds-48.c  |   4 +-
  gcc/testsuite/gcc.dg/Warray-parameter-3.c|   2 +-
  gcc/testsuite/gcc.dg/Wstringop-overflow-68.c |   4 +-
  gcc/testsuite/gcc.dg/Wstringop-overflow-76.c |  16 +-
  gcc/testsuite/lib/target-supports.exp| 201 ++-
  6 files changed, 179 insertions(+), 60 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 6a165767630..2bb3cb3a9be 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1854,6 +1854,14 @@ address at plain @option{-O2}.
  Target supports vectorization of 4-byte char stores with 4-byte aligned
  address at plain @option{-O2}.
  
+@item vect_slp_v4qi_store_2

+Target supports vectorization of 4-byte char stores with 4-byte aligned
+address at plain @option{-O2}.
+
+@item vect_slp_v4qi_store_3
+Target supports vectorization of 4-byte char stores with 4-byte aligned
+address at plain @option{-O2}.


The description is the same for both of these targets as well
as for vect_slp_v2qi_store.

I think if anyone other than a vectorization expert is to have
a chance of using these in the future without reverse engineering
the code the descriptions need to capture the differences between
them.  I.e., make it clear when vect_slp_v4qi_store is appropriate
and when either vect_slp_v4qi_store_2 or vect_slp_v4qi_store_3
should be used instead.

Martin


+
  @item vect_slp_v8qi_store
  Target supports vectorization of 8-byte char stores with 8-byte aligned
  address at plain @option{-O2}.
@@ -1874,6 +1882,10 @@ address at plain @option{-O2}.
  Target supports vectorization of 8-byte int stores with 8-byte aligned
  address at plain @option{-O2}.
  
+@item vect_slp_v2si_store_2

+Target supports vectorization of 8-byte int stores with 8-byte aligned
+address at plain @option{-O2}.
+
  @item vect_slp_v4si_store
  Target supports vectorization of 16-byte int stores with 16-byte aligned
  address at plain @option{-O2}.
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-48.c 
b/gcc/testsuite/gcc.dg/Warray-bounds-48.c
index 19b7634c063..32c0df843d2 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-48.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-48.c
@@ -30,7 +30,7 @@ static void nowarn_ax_extern (struct AX *p)
  
  static void warn_ax_local_buf (struct AX *p)

  {
-  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { 
target { vect_slp_v2hi_store &&  { ! vect_slp_v4hi_store } } } }
+  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { 
target { vect_slp_v2hi_store_2 &&  { ! vect_slp_v4hi_store } } } }
  
p->ax[2] = 6; // { dg-warning "\\\[-Warray-bounds" }

p->ax[3] = 7; // { dg-warning "\\\[-Warray-bounds" }
@@ -130,7 +130,7 @@ static void warn_a0_extern (struct A0 *p)
  
  static void warn_a0_local_buf (struct A0 *p)

  {
-  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { 
target { vect_slp_v2hi_store && { ! vect_slp_v4hi_store } } } }
+  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { 
target { vect_slp_v2hi_store_2 && { ! vect_slp_v4hi_store } } } }
  
p->a0[2] = 6; // { dg-warning "\\\[-Warray-bounds" }

p->a0[3] = 7; // { dg-warning "\\\[-Warray-bounds" }
diff --git a/gcc/testsuite/gcc.dg/Warray-parameter-3.c 
b/gcc/testsuite/gcc.dg/Warray-parameter-3.c
index b6ed8daf51c..bbf55a40a3c 100644
--- a/gcc/testsuite/gcc.dg/Warray-parameter-3.c
+++ 

[PATCH] Adjust testcase for O2 vect.

2021-10-28 Thread liuhongt via Gcc-patches
Adjust code in check_vect_slp_aligned_store_usage to make it an exact
pattern match of the corresponding testcases.
These new target/xfail selectors are added as a temporary solution,
and should be removed after real issue is fixed for Wstringop-overflow.

gcc/ChangeLog:

* doc/sourcebuild.texi (vect_slp_v4qi_store_2): Document
efficient target.
(vect_slp_v4qi_store_3): Ditto.
(vect_slp_v2hi_store_2): Ditto.

gcc/testsuite/ChangeLog:

PR testsuite/102944
* gcc.dg/Warray-bounds-48.c: Adjust target/xfail selector.
* gcc.dg/Warray-parameter-3.c: Ditto.
* gcc.dg/Wstringop-overflow-68.c: Ditto
* gcc.dg/Wstringop-overflow-76.c: Ditto
* lib/target-supports.exp (vect_slp_v4qi_store_2): New
efficient target.
(vect_slp_v4qi_store_3): Ditto.
(vect_slp_v2hi_store_2): Ditto.
(check_vect_slp_aligned_store_usage): Adjust code to make it
an exact pattern match of corresponding testcase.
---
 gcc/doc/sourcebuild.texi |  12 ++
 gcc/testsuite/gcc.dg/Warray-bounds-48.c  |   4 +-
 gcc/testsuite/gcc.dg/Warray-parameter-3.c|   2 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-68.c |   4 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-76.c |  16 +-
 gcc/testsuite/lib/target-supports.exp| 201 ++-
 6 files changed, 179 insertions(+), 60 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 6a165767630..2bb3cb3a9be 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1854,6 +1854,14 @@ address at plain @option{-O2}.
 Target supports vectorization of 4-byte char stores with 4-byte aligned
 address at plain @option{-O2}.
 
+@item vect_slp_v4qi_store_2
+Target supports vectorization of 4-byte char stores with 4-byte aligned
+address at plain @option{-O2}.
+
+@item vect_slp_v4qi_store_3
+Target supports vectorization of 4-byte char stores with 4-byte aligned
+address at plain @option{-O2}.
+
 @item vect_slp_v8qi_store
 Target supports vectorization of 8-byte char stores with 8-byte aligned
 address at plain @option{-O2}.
@@ -1874,6 +1882,10 @@ address at plain @option{-O2}.
 Target supports vectorization of 8-byte int stores with 8-byte aligned
 address at plain @option{-O2}.
 
+@item vect_slp_v2si_store_2
+Target supports vectorization of 8-byte int stores with 8-byte aligned
+address at plain @option{-O2}.
+
 @item vect_slp_v4si_store
 Target supports vectorization of 16-byte int stores with 16-byte aligned
 address at plain @option{-O2}.
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-48.c 
b/gcc/testsuite/gcc.dg/Warray-bounds-48.c
index 19b7634c063..32c0df843d2 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-48.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-48.c
@@ -30,7 +30,7 @@ static void nowarn_ax_extern (struct AX *p)
 
 static void warn_ax_local_buf (struct AX *p)
 {
-  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v2hi_store &&  { ! vect_slp_v4hi_store } } } }
+  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v2hi_store_2 &&  { ! vect_slp_v4hi_store } } } }
 
   p->ax[2] = 6; // { dg-warning "\\\[-Warray-bounds" }
   p->ax[3] = 7; // { dg-warning "\\\[-Warray-bounds" }
@@ -130,7 +130,7 @@ static void warn_a0_extern (struct A0 *p)
 
 static void warn_a0_local_buf (struct A0 *p)
 {
-  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v2hi_store && { ! vect_slp_v4hi_store } } } }
+  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v2hi_store_2 && { ! vect_slp_v4hi_store } } } }
 
   p->a0[2] = 6; // { dg-warning "\\\[-Warray-bounds" }
   p->a0[3] = 7; // { dg-warning "\\\[-Warray-bounds" }
diff --git a/gcc/testsuite/gcc.dg/Warray-parameter-3.c 
b/gcc/testsuite/gcc.dg/Warray-parameter-3.c
index b6ed8daf51c..bbf55a40a3c 100644
--- a/gcc/testsuite/gcc.dg/Warray-parameter-3.c
+++ b/gcc/testsuite/gcc.dg/Warray-parameter-3.c
@@ -77,7 +77,7 @@ gia3 (int a[3])
 __attribute__ ((noipa)) void
 gcas3 (char a[static 3])
 {
-  a[0] = 0; a[1] = 1; a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v4qi_store } } }
+  a[0] = 0; a[1] = 1; a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v4qi_store_2 } } }
   a[3] = 3;   // { dg-warning "\\\[-Warray-bounds" }
 }
 
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c 
b/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
index 04e91afb8bc..488b4a9b0c7 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
@@ -65,8 +65,8 @@ void warn_comp_lit (void)
   // MEM  [(char *)] = { 0, 1, 2, 3, 4, 5, 6, 7 };
   // MEM  [(char *)] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 13, 14, 15 };
   // and warning should be expected, refer