From: Andrei Nichita Tirziu <[email protected]>
Add tests that verify the vectorizer dump and assembly output.
They expect the MATCH pattern to be identified and the initial
code to be replaced with the new conditional IFNs.
We also expect the assembly to contain the `match` or `nmatch`
SVE instructions.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve2/match_char_small.c: New test.
* gcc.target/aarch64/sve2/match_char_small_run.c: New test.
* gcc.target/aarch64/sve2/match_short_int_small.c: New test.
* gcc.target/aarch64/sve2/match_short_int_small_run.c: New test.
* gcc.target/aarch64/sve2/match_short_int_medium.c: New test.
* gcc.target/aarch64/sve2/match_short_int_medium_run.c: New test.
* gcc.target/aarch64/sve2/match_short_int_large.c: New test.
* gcc.target/aarch64/sve2/match_short_int_large_run.c: New test.
* gcc.target/aarch64/sve2/nmatch_short_int_small.c: New test.
* gcc.target/aarch64/sve2/nmatch_short_int_small_run.c: New test.
Change-Id: If0880d8228453c5f01ba503ac04f3e9256f7f362
---
.../aarch64/sve2/match_char_small.c | 44 ++++++++++++
.../aarch64/sve2/match_char_small_run.c | 39 ++++++++++
.../aarch64/sve2/match_short_int_large.c | 60 ++++++++++++++++
.../aarch64/sve2/match_short_int_large_run.c | 71 +++++++++++++++++++
.../aarch64/sve2/match_short_int_medium.c | 58 +++++++++++++++
.../aarch64/sve2/match_short_int_medium_run.c | 69 ++++++++++++++++++
.../aarch64/sve2/match_short_int_small.c | 48 +++++++++++++
.../aarch64/sve2/match_short_int_small_run.c | 53 ++++++++++++++
.../aarch64/sve2/nmatch_short_int_small.c | 55 ++++++++++++++
.../aarch64/sve2/nmatch_short_int_small_run.c | 53 ++++++++++++++
10 files changed, 550 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_char_small_run.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large_run.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium_run.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small_run.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small.c
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small_run.c
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c
new file mode 100644
index 000000000000..abe9e73cd9a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c
@@ -0,0 +1,44 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 3 invariants, of type `char` (8-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants is small enough
+ * to only use a MATCH instruction.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vect-details --save-temps" } */
+
+#include <stdio.h>
+#include <string.h>
+
+char s[160];
+
+int foo (int n, char ch)
+{
+ char sum = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (s[i] == 'a' || s[i] == 'e' || s[i] == ch)
+ sum++;
+ }
+ return sum;
+}
+
+int main ()
+{
+ strncpy (s, "Hello World", 160);
+ printf ("%d\n", foo (160, 'o'));
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "SLP MATCH pattern: Successfully built
replacement for statement" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times {Choosing conditional \(COND_MATCH_EQ\)
version of original IFN MATCH_EQ} 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Transform phase: For IFN COND_MATCH_EQ,
got mask_index = 2 , else_index = 3 , len_index = -1 , bias_index = 0" 1 "vect"
} } */
+
+/* { dg-final { scan-assembler-times {\tmatch\tp[0-9]+\.b, p[0-9]+/z,
z[0-9]+\.b, z[0-9]+\.b\n} 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small_run.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small_run.c
new file mode 100644
index 000000000000..d6691f3f20bd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small_run.c
@@ -0,0 +1,39 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 3 invariants, of type `char` (8-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants is small enough
+ * to only use a MATCH instruction.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+char s[160];
+
+int foo (int n, char ch)
+{
+ char sum = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (s[i] == 'a' || s[i] == 'e' || s[i] == ch)
+ sum++;
+ }
+ return sum;
+}
+
+int main ()
+{
+ strncpy (s, "Hello World", 160);
+ assert (foo (160, 'o') == 3);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large.c
new file mode 100644
index 000000000000..10033e3abb01
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large.c
@@ -0,0 +1,60 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 20 invariants, of type `short int` (16-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants should require
+ * three MATCH instructions.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vect-details --save-temps" } */
+
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||
+ a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||
+ a[i] == 30 || a[i] == 40 || a[i] == 110 || a[i] == 120 ||
+ a[i] == 130 || a[i] == 140 || a[i] == 150 || a[i] == 160 ||
+ a[i] == 170 || a[i] == 180 || a[i] == 190 || a[i] == 0)
+ {
+ s += a[i];
+ }
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ {
+ if (i % 4 == 0)
+ a[i] = 10;
+ else if (i % 4 == 1)
+ a[i] = 100;
+ else if (i % 4 == 2)
+ a[i] = 90;
+ else
+ a[i] = 1000;
+ }
+
+ printf ("%d\n", foo (160, 100, 99));
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "SLP MATCH pattern: Successfully built
replacement for statement" 4 "vect" } } */
+/* { dg-final { scan-tree-dump-times {Choosing conditional \(COND_MATCH_EQ\)
version of original IFN MATCH_EQ} 6 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Transform phase: For IFN COND_MATCH_EQ,
got mask_index = 2 , else_index = 3 , len_index = -1 , bias_index = 0" 6 "vect"
} } */
+
+/* { dg-final { scan-assembler-times {\tmatch\tp[0-9]+\.h, p[0-9]+/z,
z[0-9]+\.h, z[0-9]+\.h\n} 6 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large_run.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large_run.c
new file mode 100644
index 000000000000..64be5ecb51b3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large_run.c
@@ -0,0 +1,71 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 20 invariants, of type `short int` (16-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants should require
+ * three MATCH instructions.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+#include <assert.h>
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||
+ a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||
+ a[i] == 30 || a[i] == 40 || a[i] == 110 || a[i] == 120 ||
+ a[i] == 130 || a[i] == 140 || a[i] == 150 || a[i] == 160 ||
+ a[i] == 170 || a[i] == 180 || a[i] == 190 || a[i] == 0)
+ {
+ s += a[i];
+ }
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ {
+ if (i % 4 == 0)
+ a[i] = 10;
+ else if (i % 4 == 1)
+ a[i] = 9;
+ else if (i % 4 == 2)
+ a[i] = 60;
+ else
+ a[i] = 1000;
+ }
+
+ // Only match elements that are 10 in the array.
+ assert (foo (160, 0, 0) == 400);
+ assert (foo (160, 0, 10) == 400);
+ assert (foo (160, 66, 33) == 400);
+
+ // Only match elements that are 10 or 60 in the array.
+ assert (foo (160, 60, 0) == 2800);
+ assert (foo (160, 0, 60) == 2800);
+ assert (foo (160, 59, 0) == 2800);
+ assert (foo (160, 60, 10) == 2800);
+ assert (foo (160, 10, 60) == 2800);
+ assert (foo (160, 59, 60) == 2800);
+
+ // Match all elements in the array, apart from those whose value is 1000.
+ assert (foo (160, 60, 9) == 3160);
+ assert (foo (160, 9, 60) == 3160);
+ assert (foo (160, 59, 9) == 3160);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium.c
new file mode 100644
index 000000000000..8427e229acae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium.c
@@ -0,0 +1,58 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 10 invariants, of type `short int` (16-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants should require
+ * two MATCH instructions.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vect-details --save-temps" } */
+
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||
+ a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||
+ a[i] == 30 || a[i] == 40)
+ {
+ s += a[i];
+ }
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ {
+ if (i % 4 == 0)
+ a[i] = 10;
+ else if (i % 4 == 1)
+ a[i] = 100;
+ else if (i % 4 == 2)
+ a[i] = 90;
+ else
+ a[i] = 1000;
+ }
+
+ printf ("%d\n", foo (160, 100, 99));
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "SLP MATCH pattern: Successfully built
replacement for statement" 4 "vect" } } */
+/* { dg-final { scan-tree-dump-times {Choosing conditional \(COND_MATCH_EQ\)
version of original IFN MATCH_EQ} 4 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Transform phase: For IFN COND_MATCH_EQ,
got mask_index = 2 , else_index = 3 , len_index = -1 , bias_index = 0" 4 "vect"
} } */
+
+/* { dg-final { scan-assembler-times {\tmatch\tp[0-9]+\.h, p[0-9]+/z,
z[0-9]+\.h, z[0-9]+\.h\n} 4 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium_run.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium_run.c
new file mode 100644
index 000000000000..473fcd621973
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium_run.c
@@ -0,0 +1,69 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 10 invariants, of type `short int` (16-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants should require
+ * two MATCH instructions.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+#include <assert.h>
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||
+ a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||
+ a[i] == 30 || a[i] == 40)
+ {
+ s += a[i];
+ }
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ {
+ if (i % 4 == 0)
+ a[i] = 10;
+ else if (i % 4 == 1)
+ a[i] = 9;
+ else if (i % 4 == 2)
+ a[i] = 60;
+ else
+ a[i] = 1000;
+ }
+
+ // Only match elements that are 10 in the array.
+ assert (foo (160, 0, 0) == 400);
+ assert (foo (160, 0, 10) == 400);
+ assert (foo (160, 66, 33) == 400);
+
+ // Only match elements that are 10 or 60 in the array.
+ assert (foo (160, 60, 0) == 2800);
+ assert (foo (160, 0, 60) == 2800);
+ assert (foo (160, 59, 0) == 2800);
+ assert (foo (160, 60, 10) == 2800);
+ assert (foo (160, 10, 60) == 2800);
+ assert (foo (160, 59, 60) == 2800);
+
+ // Match all elements in the array, apart from those whose value is 1000.
+ assert (foo (160, 60, 9) == 3160);
+ assert (foo (160, 9, 60) == 3160);
+ assert (foo (160, 59, 9) == 3160);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small.c
new file mode 100644
index 000000000000..efae8f633201
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small.c
@@ -0,0 +1,48 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 4 invariants, of type `short int` (16-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants is small enough
+ * to only use a MATCH instruction.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vect-details --save-temps" } */
+
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y, short int z)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] == x || a[i] == y || a[i] == 7 || a[i] == z)
+ s++;
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ if (i % 2 == 0)
+ a[i] = 10;
+ else
+ a[i] = 30;
+
+ printf ("%d\n", foo (160, 0, 10, 40));
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "SLP MATCH pattern: Successfully built
replacement for statement" 2 "vect" } } */
+/* { dg-final { scan-tree-dump-times {Choosing conditional \(COND_MATCH_EQ\)
version of original IFN MATCH_EQ} 2 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Transform phase: For IFN COND_MATCH_EQ,
got mask_index = 2 , else_index = 3 , len_index = -1 , bias_index = 0" 2 "vect"
} } */
+
+/* { dg-final { scan-assembler-times {\tmatch\tp[0-9]+\.h, p[0-9]+/z,
z[0-9]+\.h, z[0-9]+\.h\n} 2 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small_run.c
b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small_run.c
new file mode 100644
index 000000000000..39d57154fe8e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small_run.c
@@ -0,0 +1,53 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 4 invariants, of type `short int` (16-bits).
+ *
+ * A Match-EQ pattern should be identified and replaced with
+ * a MATCH instruction. In this test, the number of invariants is small enough
+ * to only use a MATCH instruction.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+#include <assert.h>
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y, short int z)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] == x || a[i] == y || a[i] == 7 || a[i] == z)
+ s++;
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ if (i % 2 == 0)
+ a[i] = 10;
+ else
+ a[i] = 30;
+
+ assert (foo (160, 0, 0, 0) == 0);
+ assert (foo (160, 40, 70, 90) == 0);
+
+ assert (foo (160, 10, 0, 0) == 80);
+ assert (foo (160, 0, 10, 0) == 80);
+ assert (foo (160, 0, 0, 10) == 80);
+
+ assert (foo (160, 70, 0, 10) == 80);
+ assert (foo (160, 10, 70, 0) == 80);
+
+ assert (foo (160, 30, 0, 10) == 160);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small.c
b/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small.c
new file mode 100644
index 000000000000..e63967cbb698
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small.c
@@ -0,0 +1,55 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 4 invariants, of type `short int` (16-bits).
+ *
+ * A Match-NE pattern should be identified and replaced with
+ * a NMATCH instruction. In this test, the number of invariants is small enough
+ * to only use a NMATCH instruction.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ *
+ * Note: the code is sometimes optimized from an AND-of-NE to
+ * an OR-of-EQ structure, which is the reason why this test also expects the
+ * use of a `match` instruction (in addition to `nmatch`).
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vect-details --save-temps" } */
+
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y, short int z)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] != x && a[i] != y && a[i] != 7 && a[i] != z)
+ s++;
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ if (i % 2 == 0)
+ a[i] = 70;
+ else
+ a[i] = 30;
+
+ printf ("%d\n", foo (160, 0, 10, 40));
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "SLP MATCH pattern: Successfully built
replacement for statement" 2 "vect" } } */
+/* { dg-final { scan-tree-dump-times {Choosing conditional \(COND_MATCH_NE\)
version of original IFN MATCH_NE} 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times {Choosing conditional \(COND_MATCH_EQ\)
version of original IFN MATCH_EQ} 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Transform phase: For IFN COND_MATCH_NE,
got mask_index = 2 , else_index = 3 , len_index = -1 , bias_index = 0" 1 "vect"
} } */
+/* { dg-final { scan-tree-dump-times "Transform phase: For IFN COND_MATCH_EQ,
got mask_index = 2 , else_index = 3 , len_index = -1 , bias_index = 0" 1 "vect"
} } */
+
+/* { dg-final { scan-assembler-times {\tnmatch\tp[0-9]+\.h, p[0-9]+/z,
z[0-9]+\.h, z[0-9]+\.h\n} 1 } } */
+/* { dg-final { scan-assembler-times {\tmatch\tp[0-9]+\.h, p[0-9]+/z,
z[0-9]+\.h, z[0-9]+\.h\n} 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small_run.c
b/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small_run.c
new file mode 100644
index 000000000000..511b1fe9e518
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small_run.c
@@ -0,0 +1,53 @@
+/**
+ * Test for vectorizer MATCH pattern.
+ *
+ * Test with 4 invariants, of type `short int` (16-bits).
+ *
+ * A Match-NE pattern should be identified and replaced with
+ * a NMATCH instruction. In this test, the number of invariants is small enough
+ * to only use a NMATCH instruction.
+ *
+ * Compile for: ARM-v9, which has SVE2 included.
+ */
+
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+#include <assert.h>
+#include <stdio.h>
+
+short int a[160];
+
+int foo (int n, short int x, short int y, short int z)
+{
+ short int s = 0;
+ for (int i = 0; i < n; i++)
+ {
+ if (a[i] != x && a[i] != y && a[i] != 7 && a[i] != z)
+ s++;
+ }
+ return s;
+}
+
+int main ()
+{
+ for (int i = 0; i < 160; i++)
+ if (i % 2 == 0)
+ a[i] = 70;
+ else
+ a[i] = 30;
+
+ assert (foo (160, 0, 0, 0) == 160);
+ assert (foo (160, 40, 60, 90) == 160);
+
+ assert (foo (160, 70, 0, 0) == 80);
+ assert (foo (160, 0, 70, 0) == 80);
+ assert (foo (160, 0, 0, 30) == 80);
+
+ assert (foo (160, 70, 0, 10) == 80);
+ assert (foo (160, 10, 70, 0) == 80);
+
+ assert (foo (160, 30, 0, 70) == 0);
+
+ return 0;
+}
--
2.52.0