On 2026-09-23 15:40, Richard Biener wrote:
On Wed, Sep 2, 2026 at 1:18 PM Torbjörn Svensson via Sourceware Forge
<[email protected]> wrote:

From: Torbjörn SVENSSON <[email protected]>

vect_slp_v2qi_store_unalign tests whether the vectorizer handles a V2QI
store through a byte-aligned base, but some -Wstringop-overflow tests
instead depend on a V2QI store at a known one-byte misalignment from a
defined object.

These two variants are not the same on armv7ve with -mfloat-abi=hard.
Add a separate effective target for the latter case.

Can you again explain why they are not the same?  I'm guessing it's
about knowing the misalignment vs. unknown misalignment but then
vect_slp_v2qi_store_misalign vs. _unalign is not obvious.  Maybe
_unknown_misalign vs. _known_misalign?  But I'm still curious
why a target choses to allow one but not the other (for stores there's
no dr_explicit_realign[_optimized])?

Unless I've completly missunderstood the sequence, it should stem from
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/arm/arm.cc;hb=refs/heads/trunk#l30984

After another bisect, I identified that the first failing commit is
r16-4314-g5e9eecc6686 (for r16-4315 and later, r16-4355-g53085a46e7f162
is also needed to build).

I think the reason for the regression is that the value of "align" is
not the same for TYPE_ALIGN_UNIT(type) and GET_MODE_UNIT_SIZE(mode).

In the v2qi tests, mode would match HImode, thus:

- GET_MODE_UNIT_SIZE(HImode) would return 2.
- TYPE_ALIGN_UNIT(type) would return 1 for char.

So, maybe my patch is not correct and instead the function should
simply be like this since NEON apparently accepts unknown alignment:

static bool
arm_builtin_support_vector_misalignment (machine_mode mode,
                                         int misalignment,
                                         bool is_packed,
                                         bool is_gather_scatter)
{
  if (TARGET_NEON && !BYTES_BIG_ENDIAN && unaligned_access)
    {
      HOST_WIDE_INT align = GET_MODE_UNIT_SIZE (mode);

      if (is_gather_scatter)
        return true;

      if (is_packed)
        return align == 1;

      /* NEON supports access regardless of the alignment.  */
      return true;
    }

  return default_builtin_support_vector_misalignment (mode, misalignment,
                                                      is_packed,
                                                      is_gather_scatter);
}


WDYT?

Also, the check "align == 1" in the is_packed branch is probably not
doing the right thing since the value in "align" is the size(?) and not
the alignment.



         PR testsuite/124342
         PR testsuite/124619

gcc/ChangeLog:

         * doc/sourcebuild.texi (vect_slp_v2qi_store_unalign): Document.
         (vect_slp_v2qi_store_misalign): Likewise.

gcc/testsuite/ChangeLog:

         * lib/target-supports.exp (check_vect_slp_store_usage): Add
         TEST_V2QI_MISALIGN.  Renamed TEST_V2QI to TEST_V2QI_ALIGN and
         TEST_V2QI_2 to TEST_V2QI_UNALIGN.
         (check_effective_target_vect_slp_v2qi_store_misalign): New proc.
         (check_effective_target_vect_slp_v2qi_store_align): Define
         TEST_V2QI_ALIGN.
         (check_effective_target_vect_slp_v2qi_store_unalign): Define
         TEST_V2QI_UNALIGN.
         * c-c++-common/Wstringop-overflow-2.c: Use
         check_effective_target_vect_slp_v2qi_store_misalign.
         * g++.dg/warn/Wstringop-overflow-3.C: Likewise.

Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
Changes since v1:

- Renamed define TEST_V2QI to TEST_V2QI_ALIGN
- Renamed define TEST_V2QI_2 to TEST_V2QI_UNALIGN


I've tested this change on top of r17-3738-gaaa0f6b1e87bc6 and 
r16-9620-g04c3e1efd4917e.

Ok for trunk and releases/gcc-16?


--



This is a forge pull request published on the gcc-patches mailing list mailing 
list
as requested by Torbjörn Svensson via Sourceware Forge 
<[email protected]>.
Forge discussion: https://forge.sourceware.org/gcc/gcc/pulls/215

Get it locally using:
```
git fetch forge-upstream "+refs/versioned_pull/215/*:refs/versioned_pull/215/*"
git switch -c "pr-215-v2" "refs/versioned_pull/215/2/head"
```
Or, download the patch at: https://forge.sourceware.org/gcc/gcc/pulls/215.diff
Created on: 2026-08-10 17:42:02+00:00
Latest update: 2026-09-02 11:17:13+00:00
Changes: 4 changed files, 81 additions, 51 deletions
Head revision: azoff/gcc ref pr/Wstringop-overflow commit 
3f5592502b2ba71cb4088daeae109915f431b6a9
Base revision: gcc/gcc ref trunk commit 
aaa0f6b1e87bc62ea15da6eab431af6dcebf6414 r17-3738-gaaa0f6b1e87bc6
Merge base: aaa0f6b1e87bc62ea15da6eab431af6dcebf6414
Requested Reviewers:

Changed files:
- M: gcc/doc/sourcebuild.texi
- M: gcc/testsuite/c-c++-common/Wstringop-overflow-2.c
- M: gcc/testsuite/g++.dg/warn/Wstringop-overflow-3.C
- M: gcc/testsuite/lib/target-supports.exp

  gcc/doc/sourcebuild.texi                      |  8 +++
  .../c-c++-common/Wstringop-overflow-2.c       | 50 +++++++++----------
  .../g++.dg/warn/Wstringop-overflow-3.C        | 44 ++++++++--------
  gcc/testsuite/lib/target-supports.exp         | 30 +++++++++--
  4 files changed, 81 insertions(+), 51 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index aad51550eba40..5215d5a9529d5 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1946,6 +1946,14 @@ Target supports loop vectorization with partial vectors 
and
  Target supports vectorization of 2-byte char stores with 2-byte aligned
  address at plain @option{-O2}.

+@item vect_slp_v2qi_store_unalign
+Target supports vectorization of 2-byte char stores with an unaligned
+address at plain @option{-O2}.
+
+@item vect_slp_v2qi_store_misalign
+Target supports vectorization of 2-byte char stores at a known one-byte
+misaligned address at plain @option{-O2}.
+
  @item vect_slp_v4qi_store_align
  Target supports vectorization of 4-byte char stores with 4-byte aligned
  address at plain @option{-O2}.
diff --git a/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c 
b/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c
index 3f9171947c252..4b0e443f28852 100644
--- a/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c
+++ b/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c
@@ -19,7 +19,7 @@ struct Ax ax_;
  void gax_ (void)
  {
    ax_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  ax_.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax_.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax_.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -30,7 +30,7 @@ struct Ax ax0 = { 0 };
  void gax0 (void)
  {
    ax0.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  ax0.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax0.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax0.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -41,7 +41,7 @@ struct Ax ax0_ = { 0, { } };
  void gax0_ (void)
  {
    ax0_.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
-  ax0_.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax0_.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax0_.a[2] = 2;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -51,8 +51,8 @@ struct Ax ax1 = { 1, { 0 } };

  void gax1 (void)
  {
-  ax1.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  ax1.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax1.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  ax1.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax1.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -100,7 +100,7 @@ struct A0 a0_;
  void ga0_ (void)
  {
    a0_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  a0_.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a0_.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a0_.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -111,7 +111,7 @@ struct A0 a00 = { 0 };
  void ga00 (void)
  {
    a00.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  a00.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a00.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a00.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -122,7 +122,7 @@ struct A0 a00_ = { 0, { } };
  void ga00_ (void)
  {
    a00_.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
-  a00_.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a00_.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a00_.a[2] = 2;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -166,13 +166,13 @@ struct A1 a1_;

  void ga1_ (void)
  {
-  a1_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1_.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1_.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1_.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1 a;
-  a.a[0] = 0;                   // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a.a[1] = 1;                   // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a.a[0] = 0;                   // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a.a[1] = 1;                   // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a.a[2] = 2;                   // { dg-warning "\\\[-Wstringop-overflow" }
    sink (&a);
  }
@@ -183,8 +183,8 @@ struct A1 a1__ = { 0 };

  void ga1__ (void)
  {
-  a1__.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ target { vect_slp_v2qi_store_unalign } } }
-  a1__.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_unalign } } }
+  a1__.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ target { vect_slp_v2qi_store_misalign } } }
+  a1__.a[1] = 1;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_misalign } } }
    a1__.a[2] = 2;                 // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1 a = { 1 };
@@ -200,8 +200,8 @@ struct A1 a1_0 = { 0, { } };

  void ga1_0_ (void)
  {
-  a1_0.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1_0.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1_0.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1_0.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1_0.a[2] = 2;                // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1 a = { 1, { } };
@@ -217,8 +217,8 @@ struct A1 a1_1 = { 0, { 1 } };

  void ga1_1 (void)
  {
-  a1_1.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1_1.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1_1.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1_1.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1_1.a[2] = 2;                // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1 a = { 0, { 1 } };   // { dg-warning "\\\[-Wstringop-overflow" 
"pr102706" { target { vect_slp_v4qi_store_align } } }
@@ -266,12 +266,12 @@ struct A1i a1i_;
  void ga1i_ (void)
  {
    a1i_.a[0] = 0;
-  a1i_.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1i_.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1i_.a[2] = 2;                // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1i a;
    a.a[0] = 1;
-  a.a[1] = 2;                   // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a.a[1] = 2;                   // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a.a[2] = 3;                   // { dg-warning "\\\[-Wstringop-overflow" }
    sink (&a);
  }
@@ -283,7 +283,7 @@ struct A1i a1i__ = { 0 };
  void ga1i__ (void)
  {
    a1i__.a[0] = 0;
-  a1i__.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_unalign } } }
+  a1i__.a[1] = 1;                // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_misalign } } }
    a1i__.a[2] = 2;                // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1i a = { 0 };
@@ -299,8 +299,8 @@ struct A1 a1i_0 = { 0, { } };

  void ga1i_0_ (void)
  {
-  a1i_0.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1i_0.a[1] = 1;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1i_0.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1i_0.a[1] = 1;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1i_0.a[2] = 2;               // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1 a = { 0, { } };
@@ -316,8 +316,8 @@ struct A1 a1i_1 = { 0, { 1 } };

  void ga1i_1 (void)
  {
-  a1i_1.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1i_1.a[1] = 1;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1i_1.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1i_1.a[1] = 1;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1i_1.a[2] = 2;               // { dg-warning "\\\[-Wstringop-overflow" }

    struct A1 a = { 0, { 1 } };   // { dg-warning "\\\[-Wstringop-overflow" 
"pr102462" { target { vect_slp_v4qi_store_align } } }
diff --git a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-3.C 
b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-3.C
index e1d547fe4d40c..0e8523b8ed182 100644
--- a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-3.C
+++ b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-3.C
@@ -21,7 +21,7 @@ Ax ax_;
  NOIPA void gax_ ()
  {
    ax_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  ax_.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax_.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax_.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -32,7 +32,7 @@ Ax ax0 = { 0 };
  NOIPA void gax0 ()
  {
    ax0.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  ax0.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax0.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax0.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -43,7 +43,7 @@ Ax ax0_ = { 0, { } };
  NOIPA void gax0_ ()
  {
    ax0_.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
-  ax0_.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax0_.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax0_.a[2] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -53,8 +53,8 @@ Ax ax1 = { 1, { 0 } };

  NOIPA void gax1 ()
  {
-  ax1.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  ax1.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  ax1.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  ax1.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    ax1.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -102,7 +102,7 @@ A0 a0_;
  NOIPA void ga0_ ()
  {
    a0_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  a0_.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a0_.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a0_.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -113,7 +113,7 @@ A0 a00 = { 0 };
  NOIPA void ga00 ()
  {
    a00.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
-  a00.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a00.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a00.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -124,7 +124,7 @@ A0 a00_ = { 0, { } };
  NOIPA void ga00_ ()
  {
    a00_.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
-  a00_.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a00_.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a00_.a[2] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -168,8 +168,8 @@ A1 a1_;

  NOIPA void ga1_ ()
  {
-  a1_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1_.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1_.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1_.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1_.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -179,8 +179,8 @@ A1 a1__ = { 0 };

  NOIPA void ga1__ ()
  {
-  a1__.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ target { vect_slp_v2qi_store_unalign } } }
-  a1__.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_unalign } } }
+  a1__.a[0] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ target { vect_slp_v2qi_store_misalign } } }
+  a1__.a[1] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_misalign } } }
    a1__.a[2] = 0;                 // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -190,8 +190,8 @@ A1 a1_0 = { 0, { } };

  NOIPA void ga1_0_ ()
  {
-  a1_0.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1_0.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1_0.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1_0.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1_0.a[2] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -201,8 +201,8 @@ A1 a1_1 = { 0, { 1 } };

  NOIPA void ga1_1 ()
  {
-  a1_1.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1_1.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1_1.a[0] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1_1.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1_1.a[2] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -244,7 +244,7 @@ A1i a1i_;
  NOIPA void ga1i_ ()
  {
    a1i_.a[0] = 0;
-  a1i_.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1i_.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1i_.a[2] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -255,7 +255,7 @@ A1i a1i__ = { 0 };
  NOIPA void ga1i__ ()
  {
    a1i__.a[0] = 0;
-  a1i__.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_unalign } } }
+  a1i__.a[1] = 0;                // { dg-warning "\\\[-Wstringop-overflow" "" 
{ xfail { vect_slp_v2qi_store_misalign } } }
    a1i__.a[2] = 0;                // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -265,8 +265,8 @@ A1 a1i_0 = { 0, { } };

  NOIPA void ga1i_0_ ()
  {
-  a1i_0.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1i_0.a[1] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1i_0.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1i_0.a[1] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1i_0.a[2] = 0;               // { dg-warning "\\\[-Wstringop-overflow" }
  }

@@ -276,8 +276,8 @@ A1 a1i_1 = { 0, { 1 } };

  NOIPA void ga1i_1 ()
  {
-  a1i_1.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_unalign } } }
-  a1i_1.a[1] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_unalign } } }
+  a1i_1.a[0] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
target { vect_slp_v2qi_store_misalign } } }
+  a1i_1.a[1] = 0;               // { dg-warning "\\\[-Wstringop-overflow" "" { 
xfail { vect_slp_v2qi_store_misalign } } }
    a1i_1.a[2] = 0;               // { dg-warning "\\\[-Wstringop-overflow" }
  }

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index d467e9fa3b7fd..e752532298901 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9696,7 +9696,7 @@ proc check_vect_slp_store_usage { pattern macro } {
         {
             *(AC4*)a = Ac4;
         }
-       #elif TEST_V2QI
+       #elif TEST_V2QI_ALIGN
         struct A2
         {
             char a[2];
@@ -9709,7 +9709,7 @@ proc check_vect_slp_store_usage { pattern macro } {
             a.a[1] = 4;
             sink (&a);
         }
-       #elif TEST_V2QI_2
+       #elif TEST_V2QI_UNALIGN
         extern char p[2];
         void
         foo3_2 ()
@@ -9717,6 +9717,19 @@ proc check_vect_slp_store_usage { pattern macro } {
             p[0] = 0;
             p[1] = 1;
         }
+       #elif TEST_V2QI_MISALIGN
+       struct A2
+       {
+           char n;
+           char a[2];
+       };
+       struct A2 p __attribute__ ((aligned (2)));
+       void
+       foo3_misalign ()
+       {
+           p.a[0] = 0;
+           p.a[1] = 1;
+       }
         #elif TEST_V4HI
         struct Ax
         {
@@ -9812,7 +9825,7 @@ proc check_vect_slp_store_usage { pattern macro } {
  # is the exact match of relative testcases
  proc check_effective_target_vect_slp_v2qi_store_align { } {
      set pattern {add new stmt: MEM <vector\(2\) char>}
-    set macro "TEST_V2QI"
+    set macro "TEST_V2QI_ALIGN"
      return [check_cached_effective_target vect_slp_v2qi_store_align {
         expr [check_vect_slp_store_usage $pattern $macro] }]
  }
@@ -9821,11 +9834,20 @@ proc check_effective_target_vect_slp_v2qi_store_align { 
} {
  # with unaligned address at plain O2.
  proc check_effective_target_vect_slp_v2qi_store_unalign { } {
      set pattern {add new stmt: MEM <vector\(2\) char>}
-    set macro "TEST_V2QI_2"
+    set macro "TEST_V2QI_UNALIGN"
      return [check_cached_effective_target vect_slp_v2qi_store_unalign {
         expr [check_vect_slp_store_usage $pattern $macro ] }]
  }

+# Return the true if target support vectorization of 2-byte char stores
+# with a known one-byte misaligned address at plain O2.
+proc check_effective_target_vect_slp_v2qi_store_misalign { } {
+    set pattern {add new stmt: MEM <vector\(2\) char>}
+    set macro "TEST_V2QI_MISALIGN"
+    return [check_cached_effective_target vect_slp_v2qi_store_misalign {
+       expr [check_vect_slp_store_usage $pattern $macro ] }]
+}
+
  # Return the true if target support vectorization of 4-byte char stores
  # with 4-byte aligned address at plain O2.
  # NB: This target should be removed after real issues are fixed for

Range-diff against v1:
1:  1a3f4342b3ffa ! 1:  3f5592502b2ba testsuite: Split out known-misaligned 
V2QI store target [PR124342] [PR124619]
     @@ Commit message
          gcc/testsuite/ChangeLog:

                  * lib/target-supports.exp (check_vect_slp_store_usage): Add
     -            TEST_V2QI_MISALIGN.
     +            TEST_V2QI_MISALIGN.  Renamed TEST_V2QI to TEST_V2QI_ALIGN and
     +            TEST_V2QI_2 to TEST_V2QI_UNALIGN.
                  (check_effective_target_vect_slp_v2qi_store_misalign): New 
proc.
     -            * c-c++-common/Wstringop-overflow-2.c: Use it.
     +            (check_effective_target_vect_slp_v2qi_store_align): Define
     +            TEST_V2QI_ALIGN.
     +            (check_effective_target_vect_slp_v2qi_store_unalign): Define
     +            TEST_V2QI_UNALIGN.
     +            * c-c++-common/Wstringop-overflow-2.c: Use
     +            check_effective_target_vect_slp_v2qi_store_misalign.
                  * g++.dg/warn/Wstringop-overflow-3.C: Likewise.

          Signed-off-by: Torbjörn SVENSSON <[email protected]>
     @@ gcc/testsuite/g++.dg/warn/Wstringop-overflow-3.C: A1 a1i_1 = { 0, { 1 } 
};


       ## gcc/testsuite/lib/target-supports.exp ##
     +@@ gcc/testsuite/lib/target-supports.exp: proc check_vect_slp_store_usage 
{ pattern macro } {
     +   {
     +       *(AC4*)a = Ac4;
     +   }
     +-  #elif TEST_V2QI
     ++  #elif TEST_V2QI_ALIGN
     +   struct A2
     +   {
     +       char a[2];
     +@@ gcc/testsuite/lib/target-supports.exp: proc check_vect_slp_store_usage 
{ pattern macro } {
     +       a.a[1] = 4;
     +       sink (&a);
     +   }
     +-  #elif TEST_V2QI_2
     ++  #elif TEST_V2QI_UNALIGN
     +   extern char p[2];
     +   void
     +   foo3_2 ()
      @@ gcc/testsuite/lib/target-supports.exp: proc check_vect_slp_store_usage 
{ pattern macro } {
             p[0] = 0;
             p[1] = 1;
     @@ gcc/testsuite/lib/target-supports.exp: proc check_vect_slp_store_usage 
{ pattern
         #elif TEST_V4HI
         struct Ax
         {
     -@@ gcc/testsuite/lib/target-supports.exp: proc 
check_effective_target_vect_slp_v2qi_store_unalign { } {
     +@@ gcc/testsuite/lib/target-supports.exp: proc check_vect_slp_store_usage 
{ pattern macro } {
     + # is the exact match of relative testcases
     + proc check_effective_target_vect_slp_v2qi_store_align { } {
     +     set pattern {add new stmt: MEM <vector\(2\) char>}
     +-    set macro "TEST_V2QI"
     ++    set macro "TEST_V2QI_ALIGN"
     +     return [check_cached_effective_target vect_slp_v2qi_store_align {
     +   expr [check_vect_slp_store_usage $pattern $macro] }]
     + }
     +@@ gcc/testsuite/lib/target-supports.exp: proc 
check_effective_target_vect_slp_v2qi_store_align { } {
     + # with unaligned address at plain O2.
     + proc check_effective_target_vect_slp_v2qi_store_unalign { } {
     +     set pattern {add new stmt: MEM <vector\(2\) char>}
     +-    set macro "TEST_V2QI_2"
     ++    set macro "TEST_V2QI_UNALIGN"
     +     return [check_cached_effective_target vect_slp_v2qi_store_unalign {
         expr [check_vect_slp_store_usage $pattern $macro ] }]
       }

--
2.54.0


Reply via email to