Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2195897/?format=api
{ "id": 2195897, "url": "http://patchwork.ozlabs.org/api/patches/2195897/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260212091326.2240990-8-linopeng@andestech.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "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, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260212091326.2240990-8-linopeng@andestech.com>", "list_archive_url": null, "date": "2026-02-12T09:13:25", "name": "[7/8] RISC-V: Track altfmt in vsetvl pass", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "6fe01586e72842efc9f8b89b898e0f7a8f988d12", "submitter": { "id": 92634, "url": "http://patchwork.ozlabs.org/api/people/92634/?format=api", "name": "Lino Hsing-Yu Peng", "email": "linopeng@andestech.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260212091326.2240990-8-linopeng@andestech.com/mbox/", "series": [ { "id": 491947, "url": "http://patchwork.ozlabs.org/api/series/491947/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=491947", "date": "2026-02-12T09:13:18", "name": "*** Add RISC-V zvfofp8min intrinsic ***", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/491947/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2195897/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2195897/checks/", "tags": {}, "related": [], "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=2620:52:6:3111::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;\n dmarc=permerror header.from=andestech.com", "sourceware.org; spf=pass smtp.mailfrom=andestech.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=60.248.187.195" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::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 4fBVJk11CGz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 20:25:26 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 1FE5C4B9DB44\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 09:25:24 +0000 (GMT)", "from Atcsqr.andestech.com (unknown [60.248.187.195])\n by sourceware.org (Postfix) with ESMTPS id 933AE4BA23F9\n for <gcc-patches@gcc.gnu.org>; Thu, 12 Feb 2026 09:24:52 +0000 (GMT)", "from mail.andestech.com (ATCPCS34.andestech.com [10.0.1.134])\n by Atcsqr.andestech.com with ESMTP id 61C9OlPk012116;\n Thu, 12 Feb 2026 17:24:47 +0800 (+08)\n (envelope-from linopeng@andestech.com)", "from atccpl01.andestech.com (10.0.15.149) by ATCPCS34.andestech.com\n (10.0.1.134) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 12 Feb\n 2026 17:24:47 +0800" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 1FE5C4B9DB44", "OpenDKIM Filter v2.11.0 sourceware.org 933AE4BA23F9" ], "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 933AE4BA23F9", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770888293; cv=none;\n b=tLMLJ1xZF0ofGjUzv800M3XtwnEgAypDxXLVomhxZdlzWMuCsjV5YW+FISf5tLt9wzT4KlnwvmyPDvFQdwr57t+Sh1GgpEzDsiNsmWA/jqT+s56+6GeVI+gbXDVA8mdFxsVsZOlWpLYAbaO8UVPQelMBLWGWhNrjVGZPrcRQVg0=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1770888293; c=relaxed/simple;\n bh=7kWBKyWrmrtmeXM630ZWvrhlQGG1jHFGa6YKu4mk1DA=;\n h=From:To:Subject:Date:Message-ID:MIME-Version;\n b=MrJw7OI5+n2ufnOGoFnDfxv2+m1ax23gEL7L9ADzslB7imJ2zoFq6vwvLVXA7FfeDyFYF548eytbwLNjLglAJG5ERo1lkZN51fmf7qTEXcn5erTxCPdPj0ATU9NeztdHq9W9TDNaEDOU7uWRm6JdRjHCUolkQ0NyRKy2OBho1m4=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "From": "Lino Hsing-Yu Peng <linopeng@andestech.com>", "To": "<gcc-patches@gcc.gnu.org>", "CC": "Lino Hsing-Yu Peng <linopeng1019@gmail.com>", "Subject": "[PATCH 7/8] RISC-V: Track altfmt in vsetvl pass", "Date": "Thu, 12 Feb 2026 17:13:25 +0800", "Message-ID": "<20260212091326.2240990-8-linopeng@andestech.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20260212091326.2240990-7-linopeng@andestech.com>", "References": "<20260212091326.2240990-1-linopeng@andestech.com>\n <20260212091326.2240990-2-linopeng@andestech.com>\n <20260212091326.2240990-3-linopeng@andestech.com>\n <20260212091326.2240990-4-linopeng@andestech.com>\n <20260212091326.2240990-5-linopeng@andestech.com>\n <20260212091326.2240990-6-linopeng@andestech.com>\n <20260212091326.2240990-7-linopeng@andestech.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-Originating-IP": "[10.0.15.149]", "X-ClientProxiedBy": "ATCPCS33.andestech.com (10.0.1.100) To\n ATCPCS34.andestech.com (10.0.1.134)", "X-DKIM-Results": "atcpcs34.andestech.com; dkim=none;", "X-DNSRBL": "", "X-MAIL": "Atcsqr.andestech.com 61C9OlPk012116", "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>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "From: Lino Hsing-Yu Peng <linopeng1019@gmail.com>\n\nThe pass now checks altfmt compatibility when merging states and\nselecting vsetvl patterns.\n\ngcc/ChangeLog:\n\n\t* config/riscv/riscv-vsetvl.cc (altfmt_to_str, get_altfmt): New helpers.\n\t(demand_flags, altfmt_demand_type): Add altfmt demand tracking.\n\t(vsetvl_info): Track altfmt and its demand.\n\t(normalize_demand, parse_insn, get_vsetvl_pat, dump, operator==):\n\tHandle altfmt.\n\t(demand_system): Add altfmt compatibility, availability, and merge.\n\t(preds_all_same_avl_and_ratio_p): Check altfmt availability.\n\t* config/riscv/riscv-vsetvl.def (DEF_ALTFMT_RULE): New macro.\n\tAdd altfmt fusion rules.\n---\n gcc/config/riscv/riscv-vsetvl.cc | 183 ++++++++++++++++++++++++++----\n gcc/config/riscv/riscv-vsetvl.def | 15 +++\n 2 files changed, 175 insertions(+), 23 deletions(-)", "diff": "diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc\nindex c62295ee89b..22a8f6c6ef1 100644\n--- a/gcc/config/riscv/riscv-vsetvl.cc\n+++ b/gcc/config/riscv/riscv-vsetvl.cc\n@@ -256,6 +256,22 @@ policy_to_str (bool agnostic_p)\n return agnostic_p ? \"agnostic\" : \"undisturbed\";\n }\n \n+static const char *\n+altfmt_to_str (uint8_t altfmt)\n+{\n+ switch (altfmt)\n+ {\n+ case ALTFMT_NONE:\n+ return \"none\";\n+ case ALTFMT_ALT:\n+ return \"alt\";\n+ case ALTFMT_ANY:\n+ return \"any\";\n+ default:\n+ return \"unknown\";\n+ }\n+}\n+\n /* Return true if it is an RVV instruction depends on VTYPE global\n status register. */\n bool\n@@ -501,6 +517,14 @@ mask_agnostic_p (rtx_insn *rinsn)\n return ma == INVALID_ATTRIBUTE ? get_default_ma () : IS_AGNOSTIC (ma);\n }\n \n+static uint8_t\n+get_altfmt (rtx_insn *rinsn)\n+{\n+ extract_insn_cached (rinsn);\n+ int altfmt = get_attr_altfmt (rinsn);\n+ return altfmt == INVALID_ATTRIBUTE ? ALTFMT_NONE : altfmt;\n+}\n+\n /* Return true if FN has a vector instruction that use VL/VTYPE. */\n static bool\n has_vector_insn (function *fn)\n@@ -817,19 +841,21 @@ enum demand_flags : unsigned\n DEMAND_MASK_POLICY_P = 1 << 5,\n DEMAND_AVL_P = 1 << 6,\n DEMAND_NON_ZERO_AVL_P = 1 << 7,\n+ DEMAND_ALTFMT_P = 1 << 8,\n };\n \n-/* We split the demand information into three parts. They are sew and lmul\n+/* We split the demand information into four parts. They are sew and lmul\n related (sew_lmul_demand_type), tail and mask policy related\n- (policy_demand_type) and avl related (avl_demand_type). Then we define three\n- interfaces available_p, compatible_p and merge. available_p is\n- used to determine whether the two vsetvl infos prev_info and next_info are\n- available or not. If prev_info is available for next_info, it means that the\n- RVV insn corresponding to next_info on the path from prev_info to next_info\n- can be used without inserting a separate vsetvl instruction. compatible_p\n- is used to determine whether prev_info is compatible with next_info, and if\n- so, merge can be used to merge the stricter demand information from\n- next_info into prev_info so that prev_info becomes available to next_info.\n+ (policy_demand_type), alternate FP8 format related (altfmt_demand_type) and\n+ avl related (avl_demand_type). Then we define three interfaces available_p,\n+ compatible_p and merge. available_p is used to determine whether the two\n+ vsetvl infos prev_info and next_info are available or not. If prev_info is\n+ available for next_info, it means that the RVV insn corresponding to\n+ next_info on the path from prev_info to next_info can be used without\n+ inserting a separate vsetvl instruction. compatible_p is used to determine\n+ whether prev_info is compatible with next_info, and if so, merge can be used\n+ to merge the stricter demand information from next_info into prev_info so\n+ that prev_info becomes available to next_info.\n */\n \n enum class sew_lmul_demand_type : unsigned\n@@ -851,6 +877,12 @@ enum class policy_demand_type : unsigned\n ignore_policy = demand_flags::DEMAND_EMPTY_P,\n };\n \n+enum class altfmt_demand_type : unsigned\n+{\n+ altfmt = demand_flags::DEMAND_ALTFMT_P,\n+ ignore_altfmt = demand_flags::DEMAND_EMPTY_P,\n+};\n+\n enum class avl_demand_type : unsigned\n {\n avl = demand_flags::DEMAND_AVL_P,\n@@ -900,11 +932,13 @@ private:\n uint8_t m_max_sew;\n vlmul_type m_vlmul;\n uint8_t m_ratio;\n+ uint8_t m_altfmt;\n bool m_ta;\n bool m_ma;\n \n sew_lmul_demand_type m_sew_lmul_demand;\n policy_demand_type m_policy_demand;\n+ altfmt_demand_type m_altfmt_demand;\n avl_demand_type m_avl_demand;\n \n enum class state_type\n@@ -925,9 +959,10 @@ public:\n vsetvl_info ()\n : m_insn (nullptr), m_bb (nullptr), m_avl (NULL_RTX), m_vl (NULL_RTX),\n m_avl_def (nullptr), m_sew (0), m_max_sew (0), m_vlmul (LMUL_RESERVED),\n- m_ratio (0), m_ta (false), m_ma (false),\n+ m_ratio (0), m_altfmt (ALTFMT_NONE), m_ta (false), m_ma (false),\n m_sew_lmul_demand (sew_lmul_demand_type::sew_lmul),\n m_policy_demand (policy_demand_type::tail_mask_policy),\n+ m_altfmt_demand (altfmt_demand_type::altfmt),\n m_avl_demand (avl_demand_type::avl), m_state (state_type::UNINITIALIZED),\n m_delete (false), m_change_vtype_only (false), m_read_vl_insn (nullptr),\n m_vl_used_by_non_rvv_insn (false)\n@@ -943,6 +978,7 @@ public:\n void set_sew (uint8_t sew) { m_sew = sew; }\n void set_vlmul (vlmul_type vlmul) { m_vlmul = vlmul; }\n void set_ratio (uint8_t ratio) { m_ratio = ratio; }\n+ void set_altfmt (uint8_t altfmt) { m_altfmt = altfmt; }\n void set_ta (bool ta) { m_ta = ta; }\n void set_ma (bool ma) { m_ma = ma; }\n void set_delete () { m_delete = true; }\n@@ -957,6 +993,7 @@ public:\n uint8_t get_sew () const { return m_sew; }\n vlmul_type get_vlmul () const { return m_vlmul; }\n uint8_t get_ratio () const { return m_ratio; }\n+ uint8_t get_altfmt () const { return m_altfmt; }\n bool get_ta () const { return m_ta; }\n bool get_ma () const { return m_ma; }\n insn_info *get_insn () const { return m_insn; }\n@@ -1026,6 +1063,10 @@ public:\n {\n m_policy_demand = demand;\n }\n+ void set_altfmt_demand (altfmt_demand_type demand)\n+ {\n+ m_altfmt_demand = demand;\n+ }\n void set_avl_demand (avl_demand_type demand) { m_avl_demand = demand; }\n \n sew_lmul_demand_type get_sew_lmul_demand () const\n@@ -1033,6 +1074,7 @@ public:\n return m_sew_lmul_demand;\n }\n policy_demand_type get_policy_demand () const { return m_policy_demand; }\n+ altfmt_demand_type get_altfmt_demand () const { return m_altfmt_demand; }\n avl_demand_type get_avl_demand () const { return m_avl_demand; }\n \n void normalize_demand (unsigned demand_flags)\n@@ -1077,6 +1119,18 @@ public:\n \tgcc_unreachable ();\n }\n \n+ switch (demand_flags & DEMAND_ALTFMT_P)\n+ {\n+ case (unsigned) altfmt_demand_type::altfmt:\n+\tm_altfmt_demand = altfmt_demand_type::altfmt;\n+\tbreak;\n+ case (unsigned) altfmt_demand_type::ignore_altfmt:\n+\tm_altfmt_demand = altfmt_demand_type::ignore_altfmt;\n+\tbreak;\n+ default:\n+\tgcc_unreachable ();\n+ }\n+\n switch (demand_flags & (DEMAND_AVL_P | DEMAND_NON_ZERO_AVL_P))\n {\n case (unsigned) avl_demand_type::avl:\n@@ -1107,6 +1161,9 @@ public:\n m_vl = ::get_vl (rinsn);\n m_sew = ::get_sew (rinsn);\n m_vlmul = ::get_vlmul (rinsn);\n+ m_altfmt = ::get_altfmt (rinsn);\n+ m_altfmt_demand = m_altfmt == ALTFMT_ANY ? altfmt_demand_type::ignore_altfmt\n+\t\t\t\t\t : altfmt_demand_type::altfmt;\n m_ta = tail_agnostic_p (rinsn);\n m_ma = mask_agnostic_p (rinsn);\n }\n@@ -1166,6 +1223,7 @@ public:\n in demand info backward analysis. */\n if (m_ratio == INVALID_ATTRIBUTE)\n m_ratio = calculate_ratio (m_sew, m_vlmul);\n+ m_altfmt = ::get_altfmt (insn->rtl ());\n m_ta = tail_agnostic_p (insn->rtl ());\n m_ma = mask_agnostic_p (insn->rtl ());\n \n@@ -1232,6 +1290,9 @@ public:\n \t dflags |= demand_flags::DEMAND_MASK_POLICY_P;\n }\n \n+ if (m_altfmt != ALTFMT_ANY)\n+ dflags |= demand_flags::DEMAND_ALTFMT_P;\n+\n normalize_demand (dflags);\n \n /* Optimize AVL from the vsetvl instruction. */\n@@ -1288,7 +1349,8 @@ public:\n avl = GEN_INT (0);\n rtx sew = gen_int_mode (get_sew (), Pmode);\n rtx vlmul = gen_int_mode (get_vlmul (), Pmode);\n- rtx altfmt = const0_rtx;\n+ uint8_t altfmt_val = get_altfmt () == ALTFMT_ALT ? ALTFMT_ALT : ALTFMT_NONE;\n+ rtx altfmt = gen_int_mode (altfmt_val, Pmode);\n rtx ta = gen_int_mode (get_ta (), Pmode);\n rtx ma = gen_int_mode (get_ma (), Pmode);\n \n@@ -1336,11 +1398,13 @@ public:\n \t && get_avl () == other.get_avl () && get_vl () == other.get_vl ()\n \t && get_avl_def () == other.get_avl_def ()\n \t && get_sew () == other.get_sew ()\n-\t && get_vlmul () == other.get_vlmul () && get_ta () == other.get_ta ()\n-\t && get_ma () == other.get_ma ()\n+\t && get_vlmul () == other.get_vlmul ()\n+\t && get_altfmt () == other.get_altfmt ()\n+\t && get_ta () == other.get_ta () && get_ma () == other.get_ma ()\n \t && get_avl_demand () == other.get_avl_demand ()\n \t && get_sew_lmul_demand () == other.get_sew_lmul_demand ()\n-\t && get_policy_demand () == other.get_policy_demand ();\n+\t && get_policy_demand () == other.get_policy_demand ()\n+\t && get_altfmt_demand () == other.get_altfmt_demand ();\n }\n \n void dump (FILE *file, const char *indent = \"\") const\n@@ -1385,6 +1449,9 @@ public:\n else if (m_policy_demand == policy_demand_type::mask_policy_only)\n fprintf (file, \" demand_mask_policy_only\");\n \n+ if (m_altfmt_demand == altfmt_demand_type::altfmt)\n+ fprintf (file, \" demand_altfmt\");\n+\n if (m_avl_demand == avl_demand_type::avl)\n fprintf (file, \" demand_avl\");\n else if (m_avl_demand == avl_demand_type::non_zero_avl)\n@@ -1393,6 +1460,7 @@ public:\n \n fprintf (file, \"%sSEW=%d, \", indent, get_sew ());\n fprintf (file, \"VLMUL=%s, \", vlmul_to_str (get_vlmul ()));\n+ fprintf (file, \"ALTFMT=%s, \", altfmt_to_str (get_altfmt ()));\n fprintf (file, \"RATIO=%d, \", get_ratio ());\n fprintf (file, \"MAX_SEW=%d\\n\", get_max_sew ());\n \n@@ -1670,6 +1738,13 @@ private:\n return tail_policy_eq_p (prev, next) && mask_policy_eq_p (prev, next);\n }\n \n+ /* predictors for altfmt */\n+\n+ inline bool altfmt_eq_p (const vsetvl_info &prev, const vsetvl_info &next)\n+ {\n+ return prev.get_altfmt () == next.get_altfmt ();\n+ }\n+\n /* predictors for avl */\n \n inline bool modify_or_use_vl_p (insn_info *i, const vsetvl_info &info)\n@@ -1917,6 +1992,13 @@ private:\n use_mask_policy (prev, next);\n }\n \n+ /* modifiers for altfmt */\n+\n+ inline void use_next_altfmt (vsetvl_info &prev, const vsetvl_info &next)\n+ {\n+ prev.set_altfmt (next.get_altfmt ());\n+ }\n+\n /* modifiers for avl */\n \n inline void use_next_avl (vsetvl_info &prev, const vsetvl_info &next)\n@@ -2152,6 +2234,59 @@ public:\n return; \\\n }\n \n+#include \"riscv-vsetvl.def\"\n+\n+ gcc_unreachable ();\n+ }\n+\n+ bool altfmt_compatible_p (const vsetvl_info &prev, const vsetvl_info &next)\n+ {\n+ gcc_assert (prev.valid_p () && next.valid_p ());\n+ altfmt_demand_type prev_flags = prev.get_altfmt_demand ();\n+ altfmt_demand_type next_flags = next.get_altfmt_demand ();\n+#define DEF_ALTFMT_RULE(PREV_FLAGS, NEXT_FLAGS, NEW_FLAGS, COMPATIBLE_P, \\\n+\t\t\tAVAILABLE_P, FUSE) \\\n+ if (prev_flags == altfmt_demand_type::PREV_FLAGS \\\n+ && next_flags == altfmt_demand_type::NEXT_FLAGS) \\\n+ return COMPATIBLE_P (prev, next);\n+\n+#include \"riscv-vsetvl.def\"\n+\n+ gcc_unreachable ();\n+ }\n+\n+ bool altfmt_available_p (const vsetvl_info &prev, const vsetvl_info &next)\n+ {\n+ gcc_assert (prev.valid_p () && next.valid_p ());\n+ altfmt_demand_type prev_flags = prev.get_altfmt_demand ();\n+ altfmt_demand_type next_flags = next.get_altfmt_demand ();\n+#define DEF_ALTFMT_RULE(PREV_FLAGS, NEXT_FLAGS, NEW_FLAGS, COMPATIBLE_P, \\\n+\t\t\tAVAILABLE_P, FUSE) \\\n+ if (prev_flags == altfmt_demand_type::PREV_FLAGS \\\n+ && next_flags == altfmt_demand_type::NEXT_FLAGS) \\\n+ return AVAILABLE_P (prev, next);\n+\n+#include \"riscv-vsetvl.def\"\n+\n+ gcc_unreachable ();\n+ }\n+\n+ void merge_altfmt (vsetvl_info &prev, const vsetvl_info &next)\n+ {\n+ gcc_assert (prev.valid_p () && next.valid_p ());\n+ altfmt_demand_type prev_flags = prev.get_altfmt_demand ();\n+ altfmt_demand_type next_flags = next.get_altfmt_demand ();\n+#define DEF_ALTFMT_RULE(PREV_FLAGS, NEXT_FLAGS, NEW_FLAGS, COMPATIBLE_P, \\\n+\t\t\tAVAILABLE_P, FUSE) \\\n+ if (prev_flags == altfmt_demand_type::PREV_FLAGS \\\n+ && next_flags == altfmt_demand_type::NEXT_FLAGS) \\\n+ { \\\n+ gcc_assert (COMPATIBLE_P (prev, next)); \\\n+ FUSE (prev, next); \\\n+ prev.set_altfmt_demand (altfmt_demand_type::NEW_FLAGS); \\\n+ return; \\\n+ }\n+\n #include \"riscv-vsetvl.def\"\n \n gcc_unreachable ();\n@@ -2226,19 +2361,19 @@ public:\n \n bool compatible_p (const vsetvl_info &prev, const vsetvl_info &next)\n {\n- bool compatible_p = sew_lmul_compatible_p (prev, next)\n-\t\t\t&& policy_compatible_p (prev, next)\n-\t\t\t&& avl_compatible_p (prev, next)\n-\t\t\t&& vl_not_in_conflict_p (prev, next);\n+ bool compatible_p\n+ = sew_lmul_compatible_p (prev, next) && policy_compatible_p (prev, next)\n+\t&& altfmt_compatible_p (prev, next) && avl_compatible_p (prev, next)\n+\t&& vl_not_in_conflict_p (prev, next);\n return compatible_p;\n }\n \n bool available_p (const vsetvl_info &prev, const vsetvl_info &next)\n {\n- bool available_p = sew_lmul_available_p (prev, next)\n-\t\t && policy_available_p (prev, next)\n-\t\t && avl_available_p (prev, next)\n-\t\t && vl_not_in_conflict_p (prev, next);\n+ bool available_p\n+ = sew_lmul_available_p (prev, next) && policy_available_p (prev, next)\n+\t&& altfmt_available_p (prev, next) && avl_available_p (prev, next)\n+\t&& vl_not_in_conflict_p (prev, next);\n gcc_assert (!available_p || compatible_p (prev, next));\n return available_p;\n }\n@@ -2248,6 +2383,7 @@ public:\n gcc_assert (compatible_p (prev, next));\n merge_sew_lmul (prev, next);\n merge_policy (prev, next);\n+ merge_altfmt (prev, next);\n merge_avl (prev, next);\n gcc_assert (available_p (prev, next));\n }\n@@ -2497,6 +2633,7 @@ private:\n \tconst vsetvl_info &prev_info = *m_vsetvl_def_exprs[expr_index];\n \tif (!prev_info.valid_p ()\n \t || !m_dem.avl_available_p (prev_info, curr_info)\n+\t || !m_dem.altfmt_available_p (prev_info, curr_info)\n \t || prev_info.get_ratio () != curr_info.get_ratio ())\n \t return false;\n }\ndiff --git a/gcc/config/riscv/riscv-vsetvl.def b/gcc/config/riscv/riscv-vsetvl.def\nindex 2cef36bc4e9..948e812c45e 100644\n--- a/gcc/config/riscv/riscv-vsetvl.def\n+++ b/gcc/config/riscv/riscv-vsetvl.def\n@@ -38,6 +38,11 @@ along with GCC; see the file COPYING3. If not see\n \t\t\tavailable_p, fuse)\n #endif\n \n+#ifndef DEF_ALTFMT_RULE\n+#define DEF_ALTFMT_RULE(prev_demand, next_demand, fused_demand, compatible_p, \\\n+\t\t\tavailable_p, fuse)\n+#endif\n+\n #ifndef DEF_AVL_RULE\n #define DEF_AVL_RULE(prev_demand, next_demand, fused_demand, compatible_p, \\\n \t\t available_p, fuse)\n@@ -153,6 +158,15 @@ DEF_POLICY_RULE (ignore_policy, mask_policy_only, mask_policy_only, always_true,\n DEF_POLICY_RULE (ignore_policy, ignore_policy, ignore_policy, always_true,\n \t\t always_true, nop)\n \n+/* Define ALTFMT compatible and merge rules. */\n+\n+DEF_ALTFMT_RULE (altfmt, altfmt, altfmt, altfmt_eq_p, altfmt_eq_p, nop)\n+DEF_ALTFMT_RULE (altfmt, ignore_altfmt, altfmt, always_true, always_true, nop)\n+DEF_ALTFMT_RULE (ignore_altfmt, altfmt, altfmt, always_true, always_false,\n+\t\t use_next_altfmt)\n+DEF_ALTFMT_RULE (ignore_altfmt, ignore_altfmt, ignore_altfmt, always_true,\n+\t\t always_true, nop)\n+\n /* Define AVL compatible and merge rules. */\n \n DEF_AVL_RULE (avl, avl, avl, avl_equal_p, avl_equal_p, nop)\n@@ -177,4 +191,5 @@ DEF_AVL_RULE (ignore_avl, ignore_avl, ignore_avl, always_true, always_true, nop)\n \n #undef DEF_SEW_LMUL_RULE\n #undef DEF_POLICY_RULE\n+#undef DEF_ALTFMT_RULE\n #undef DEF_AVL_RULE\n", "prefixes": [ "7/8" ] }