testsuite: check for and use -mno-strict-align where needed

Message ID orr0lqc7at.fsf@lxoliva.fsfla.org
State Accepted
Headers
Series testsuite: check for and use -mno-strict-align where needed |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Alexandre Oliva Oct. 20, 2023, 3:16 a.m. UTC
  On Mar 10, 2021, Alexandre Oliva <oliva@adacore.com> wrote:

> ppc configurations that have -mstrict-align enabled by default fail
> gcc.dg/strlenopt-80.c, because some memcpy calls don't get turned into
> MEM_REFs, which defeats the tested-for strlen optimization.

I've combined this patch with other patches that added -mno-strict-align
to tests that needed it on targets configured with -mstrict-align
enabled by default, and conditioned the use of the flag to targets that
support it.

Regstrapped on x86_64-linux-gnu, ppc64le-linux-gnu, also tested on a
ppc-vx7r2 configured with -mstrict-align.  Ok to install?

----

Various tests fail on powerpc if the toolchain is configured to enable
-mstrict-align by default.  This patch introduces -mno-strict-align on
tests found to fail that way, when the target supports this option.

I suppose !non_strict_align could be used to skip tests, instead of or
in addition to this tweak, and that might be desirable if they still
fail on targets that do no support -mno-strict-align, but I haven't
observed such scenarios.


The p9-vec-length tests expect vectorization on loop bodies and
epilogues that reference arrays that are not known to be more aligned
than their small element types.

Though VSX vectors work best with 32- or 64-bit alignment, unaligned
vector loads and stores are expected by the tests.  However, with
-mstrict-align by default, vector loads and stores not known to be
aligned end up open coded, which doesn't match the asm output
expectations coded in the tests.


for  gcc/ChangeLog

	* doc/sourcebuild.texi (opt_mstrict_align): New target.

for  gcc/testsuite/ChangeLog

	* lib/target-supports.exp
	(check_effective_target_opt_mstrict_align): New.
	* gcc.dg/strlenopt-80.c: Add -mno-strict-align if supported.
	* gcc.target/powerpc/prefix-ds-dq.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-1.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-2.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-3.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-4.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-5.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-6.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-7.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-8.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-1.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-2.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-3.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-4.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-5.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-6.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-7.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-epil-run-8.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-1.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-2.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-3.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-4.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-5.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-6.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-7.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-8.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-1.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-2.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-3.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-4.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-5.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-6.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-7.c: Likewise.
	* gcc.target/powerpc/p9-vec-length-full-run-8.c: Likewise.
---
 gcc/doc/sourcebuild.texi                           |    3 +++
 gcc/testsuite/gcc.dg/strlenopt-80.c                |    4 ++++
 .../gcc.target/powerpc/p9-vec-length-epil-1.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-2.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-3.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-4.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-5.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-6.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-7.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-8.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-1.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-2.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-3.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-4.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-5.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-6.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-7.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-epil-run-8.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-1.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-2.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-3.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-4.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-5.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-6.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-7.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-8.c      |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-1.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-2.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-3.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-4.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-5.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-6.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-7.c  |    2 ++
 .../gcc.target/powerpc/p9-vec-length-full-run-8.c  |    2 ++
 gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c    |    2 ++
 gcc/testsuite/lib/target-supports.exp              |    8 ++++++++
 36 files changed, 81 insertions(+)
  

Comments

Mike Stump Nov. 5, 2023, 8:48 p.m. UTC | #1
On Oct 19, 2023, at 8:16 PM, Alexandre Oliva <oliva@adacore.com> wrote:
> 
> On Mar 10, 2021, Alexandre Oliva <oliva@adacore.com> wrote:
> 
>> ppc configurations that have -mstrict-align enabled by default fail
>> gcc.dg/strlenopt-80.c, because some memcpy calls don't get turned into
>> MEM_REFs, which defeats the tested-for strlen optimization.
> 
> I've combined this patch with other patches that added -mno-strict-align
> to tests that needed it on targets configured with -mstrict-align
> enabled by default, and conditioned the use of the flag to targets that
> support it.
> 
> Regstrapped on x86_64-linux-gnu, ppc64le-linux-gnu, also tested on a
> ppc-vx7r2 configured with -mstrict-align.  Ok to install?

Ok.
  

Patch

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index c20af31c64237..d6c7a2f93102d 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2580,6 +2580,9 @@  Target supports FPU instructions.
 @item non_strict_align
 Target does not require strict alignment.
 
+@item opt_mstrict_align
+Target supports @option{-mstrict-align} and @option{-mno-strict-align}.
+
 @item pie_copyreloc
 The x86-64 target linker supports PIE with copy reloc.
 
diff --git a/gcc/testsuite/gcc.dg/strlenopt-80.c b/gcc/testsuite/gcc.dg/strlenopt-80.c
index a8adbf1eed549..63d4eb17e4c3f 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-80.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-80.c
@@ -8,6 +8,10 @@ 
    { dg-options "-O2 -Wall -fdump-tree-optimized" }
    { dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */
 
+/* On powerpc configurations that have -mstrict-align by default,
+   the memcpy calls for ncpylog >= 3 are not turned into MEM_REFs.
+   { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } }  */
+
 #define CHAR_BIT      __CHAR_BIT__
 #define SIZE_MAX      __SIZE_MAX__
 #define LEN_MAX       (__PTRDIFF_MAX__ - 2)
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
index dfcc0e9532058..f57d9457bd94c 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
index e63f1bf23722e..19856407d277e 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
index 4a99e3a326549..eaea96d1eadd1 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
index 9fbee6a4324b5..01991325ca8b6 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
index d023a998c3ba3..c68faa8c557a9 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
index dbce90757e362..18076cc8218cf 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-7.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-7.c
index 011b731f7c5a0..4e37c0a0095d3 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-7.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-7.c
@@ -5,6 +5,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
index e56fd55f623f3..0f3cd07226829 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for that only vectorize the epilogue with vector access with length,
    the main body still use normal vector load/store.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-1.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-1.c
index d1cd67f0c4d96..2f091a3114708 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-1.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-2.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-2.c
index 815867b51d05d..03b172521a8fd 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-2.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-3.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-3.c
index 5378d02c26975..5329422cd3aa0 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-3.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-4.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-4.c
index daed9a7774ee0..2021372c68b6f 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-4.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-5.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-5.c
index b5f24e68d8461..00ed61a5df167 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-5.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-6.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-6.c
index a3e6367384711..adbfd080c94e9 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-6.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-6.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-7.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-7.c
index f0b69d462a19f..79ba4a1757987 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-7.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-7.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-8.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-8.c
index 84abecf3f692a..6e09b07d41019 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-8.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-8.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we only vectorize the epilogue
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
index f01f1c54fa566..2818bac36a2f6 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
index f546e97fa7df4..b476910753f58 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
index 65142b3fecd0b..0f502423c88ae 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
index a4cc7aafaebb2..20ddfb392e11e 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
index 4b0b9070c84d7..0bad6938bf8c5 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
index 65ddf2b098a69..a73178e3ad394 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-7.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-7.c
index e0e51d9a9724c..b50ff3cf6ef22 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-7.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-7.c
@@ -5,6 +5,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
index 7fe0dd0043181..94f2aa48f57fc 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Test for fully with length, the loop body uses vector access with length,
    there should not be any epilogues.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-1.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-1.c
index 4e9bd0fbad303..8950392d29b6c 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-1.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-2.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-2.c
index 8e06b1b9304a8..1f295ae9d696b 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-2.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-3.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-3.c
index 0b86f62834fb4..1cb9b8f97c210 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-3.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-4.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-4.c
index 359f31c9ed5ec..029454afd27bf 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-4.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-5.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-5.c
index 7aa468e5b4e4b..02bb0a8964b87 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-5.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-6.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-6.c
index 53a2ad07fb324..9839ad9e1d918 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-6.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-6.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-7.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-7.c
index 0c21d137b9d58..10ce7740fa789 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-7.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-7.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-8.c b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-8.c
index 910784260677d..163bfb2f9bc12 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-8.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-8.c
@@ -3,6 +3,8 @@ 
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
+/* { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
+
 /* Check whether it runs successfully if we vectorize the loop fully
    with vector access with length.  */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
index 554cd0c1beac0..3f477a07cb326 100644
--- a/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
@@ -2,6 +2,8 @@ 
 /* { dg-require-effective-target powerpc_prefixed_addr } */
 /* { dg-require-effective-target lp64 } */
 /* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+/* If -mstrict-align is enabled by default, we don't get the expected opcodes.
+   { dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */
 
 /* Tests whether we generate a prefixed load/store operation for addresses that
    don't meet DS/DQ offset constraints.  64-bit is needed for testing the use
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index f0b692a2e19ba..1a563cacfb239 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -11468,6 +11468,14 @@  proc check_effective_target_non_strict_align {} {
     } "-Wcast-align"]
 }
 
+# Return 1 if the target supports -mstrict-align (and -mno-strict-align).
+
+proc check_effective_target_opt_mstrict_align {} {
+    return [check_no_compiler_messages opt_mstrict_align assembly {
+	void foo(void) {}
+    } "-mstrict-align -mno-strict-align"]
+}
+
 # Return 1 if the target has <ucontext.h>.
 
 proc check_effective_target_ucontext_h { } {