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(+)
@@ -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.
@@ -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)
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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. */
@@ -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
@@ -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 { } {