{"id":2198184,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2198184/?format=json","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.0/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<bmm.hfy4c1w8xq.gcc.gcc-TEST.why.135.2.7@forge-stage.sourceware.org>","date":"2026-02-19T14:02:08","name":"[v2,7/7,Vectorizer] : SLP MATCH Pattern: Add tests","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"702a818f3e5961675b22e9808d3342147b5b0938","submitter":{"id":92460,"url":"http://patchwork.ozlabs.org/api/1.0/people/92460/?format=json","name":"Andrei Tirziu via Sourceware Forge","email":"forge-bot+why@forge-stage.sourceware.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hfy4c1w8xq.gcc.gcc-TEST.why.135.2.7@forge-stage.sourceware.org/mbox/","series":[{"id":492684,"url":"http://patchwork.ozlabs.org/api/1.0/series/492684/?format=json","date":"2026-02-19T14:02:02","name":"Vectorizer: New SLP Pattern","version":2,"mbox":"http://patchwork.ozlabs.org/series/492684/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2198184/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org","sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org","server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fGwCC6bRLz1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 20 Feb 2026 01:05:59 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 0F3CF4B9DB78\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Feb 2026 14:05:58 +0000 (GMT)","from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 2E7C64B9DB56\n for <gcc-patches@gcc.gnu.org>; Thu, 19 Feb 2026 14:02:39 +0000 (GMT)","from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id DE2B644235;\n Thu, 19 Feb 2026 14:02:36 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 0F3CF4B9DB78","OpenDKIM Filter v2.11.0 sourceware.org 2E7C64B9DB56"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 2E7C64B9DB56","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 2E7C64B9DB56","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771509759; cv=none;\n b=c2qIIBq6/Ffqkogz0MDTBL0Wj9TIQ1h1SUWCIwT9nVYO3Zdc1hZ0Hdpg0ZxROvYje0uC4dPBZRRt1nBYfttIuXvi+mbNsRSukm16nEFCqd82Y08i9uFBi2sdy04c1rs8LBp01Et4oV+R+/rWRIjiQbogGWxWNDUiYSNYotuLJo8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1771509759; c=relaxed/simple;\n bh=dpKFs44V4Tb2913gz3ZBwBIfq/B4q4w5frBy7I+GeZc=;\n h=From:Date:Subject:To:Message-ID;\n b=RLT9UvUuIX+loNz9M1jtzlgYJivQ+yAdPGk//tH5QQUPQiZFZrsPMnMT39nGjxUL+lJ5XeW/hBBdvm670a16rzS6hhFCTJJcQlY/zQ1bnAknlSBVoYf6WdlRTJ1EpIQ0PojbHGVAY3QU2ABEyKWUhGB+W1w8cKm1OKpvUO0jpYY=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"Andrei Tirziu via Sourceware Forge\n <forge-bot+why@forge-stage.sourceware.org>","Date":"Thu, 19 Feb 2026 14:02:08 +0000","Subject":"[PATCH v2 7/7] [Vectorizer]: SLP MATCH Pattern: Add tests","To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>","Cc":"Tamar Christina <tamar.christina@arm.com>,\n Victor Do Nascimento <victor.donascimento@arm.com>","Message-ID":"\n <bmm.hfy4c1w8xq.gcc.gcc-TEST.why.135.2.7@forge-stage.sourceware.org>","X-Mailer":"batrachomyomachia","X-Pull-Request-Organization":"gcc","X-Pull-Request-Repository":"gcc-TEST","X-Pull-Request":"https://forge.sourceware.org/gcc/gcc-TEST/pulls/135","References":"\n <bmm.hfy4c1w8xq.gcc.gcc-TEST.why.135.2.0@forge-stage.sourceware.org>","In-Reply-To":"\n <bmm.hfy4c1w8xq.gcc.gcc-TEST.why.135.2.0@forge-stage.sourceware.org>","X-Patch-URL":"\n https://forge.sourceware.org/why/gcc/commit/9de0c72932c609f582ab88807528c475f0f095ed","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>,\n Tamar Christina <tamar.christina@arm.com>,\n Victor Do Nascimento <victor.donascimento@arm.com>,\n andreinichita.tirziu@arm.com","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"From: Andrei Nichita Tirziu <andreinichita.tirziu@arm.com>\n\nAdd tests that verify the vectorizer dump and assembly output.\nThey expect the MATCH pattern to be identified and the initial\ncode to be replaced with the new conditional IFNs.\nWe also expect the assembly to contain the `match` or `nmatch`\nSVE instructions.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.target/aarch64/sve2/match_char_small.c: New test.\n\t* gcc.target/aarch64/sve2/match_char_small_run.c: New test.\n\t* gcc.target/aarch64/sve2/match_short_int_small.c: New test.\n\t* gcc.target/aarch64/sve2/match_short_int_small_run.c: New test.\n\t* gcc.target/aarch64/sve2/match_short_int_medium.c: New test.\n\t* gcc.target/aarch64/sve2/match_short_int_medium_run.c: New test.\n\t* gcc.target/aarch64/sve2/match_short_int_large.c: New test.\n\t* gcc.target/aarch64/sve2/match_short_int_large_run.c: New test.\n\t* gcc.target/aarch64/sve2/nmatch_short_int_small.c: New test.\n\t* gcc.target/aarch64/sve2/nmatch_short_int_small_run.c: New test.\n---\n .../aarch64/sve2/match_char_small.c           | 44 ++++++++++++\n .../aarch64/sve2/match_char_small_run.c       | 39 ++++++++++\n .../aarch64/sve2/match_short_int_large.c      | 60 ++++++++++++++++\n .../aarch64/sve2/match_short_int_large_run.c  | 71 +++++++++++++++++++\n .../aarch64/sve2/match_short_int_medium.c     | 58 +++++++++++++++\n .../aarch64/sve2/match_short_int_medium_run.c | 69 ++++++++++++++++++\n .../aarch64/sve2/match_short_int_small.c      | 48 +++++++++++++\n .../aarch64/sve2/match_short_int_small_run.c  | 53 ++++++++++++++\n .../aarch64/sve2/nmatch_short_int_small.c     | 55 ++++++++++++++\n .../aarch64/sve2/nmatch_short_int_small_run.c | 53 ++++++++++++++\n 10 files changed, 550 insertions(+)\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_char_small_run.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large_run.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium_run.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small_run.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small.c\n create mode 100644 gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small_run.c","diff":"diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c\nnew file mode 100644\nindex 000000000000..6760dc88b18e\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small.c\n@@ -0,0 +1,44 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 3 invariants, of type `char` (8-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants is small enough\n+ * to only use a MATCH instruction.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -fdump-tree-vect-details --save-temps\" } */\n+\n+#include <stdio.h>\n+#include <string.h>\n+\n+char s[160];\n+\n+int foo (int n, char ch)\n+{\n+    char sum = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (s[i] == 'a' || s[i] == 'e' || s[i] == ch)\n+\t    sum++;\n+    }\n+    return sum;\n+}\n+\n+int main ()\n+{\n+    strncpy (s, \"Hello World\", 160);\n+    printf (\"%d\\n\", foo (160, 'o'));\n+\n+    return 0;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"SLP MATCH pattern: Successfully built replacement for statement\" 1 \"vect\" } } */\n+/* { dg-final { scan-tree-dump-times {Choosing conditional \\(COND_MATCH_EQ\\) version of original IFN MATCH_EQ} 1 \"vect\" } } */\n+/* { 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\" } } */\n+\n+/* { dg-final { scan-assembler-times {\\tmatch\\tp[0-9]+\\.b, p[0-9]+/z, z[0-9]+\\.b, z[0-9]+\\.b\\n} 1 } } */\ndiff --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\nnew file mode 100644\nindex 000000000000..a8cd3d763f81\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_char_small_run.c\n@@ -0,0 +1,39 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 3 invariants, of type `char` (8-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants is small enough\n+ * to only use a MATCH instruction.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do run } */\n+/* { dg-options \"-O3\" } */\n+\n+#include <assert.h>\n+#include <stdio.h>\n+#include <string.h>\n+\n+char s[160];\n+\n+int foo (int n, char ch)\n+{\n+    char sum = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (s[i] == 'a' || s[i] == 'e' || s[i] == ch)\n+\t    sum++;\n+    }\n+    return sum;\n+}\n+\n+int main ()\n+{\n+    strncpy (s, \"Hello World\", 160);\n+    assert (foo (160, 'o') == 3);\n+\n+    return 0;\n+}\ndiff --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\nnew file mode 100644\nindex 000000000000..d7fa458ec21b\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large.c\n@@ -0,0 +1,60 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 20 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants should require\n+ * three MATCH instructions.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -fdump-tree-vect-details --save-temps\" } */\n+\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||\n+\t    a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||\n+\t    a[i] == 30 || a[i] == 40 || a[i] == 110 || a[i] == 120 ||\n+\t    a[i] == 130 || a[i] == 140 || a[i] == 150 || a[i] == 160 ||\n+\t    a[i] == 170 || a[i] == 180 || a[i] == 190 || a[i] == 0)\n+\t{\n+\t    s += a[i];\n+\t}\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+    {\n+\tif (i % 4 == 0)\n+\t    a[i] = 10;\n+\telse if (i % 4 == 1)\n+\t    a[i] = 100;\n+\telse if (i % 4 == 2)\n+\t    a[i] = 90;\n+\telse\n+\t    a[i] = 1000;\n+    }\n+\n+    printf (\"%d\\n\", foo (160, 100, 99));\n+\n+    return 0;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"SLP MATCH pattern: Successfully built replacement for statement\" 4 \"vect\" } } */\n+/* { dg-final { scan-tree-dump-times {Choosing conditional \\(COND_MATCH_EQ\\) version of original IFN MATCH_EQ} 6 \"vect\" } } */\n+/* { 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\" } } */\n+\n+/* { dg-final { scan-assembler-times {\\tmatch\\tp[0-9]+\\.h, p[0-9]+/z, z[0-9]+\\.h, z[0-9]+\\.h\\n} 6 } } */\ndiff --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\nnew file mode 100644\nindex 000000000000..e04a5b6d89dc\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_large_run.c\n@@ -0,0 +1,71 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 20 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants should require\n+ * three MATCH instructions.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do run } */\n+/* { dg-options \"-O3\" } */\n+\n+#include <assert.h>\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||\n+\t    a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||\n+\t    a[i] == 30 || a[i] == 40 || a[i] == 110 || a[i] == 120 ||\n+\t    a[i] == 130 || a[i] == 140 || a[i] == 150 || a[i] == 160 ||\n+\t    a[i] == 170 || a[i] == 180 || a[i] == 190 || a[i] == 0)\n+\t{\n+\t    s += a[i];\n+\t}\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+    {\n+\tif (i % 4 == 0)\n+\t    a[i] = 10;\n+\telse if (i % 4 == 1)\n+\t    a[i] = 9;\n+\telse if (i % 4 == 2)\n+\t    a[i] = 60;\n+\telse\n+\t    a[i] = 1000;\n+    }\n+\n+    // Only match elements that are 10 in the array.\n+    assert (foo (160, 0, 0) == 400);\n+    assert (foo (160, 0, 10) == 400);\n+    assert (foo (160, 66, 33) == 400);\n+\n+    // Only match elements that are 10 or 60 in the array.\n+    assert (foo (160, 60, 0) == 2800);\n+    assert (foo (160, 0, 60) == 2800);\n+    assert (foo (160, 59, 0) == 2800);\n+    assert (foo (160, 60, 10) == 2800);\n+    assert (foo (160, 10, 60) == 2800);\n+    assert (foo (160, 59, 60) == 2800);\n+\n+    // Match all elements in the array, apart from those whose value is 1000.\n+    assert (foo (160, 60, 9) == 3160);\n+    assert (foo (160, 9, 60) == 3160);\n+    assert (foo (160, 59, 9) == 3160);\n+\n+    return 0;\n+}\ndiff --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\nnew file mode 100644\nindex 000000000000..e3e192954ee3\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium.c\n@@ -0,0 +1,58 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 10 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants should require\n+ * two MATCH instructions.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -fdump-tree-vect-details --save-temps\" } */\n+\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||\n+\t    a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||\n+\t    a[i] == 30 || a[i] == 40)\n+\t{\n+\t    s += a[i];\n+\t}\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+    {\n+\tif (i % 4 == 0)\n+\t    a[i] = 10;\n+\telse if (i % 4 == 1)\n+\t    a[i] = 100;\n+\telse if (i % 4 == 2)\n+\t    a[i] = 90;\n+\telse\n+\t    a[i] = 1000;\n+    }\n+\n+    printf (\"%d\\n\", foo (160, 100, 99));\n+\n+    return 0;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"SLP MATCH pattern: Successfully built replacement for statement\" 4 \"vect\" } } */\n+/* { dg-final { scan-tree-dump-times {Choosing conditional \\(COND_MATCH_EQ\\) version of original IFN MATCH_EQ} 4 \"vect\" } } */\n+/* { 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\" } } */\n+\n+/* { dg-final { scan-assembler-times {\\tmatch\\tp[0-9]+\\.h, p[0-9]+/z, z[0-9]+\\.h, z[0-9]+\\.h\\n} 4 } } */\ndiff --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\nnew file mode 100644\nindex 000000000000..21ace72e6e4a\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_medium_run.c\n@@ -0,0 +1,69 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 10 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants should require\n+ * two MATCH instructions.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do run } */\n+/* { dg-options \"-O3\" } */\n+\n+#include <assert.h>\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] == x || a[i] == (x + 1) || a[i] == 10 || a[i] == 20 ||\n+\t    a[i] == 70 || a[i] == 90 || a[i] == y || a[i] == 100 ||\n+\t    a[i] == 30 || a[i] == 40)\n+\t{\n+\t    s += a[i];\n+\t}\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+    {\n+\tif (i % 4 == 0)\n+\t    a[i] = 10;\n+\telse if (i % 4 == 1)\n+\t    a[i] = 9;\n+\telse if (i % 4 == 2)\n+\t    a[i] = 60;\n+\telse\n+\t    a[i] = 1000;\n+    }\n+\n+    // Only match elements that are 10 in the array.\n+    assert (foo (160, 0, 0) == 400);\n+    assert (foo (160, 0, 10) == 400);\n+    assert (foo (160, 66, 33) == 400);\n+\n+    // Only match elements that are 10 or 60 in the array.\n+    assert (foo (160, 60, 0) == 2800);\n+    assert (foo (160, 0, 60) == 2800);\n+    assert (foo (160, 59, 0) == 2800);\n+    assert (foo (160, 60, 10) == 2800);\n+    assert (foo (160, 10, 60) == 2800);\n+    assert (foo (160, 59, 60) == 2800);\n+\n+    // Match all elements in the array, apart from those whose value is 1000.\n+    assert (foo (160, 60, 9) == 3160);\n+    assert (foo (160, 9, 60) == 3160);\n+    assert (foo (160, 59, 9) == 3160);\n+\n+    return 0;\n+}\ndiff --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\nnew file mode 100644\nindex 000000000000..b8f6f7823d1e\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small.c\n@@ -0,0 +1,48 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 4 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants is small enough\n+ * to only use a MATCH instruction.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -fdump-tree-vect-details --save-temps\" } */\n+\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y, short int z)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] == x || a[i] == y || a[i] == 7 || a[i] == z)\n+\t    s++;\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+\tif (i % 2 == 0)\n+\t    a[i] = 10;\n+\telse\n+\t    a[i] = 30;\n+\n+    printf (\"%d\\n\", foo (160, 0, 10, 40));\n+\n+    return 0;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"SLP MATCH pattern: Successfully built replacement for statement\" 2 \"vect\" } } */\n+/* { dg-final { scan-tree-dump-times {Choosing conditional \\(COND_MATCH_EQ\\) version of original IFN MATCH_EQ} 2 \"vect\" } } */\n+/* { 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\" } } */\n+\n+/* { dg-final { scan-assembler-times {\\tmatch\\tp[0-9]+\\.h, p[0-9]+/z, z[0-9]+\\.h, z[0-9]+\\.h\\n} 2 } } */\ndiff --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\nnew file mode 100644\nindex 000000000000..9c55e13fb350\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/match_short_int_small_run.c\n@@ -0,0 +1,53 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 4 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match ANY FROM pattern should be identified and replaced with\n+ * a MATCH instruction. In this test, the number of invariants is small enough\n+ * to only use a MATCH instruction.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do run } */\n+/* { dg-options \"-O3\" } */\n+\n+#include <assert.h>\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y, short int z)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] == x || a[i] == y || a[i] == 7 || a[i] == z)\n+\t    s++;\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+\tif (i % 2 == 0)\n+\t    a[i] = 10;\n+\telse\n+\t    a[i] = 30;\n+\n+    assert (foo (160, 0, 0, 0) == 0);\n+    assert (foo (160, 40, 70, 90) == 0);\n+\n+    assert (foo (160, 10, 0, 0) == 80);\n+    assert (foo (160, 0, 10, 0) == 80);\n+    assert (foo (160, 0, 0, 10) == 80);\n+\n+    assert (foo (160, 70, 0, 10) == 80);\n+    assert (foo (160, 10, 70, 0) == 80);\n+\n+    assert (foo (160, 30, 0, 10) == 160);\n+\n+    return 0;\n+}\ndiff --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\nnew file mode 100644\nindex 000000000000..f14e388b2bce\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small.c\n@@ -0,0 +1,55 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 4 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match NONE FROM pattern should be identified and replaced with\n+ * a NMATCH instruction. In this test, the number of invariants is small enough\n+ * to only use a NMATCH instruction.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ *\n+ * Note: the code is sometimes optimized from an AND-of-NE to\n+ * an OR-of-EQ structure, which is the reason why this test also expects the\n+ * use of a `match` instruction (in addition to `nmatch`).\n+ */\n+\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -fdump-tree-vect-details --save-temps\" } */\n+\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y, short int z)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] != x && a[i] != y && a[i] != 7 && a[i] != z)\n+\t    s++;\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+\tif (i % 2 == 0)\n+\t    a[i] = 70;\n+\telse\n+\t    a[i] = 30;\n+\n+    printf (\"%d\\n\", foo (160, 0, 10, 40));\n+\n+    return 0;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"SLP MATCH pattern: Successfully built replacement for statement\" 2 \"vect\" } } */\n+/* { dg-final { scan-tree-dump-times {Choosing conditional \\(COND_MATCH_NE\\) version of original IFN MATCH_NE} 1 \"vect\" } } */\n+/* { dg-final { scan-tree-dump-times {Choosing conditional \\(COND_MATCH_EQ\\) version of original IFN MATCH_EQ} 1 \"vect\" } } */\n+/* { 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\" } } */\n+/* { 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\" } } */\n+\n+/* { dg-final { scan-assembler-times {\\tnmatch\\tp[0-9]+\\.h, p[0-9]+/z, z[0-9]+\\.h, z[0-9]+\\.h\\n} 1 } } */\n+/* { dg-final { scan-assembler-times {\\tmatch\\tp[0-9]+\\.h, p[0-9]+/z, z[0-9]+\\.h, z[0-9]+\\.h\\n} 1 } } */\ndiff --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\nnew file mode 100644\nindex 000000000000..6e872fbf79e5\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/aarch64/sve2/nmatch_short_int_small_run.c\n@@ -0,0 +1,53 @@\n+/**\n+ * Test for vectorizer MATCH pattern.\n+ *\n+ * Test with 4 invariants, of type `short int` (16-bits).\n+ *\n+ * A Match NONE FROM pattern should be identified and replaced with\n+ * a NMATCH instruction. In this test, the number of invariants is small enough\n+ * to only use a NMATCH instruction.\n+ *\n+ * Compile for: ARM-v9, which has SVE2 included.\n+ */\n+\n+/* { dg-do run } */\n+/* { dg-options \"-O3\" } */\n+\n+#include <assert.h>\n+#include <stdio.h>\n+\n+short int a[160];\n+\n+int foo (int n, short int x, short int y, short int z)\n+{\n+    short int s = 0;\n+    for (int i = 0; i < n; i++)\n+    {\n+\tif (a[i] != x && a[i] != y && a[i] != 7 && a[i] != z)\n+\t    s++;\n+    }\n+    return s;\n+}\n+\n+int main ()\n+{\n+    for (int i = 0; i < 160; i++)\n+\tif (i % 2 == 0)\n+\t    a[i] = 70;\n+\telse\n+\t    a[i] = 30;\n+\n+    assert (foo (160, 0, 0, 0) == 160);\n+    assert (foo (160, 40, 60, 90) == 160);\n+\n+    assert (foo (160, 70, 0, 0) == 80);\n+    assert (foo (160, 0, 70, 0) == 80);\n+    assert (foo (160, 0, 0, 30) == 80);\n+\n+    assert (foo (160, 70, 0, 10) == 80);\n+    assert (foo (160, 10, 70, 0) == 80);\n+\n+    assert (foo (160, 30, 0, 70) == 0);\n+\n+    return 0;\n+}\n","prefixes":["v2","7/7","Vectorizer"]}