]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: check for and use -mno-strict-align where needed
authorAlexandre Oliva <oliva@adacore.com>
Tue, 7 Nov 2023 11:02:03 +0000 (08:02 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Tue, 7 Nov 2023 11:02:03 +0000 (08:02 -0300)
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.

36 files changed:
gcc/doc/sourcebuild.texi
gcc/testsuite/gcc.dg/strlenopt-80.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-7.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-1.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-2.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-3.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-4.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-5.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-6.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-7.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-run-8.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-7.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-1.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-2.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-3.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-4.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-5.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-6.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-7.c
gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-run-8.c
gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
gcc/testsuite/lib/target-supports.exp

index c8611a0f2a0d33471aa8e5242be466eac0f77a79..51ca735ebeb072d9158692b24dbfd0e385ab0fa8 100644 (file)
@@ -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.
 
index a8adbf1eed5490dc2529dcf2b658442952d8ae9a..63d4eb17e4c3f41c842f9c71e39062f040eb10dd 100644 (file)
@@ -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)
index dfcc0e95320584bf9f38c80d6e997e8ca890eef2..f57d9457bd94c8c0e132be08c628300e5bbd6ca5 100644 (file)
@@ -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.  */
 
index e63f1bf23722e84c290d095bafb66a36687eb06b..19856407d277e7857aca83324be2b8147893a30e 100644 (file)
@@ -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.  */
 
index 4a99e3a3265499eab49f1b3315c4c3cbfa456456..eaea96d1eadd100c101b36ad4831470f40ce679e 100644 (file)
@@ -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.  */
 
index 9fbee6a4324b55900779122062304516cfe8c331..01991325ca8b6c2687056ba406108bcf6287a8ca 100644 (file)
@@ -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.  */
 
index d023a998c3ba302c144f5462aec46c7c28997e54..c68faa8c557a9c22cad305f0ba07efdd1f310929 100644 (file)
@@ -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.  */
 
index dbce90757e362ee0f9583b66a0001659d22e5fde..18076cc8218cf3c1e3df09f7af190fd81968518a 100644 (file)
@@ -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.  */
 
index 011b731f7c5a046da7ff9da76c6f719cfef2bc98..4e37c0a0095d30b65ac97f33c14b21b9a2c1f90b 100644 (file)
@@ -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.  */
 
index e56fd55f623f3f8ca022091df4a805ee7f546b67..0f3cd07226829345f4e6d56155456b8308175b12 100644 (file)
@@ -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.  */
 
index d1cd67f0c4d9613b2619e57cd1247548adc03901..2f091a311470837315a10c566a96fdf9e3fc6beb 100644 (file)
@@ -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.  */
 
index 815867b51d05d37bc75b2e0acc44f7c8bb21776d..03b172521a8fd19e26e33ddf4547911873083a47 100644 (file)
@@ -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.  */
 
index 5378d02c269754585a2ba5b0373f76e1e13d1074..5329422cd3aa08e92be74f1dbe5a960afe21fa55 100644 (file)
@@ -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.  */
 
index daed9a7774ee052d303524231cb51a7dbfd80441..2021372c68b6ff9776ff1e482bd2b4b919904317 100644 (file)
@@ -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.  */
 
index b5f24e68d8461c1e3443310ff25c7536ce27ca08..00ed61a5df1677d852010b359e35e9b47b5d2d25 100644 (file)
@@ -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.  */
 
index a3e6367384711f52f6a798a5cbb0f1226de95089..adbfd080c94e9e34a83af7c9b6f71c5ada680eb8 100644 (file)
@@ -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.  */
 
index f0b69d462a19f137a15f0fcf5ad47c91d52afcec..79ba4a1757987166d68e8815836d4bdc73851001 100644 (file)
@@ -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.  */
 
index 84abecf3f692a0272c792e8ed8ea5a78d36d3e0d..6e09b07d410195c67a5d8965ccdafa56fc4ca12d 100644 (file)
@@ -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.  */
 
index f01f1c54fa56685bc68b0025ff9e441b910b91cf..2818bac36a2f65e4206cff9a85764448be4ee376 100644 (file)
@@ -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.  */
 
index f546e97fa7df4ff8c5436884618c1740523d1ab2..b476910753f5834e495860e0ff7ba9d1cc23df0e 100644 (file)
@@ -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.  */
 
index 65142b3fecd0b8414e30b1be665c34caaf2e47ba..0f502423c88aecded39e3f1d5cfca680bf9cfced 100644 (file)
@@ -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.  */
 
index a4cc7aafaebb2ff8f38114fe4f5d5a64f19ec454..20ddfb392e11ef2cec90168e2b90c2f56f629354 100644 (file)
@@ -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.  */
 
index 4b0b9070c84d7070a7859991afe94060e5c0e326..0bad6938bf8c56b023fc196218bab7d66ae5b57f 100644 (file)
@@ -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.  */
 
index 65ddf2b098a692798210a49991dbd6b9a0137dcc..a73178e3ad39409a1acf69220ab0d8e5dc07b245 100644 (file)
@@ -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.  */
 
index e0e51d9a9724ce02afd4a449b76ef48eeec65b20..b50ff3cf6ef227470f5266432bd33971a60d2c0b 100644 (file)
@@ -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.  */
 
index 7fe0dd00431812590e60466047aee57d23d840e8..94f2aa48f57fc3bf259554f094661923ed6381d4 100644 (file)
@@ -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.  */
 
index 4e9bd0fbad30360cca9031c0773e8825d29d63aa..8950392d29b6ca80da752c3f00c7f8597184cbed 100644 (file)
@@ -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.  */
 
index 8e06b1b9304a8d0cc12a5b3babcbad06d2ef414c..1f295ae9d696b8d630322da91f7ed78bcb0f7a91 100644 (file)
@@ -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.  */
 
index 0b86f62834fb4e4ee5131cce83b967415a96f79c..1cb9b8f97c210bd7d16e4910a4bc9e8fe83715f5 100644 (file)
@@ -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.  */
 
index 359f31c9ed5eccb531f60efd4cd5b2b597a98f6d..029454afd27bfb1015612c80ed35e4f41291d3b4 100644 (file)
@@ -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.  */
 
index 7aa468e5b4e4b13f012f2acdda5f0cebfe73cdcf..02bb0a8964b87ceea0690970d7d29a73ece2a982 100644 (file)
@@ -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.  */
 
index 53a2ad07fb32476fb3a72e56f355c565b2bc8b50..9839ad9e1d9180b77d05e595c85ec1eb89f6be9b 100644 (file)
@@ -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.  */
 
index 0c21d137b9d58525a58e36377da43784782884b3..10ce7740fa78995a867ec61f472b1ff4b8743ec0 100644 (file)
@@ -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.  */
 
index 910784260677d5d21bad98bd55460bbee2c8d812..163bfb2f9bc121df80a3e705f0b67762e2b0c50d 100644 (file)
@@ -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.  */
 
index 554cd0c1beac08c51ad65fb75a29f1300ec25b00..3f477a07cb3263ca05cf095695f7cb5724b31e3b 100644 (file)
@@ -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
index 17a87db00076b7497245a1030734cca47f20a626..6ef53e07a453f27a20bf0ce029fdd4cd4edc33a3 100644 (file)
@@ -11575,6 +11575,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 { } {