Add two x86_64-w64-mingw32 code-generation tests covering the
set_active_preset lambda cases that previously triggered Win64
over-aligned stack slot sequences.
Also broaden the existing PR54412 AVX/AVX512 runtime tests so they run
on any target with the required ISA support.
Also add two Win64 AVX C++ runtime tests covering the high-half extract
cases seen in the PR54412 regressions.
gcc/testsuite/ChangeLog:
PR target/54412
* g++.target/i386/pr54412-setactivepreset.C: New test.
* g++.target/i386/pr54412-setactivepreset-2.C: New test.
* gcc.target/i386/pr54412-avx512-aligned64.c: Run on all
targets with AVX512F support.
* gcc.target/i386/pr54412-callee-byref-param.c: Run on all
targets with AVX support.
* gcc.target/i386/pr54412-o2-by-value-cases.c: Likewise.
* gcc.target/i386/pr54412-sret-no-args.c: Likewise.
* gcc.target/i386/pr54412-v4d-o0-aligned-locals.c: Likewise.
* g++.target/i386/pr54412-highpart-extract.C: New test.
* g++.target/i386/pr54412-highpart-extract-int.C: New test.
Signed-off-by: Oleg Tolmatcev <[email protected]>
---
.../i386/pr54412-highpart-extract-int.C | 78 +++++++++++++++++++
.../i386/pr54412-highpart-extract.C | 77 ++++++++++++++++++
.../i386/pr54412-setactivepreset-2.C | 58 ++++++++++++++
.../g++.target/i386/pr54412-setactivepreset.C | 45 +++++++++++
.../i386/pr54412-avx512-aligned64.c | 3 +-
.../i386/pr54412-callee-byref-param.c | 3 +-
.../i386/pr54412-o2-by-value-cases.c | 3 +-
.../gcc.target/i386/pr54412-sret-no-args.c | 3 +-
.../i386/pr54412-v4d-o0-aligned-locals.c | 3 +-
9 files changed, 263 insertions(+), 10 deletions(-)
create mode 100644 gcc/testsuite/g++.target/i386/pr54412-highpart-extract-int.C
create mode 100644 gcc/testsuite/g++.target/i386/pr54412-highpart-extract.C
create mode 100644 gcc/testsuite/g++.target/i386/pr54412-setactivepreset-2.C
create mode 100644 gcc/testsuite/g++.target/i386/pr54412-setactivepreset.C
diff --git a/gcc/testsuite/g++.target/i386/pr54412-highpart-extract-int.C
b/gcc/testsuite/g++.target/i386/pr54412-highpart-extract-int.C
new file mode 100644
index 00000000000..cb963c3a7d8
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr54412-highpart-extract-int.C
@@ -0,0 +1,78 @@
+/* PR target/54412 */
+/* { dg-do run { target { x86_64-*-mingw* && avx } } } */
+/* { dg-options "-O2 -mavx -std=gnu++17 -fno-omit-frame-pointer" } */
+
+#include "avx-check.h"
+
+typedef int v8si __attribute__ ((vector_size (32), aligned (32)));
+
+static inline v8si
+make_v8si (int a, int b, int c, int d, int e, int f, int g, int h)
+{
+ return (v8si) { a, b, c, d, e, f, g, h };
+}
+
+struct Vec256b
+{
+ v8si ymm;
+
+ Vec256b () = default;
+ explicit Vec256b (v8si x) : ymm (x) {}
+
+ __attribute__ ((noinline, noclone))
+ operator v8si () const
+ {
+ return ymm;
+ }
+};
+
+struct Vec8i
+{
+ v8si ymm;
+
+ Vec8i () = default;
+
+ __attribute__ ((noinline, noclone))
+ explicit Vec8i (v8si x) : ymm (x) {}
+
+ __attribute__ ((noinline, noclone))
+ int
+ extract (int index) const
+ {
+ int elems[8];
+
+ __builtin_memcpy (elems, &ymm, sizeof (elems));
+ return elems[index & 7];
+ }
+};
+
+struct Vec16i
+{
+ Vec256b z0;
+ Vec256b z1;
+
+ Vec16i (v8si a, v8si b) : z0 (a), z1 (b) {}
+
+ __attribute__ ((noinline, noclone))
+ int
+ extract (int index) const
+ {
+ if ((unsigned) index < 8)
+ return Vec8i (z0).extract (index);
+ else
+ return Vec8i (z1).extract (index - 8);
+ }
+};
+
+static void
+avx_test ()
+{
+ Vec16i x (make_v8si (1, 2, 3, 4, 5, 6, 7, 8),
+ make_v8si (9, 10, 11, 12, 13, 14, 15, 16));
+
+ if (x.extract (2) != 3)
+ __builtin_abort ();
+
+ if (x.extract (10) != 11)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.target/i386/pr54412-highpart-extract.C
b/gcc/testsuite/g++.target/i386/pr54412-highpart-extract.C
new file mode 100644
index 00000000000..e4881cbeb97
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr54412-highpart-extract.C
@@ -0,0 +1,77 @@
+/* PR target/54412 */
+/* { dg-do run { target { x86_64-*-mingw* && avx } } } */
+/* { dg-options "-O2 -mavx -std=gnu++17 -fno-omit-frame-pointer" } */
+
+#include "avx-check.h"
+
+typedef long long v4di __attribute__ ((vector_size (32), aligned (32)));
+
+static inline v4di
+make_v4di (long long a, long long b, long long c, long long d)
+{
+ return (v4di) { a, b, c, d };
+}
+
+struct Vec256b
+{
+ v4di ymm;
+
+ Vec256b () = default;
+ explicit Vec256b (v4di x) : ymm (x) {}
+
+ __attribute__ ((noinline, noclone))
+ operator v4di () const
+ {
+ return ymm;
+ }
+};
+
+struct Vec4q
+{
+ v4di ymm;
+
+ Vec4q () = default;
+
+ __attribute__ ((noinline, noclone))
+ explicit Vec4q (v4di x) : ymm (x) {}
+
+ __attribute__ ((noinline, noclone))
+ long long
+ extract (int index) const
+ {
+ long long elems[4];
+
+ __builtin_memcpy (elems, &ymm, sizeof (elems));
+ return elems[index & 3];
+ }
+};
+
+struct Vec8q
+{
+ Vec256b z0;
+ Vec256b z1;
+
+ Vec8q (v4di a, v4di b) : z0 (a), z1 (b) {}
+
+ __attribute__ ((noinline, noclone))
+ long long
+ extract (int index) const
+ {
+ if ((unsigned) index < 4)
+ return Vec4q (z0).extract (index);
+ else
+ return Vec4q (z1).extract (index - 4);
+ }
+};
+
+static void
+avx_test ()
+{
+ Vec8q x (make_v4di (1, 2, 3, 4), make_v4di (5, 6, 7, 8));
+
+ if (x.extract (1) != 2)
+ __builtin_abort ();
+
+ if (x.extract (5) != 6)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.target/i386/pr54412-setactivepreset-2.C
b/gcc/testsuite/g++.target/i386/pr54412-setactivepreset-2.C
new file mode 100644
index 00000000000..4f0abec6ec0
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr54412-setactivepreset-2.C
@@ -0,0 +1,58 @@
+/* PR target/54412 */
+/* { dg-do compile { target x86_64-*-mingw* } } */
+/* { dg-options "-O2 -mavx2 -masm=intel -std=gnu++17 -fno-omit-frame-pointer"
} */
+/* { dg-final { scan-assembler-not {lea[ \t]+r8, 63\[rsp\]} } } */
+/* { dg-final { scan-assembler-not {and[ \t]+r8, -32} } } */
+/* { dg-final { scan-assembler-not {vmovdqa[ \t]+YMMWORD PTR \[r8\], ymm0} } }
*/
+
+template <typename _InputIterator, typename _Predicate>
+__attribute__ ((noinline, noclone))
+_InputIterator
+find_if_inner (_InputIterator first, _InputIterator last, _Predicate &pred)
+{
+ asm volatile ("" : : "g" (first), "g" (last), "g" (&pred) : "memory");
+ return first;
+}
+
+template <typename _InputIterator, typename _Predicate>
+__attribute__ ((noinline, noclone))
+_InputIterator
+find_if (_InputIterator first, _InputIterator last, _Predicate pred)
+{
+ return find_if_inner (first, last, pred);
+}
+
+struct basic_string_view
+{
+ int n;
+ void *_r;
+};
+
+struct dummy_iter
+{
+ int n;
+};
+
+dummy_iter first;
+dummy_iter last;
+basic_string_view cit_name;
+basic_string_view cit_category;
+
+struct ic_
+{
+ void
+ set_active_preset (basic_string_view category,
+ basic_string_view name,
+ bool)
+ {
+ find_if (first, last, [category, name] (dummy_iter) { return false; });
+ }
+};
+
+ic_ cit_pack;
+
+void
+it (bool update_visibility)
+{
+ cit_pack.set_active_preset (cit_category, cit_name, update_visibility);
+}
diff --git a/gcc/testsuite/g++.target/i386/pr54412-setactivepreset.C
b/gcc/testsuite/g++.target/i386/pr54412-setactivepreset.C
new file mode 100644
index 00000000000..c0b989fdb2c
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr54412-setactivepreset.C
@@ -0,0 +1,45 @@
+/* PR target/54412 */
+/* { dg-do compile { target x86_64-*-mingw* } } */
+/* { dg-options "-O2 -mavx2 -masm=intel -std=gnu++17 -fno-omit-frame-pointer"
} */
+/* { dg-final { scan-assembler-not {vmovdqa[ \t]+YMMWORD PTR -[0-9]+\[rbp\],
ymm[0-9]+} } } */
+
+template <typename _InputIterator, typename _Predicate>
+__attribute__ ((noinline, noclone))
+void
+find_if (_InputIterator first, _InputIterator last, _Predicate pred)
+{
+ asm volatile ("" : : "g" (first), "g" (last), "g" (&pred) : "memory");
+}
+
+struct basic_string_view
+{
+ int n;
+ void *_r;
+
+ int cbegin () const;
+ int cend () const;
+};
+
+basic_string_view presets;
+basic_string_view cit_name;
+basic_string_view cit_category;
+
+struct ic_
+{
+ void
+ set_active_preset (basic_string_view category,
+ basic_string_view name,
+ bool)
+ {
+ find_if (&basic_string_view::cbegin, &basic_string_view::cend,
+ [category, name] {});
+ }
+};
+
+ic_ cit_pack;
+
+void
+it (bool update_visibility)
+{
+ cit_pack.set_active_preset (cit_category, cit_name, update_visibility);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr54412-avx512-aligned64.c
b/gcc/testsuite/gcc.target/i386/pr54412-avx512-aligned64.c
index c496f76e76e..18fc38e04bb 100644
--- a/gcc/testsuite/gcc.target/i386/pr54412-avx512-aligned64.c
+++ b/gcc/testsuite/gcc.target/i386/pr54412-avx512-aligned64.c
@@ -1,6 +1,5 @@
/* PR target/54412 */
-/* { dg-do run { target { avx512f && { ! ia32 } } } } */
-/* { dg-skip-if "PR target/54412 exercises the Win64 ABI" { ! x86_64-*-mingw*
} } */
+/* { dg-do run { target avx512f } } */
/* { dg-options "-O0 -mavx512f" } */
#include "avx512-check.h"
diff --git a/gcc/testsuite/gcc.target/i386/pr54412-callee-byref-param.c
b/gcc/testsuite/gcc.target/i386/pr54412-callee-byref-param.c
index 1eb1164ff9b..596f19dedb5 100644
--- a/gcc/testsuite/gcc.target/i386/pr54412-callee-byref-param.c
+++ b/gcc/testsuite/gcc.target/i386/pr54412-callee-byref-param.c
@@ -1,6 +1,5 @@
/* PR target/54412 */
-/* { dg-do run { target { avx && { ! ia32 } } } } */
-/* { dg-skip-if "PR target/54412 exercises the Win64 ABI" { ! x86_64-*-mingw*
} } */
+/* { dg-do run { target avx } } */
/* { dg-options "-O0 -mavx" } */
#include "avx-check.h"
diff --git a/gcc/testsuite/gcc.target/i386/pr54412-o2-by-value-cases.c
b/gcc/testsuite/gcc.target/i386/pr54412-o2-by-value-cases.c
index cdcca7b31f4..eb2088b7127 100644
--- a/gcc/testsuite/gcc.target/i386/pr54412-o2-by-value-cases.c
+++ b/gcc/testsuite/gcc.target/i386/pr54412-o2-by-value-cases.c
@@ -1,6 +1,5 @@
/* PR target/54412 */
-/* { dg-do run { target { avx && { ! ia32 } } } } */
-/* { dg-skip-if "PR target/54412 exercises the Win64 ABI" { ! x86_64-*-mingw*
} } */
+/* { dg-do run { target avx } } */
/* { dg-options "-O2 -mavx -std=gnu99" } */
#include "avx-check.h"
diff --git a/gcc/testsuite/gcc.target/i386/pr54412-sret-no-args.c
b/gcc/testsuite/gcc.target/i386/pr54412-sret-no-args.c
index af23e6a99a0..b4c9f037815 100644
--- a/gcc/testsuite/gcc.target/i386/pr54412-sret-no-args.c
+++ b/gcc/testsuite/gcc.target/i386/pr54412-sret-no-args.c
@@ -1,6 +1,5 @@
/* PR target/54412 */
-/* { dg-do run { target { avx && { ! ia32 } } } } */
-/* { dg-skip-if "PR target/54412 exercises the Win64 ABI" { ! x86_64-*-mingw*
} } */
+/* { dg-do run { target avx } } */
/* { dg-options "-O2 -mavx -std=gnu99" } */
#include "avx-check.h"
diff --git a/gcc/testsuite/gcc.target/i386/pr54412-v4d-o0-aligned-locals.c
b/gcc/testsuite/gcc.target/i386/pr54412-v4d-o0-aligned-locals.c
index 74675f53bcb..47cc98ce502 100644
--- a/gcc/testsuite/gcc.target/i386/pr54412-v4d-o0-aligned-locals.c
+++ b/gcc/testsuite/gcc.target/i386/pr54412-v4d-o0-aligned-locals.c
@@ -1,6 +1,5 @@
/* PR target/54412 */
-/* { dg-do run { target { avx && { ! ia32 } } } } */
-/* { dg-skip-if "PR target/54412 exercises the Win64 ABI" { ! x86_64-*-mingw*
} } */
+/* { dg-do run { target avx } } */
/* { dg-options "-O0 -mavx" } */
#include "avx-check.h"
--
2.54.0.windows.1