{"id":2227078,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2227078/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260423074916.10577-1-garthlei@linux.alibaba.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/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":"<20260423074916.10577-1-garthlei@linux.alibaba.com>","date":"2026-04-23T07:49:16","name":"RISC-V: -mrvv-max-lmul=m1-dynamic","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8b9c1068840dcf989a73937b26ff7048250d6fc8","submitter":{"id":89310,"url":"http://patchwork.ozlabs.org/api/1.1/people/89310/?format=json","name":"Bohan Lei","email":"garthlei@linux.alibaba.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260423074916.10577-1-garthlei@linux.alibaba.com/mbox/","series":[{"id":501156,"url":"http://patchwork.ozlabs.org/api/1.1/series/501156/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501156","date":"2026-04-23T07:49:16","name":"RISC-V: -mrvv-max-lmul=m1-dynamic","version":1,"mbox":"http://patchwork.ozlabs.org/series/501156/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2227078/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2227078/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\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com\n header.a=rsa-sha256 header.s=default header.b=rI/6dKHK;\n\tdkim-atps=neutral","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\tdkim=pass (1024-bit key,\n unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com\n header.a=rsa-sha256 header.s=default header.b=rI/6dKHK","sourceware.org; dmarc=pass (p=none dis=none)\n header.from=linux.alibaba.com","sourceware.org;\n spf=pass smtp.mailfrom=linux.alibaba.com","server2.sourceware.org;\n arc=none smtp.remote-ip=115.124.30.131"],"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 4g1Stc2Cl5z1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 17:50:13 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 1AA9D4B8E079\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 07:50:11 +0000 (GMT)","from out30-131.freemail.mail.aliyun.com\n (out30-131.freemail.mail.aliyun.com [115.124.30.131])\n by sourceware.org (Postfix) with ESMTPS id 875984B8E04A\n for <gcc-patches@gcc.gnu.org>; Thu, 23 Apr 2026 07:49:33 +0000 (GMT)","from localhost(mailfrom:garthlei@linux.alibaba.com\n fp:SMTPD_---0X1Z.Uo._1776930562 cluster:ay36) by smtp.aliyun-inc.com;\n Thu, 23 Apr 2026 15:49:30 +0800"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 1AA9D4B8E079","OpenDKIM Filter v2.11.0 sourceware.org 875984B8E04A"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 875984B8E04A","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 875984B8E04A","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776930574; cv=none;\n b=lXkq0/49oeqZBL6OMZw3EogqPCbSy76oITcc5Zjcz5MJw+RqMh6jJSFNrF1Vm9YIwedXHuvstzhVrFdVa8ZouLXza5QqpPZU7Y+LruFw/X4kjsIBw9lJyomCy1nppgPtoXiOu4ex9Uc5+5yvsgCIS5E7EwAABBXz9B+lTZxUS2M=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776930574; c=relaxed/simple;\n bh=NqqBmBlUvEIZeOs71aD6KP29yjRZGSQhq9vLvvTekNs=;\n h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version;\n b=s9OeezQNlTEnBOLCAjJesGfEd7pVw/eM5L6wmjxkGerNwY0a4Dk81c9jKvgujLZNkQuNpEilYeaCIkEnvnU8WDvWiviMjiywz5y0PJjOKaiTdOYXlXA8bZcKUASghv9RCBZ1GIM6BvyO76C+DTtkBsYHOmsMo07FdourUHCmpW0=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linux.alibaba.com; s=default;\n t=1776930571; h=From:To:Subject:Date:Message-Id:MIME-Version;\n bh=OmQuyDRZahvT57hl+6n7IqdU4OseMFCD2jiDsTRiuVE=;\n b=rI/6dKHK4kJZ7cc9gj+0mRh++/65jPkIF0zOm3LiXFUi+3ObUNCggPgnE5vXLxBdOWAb50YCETH97s/RhVW2k46E2QvFDHv5IBmmD5WRdk68MKyzzbsWzojnv4bLSJ2TEmuQrIqulej3an8rV2AadgBxY+fQKmIWBmoWYRKoP1Q=","X-Alimail-AntiSpam":"AC=PASS; BC=-1|-1; BR=01201311R391e4; CH=green;\n DM=||false|;\n DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033037009110;\n MF=garthlei@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0;\n TI=SMTPD_---0X1Z.Uo._1776930562;","From":"Bohan Lei <garthlei@linux.alibaba.com>","To":"gcc-patches@gcc.gnu.org","Cc":"jeffrey.law@oss.qualcomm.com, rdapp.gcc@gmail.com,\n Bohan Lei <garthlei@linux.alibaba.com>","Subject":"[PATCH] RISC-V: -mrvv-max-lmul=m1-dynamic","Date":"Thu, 23 Apr 2026 15:49:16 +0800","Message-Id":"<20260423074916.10577-1-garthlei@linux.alibaba.com>","X-Mailer":"git-send-email 2.39.3 (Apple Git-146)","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"This patch adds a new dynamic LMUL mode that rejects LMUL>=2 when the\niteration count is unknown.  For unknown loops with a known iteration\ncount, it behaves the same as -mrvv-max-lmul=dynamic.\n\nWhen the iteration count is unknown, the -mrvv-max-lmul=dynamic behavior\nis also changed.  Instead of blindly choosing the bigger LMUL as long as\nno unexpected spills can occur, it calls the default cost comparing\nfunction to compare loops based costs.  This can prevent some cases\nwhere -mrvv-max-lmul=dynamic emits worse code than -mrvv-max-lmul=m8.\n\ngcc/ChangeLog:\n\n\t* config/riscv/riscv-opts.h (enum rvv_max_lmul_enum): Add\n\tRVV_M1_DYNAMIC.\n\t(TARGET_MAX_LMUL): Add support for RVV_M1_DYNAMIC.\n\t* config/riscv/riscv-string.cc (use_vector_stringop_p): Support\n\tRVV_M1_DYNAMIC.\n\t(expand_rawmemchr): Ditto.\n\t(expand_strcmp): Ditto.\n        (check_vectorise_memory_operation): Ditto.\n\t* config/riscv/riscv-vector-costs.cc\n\t(costs::compute_conversion_dynamic_lmul): Rename to ...\n\t(costs::compute_conversion_m1_dynamic_lmul): ... this, and add\n\tguard condition for RVV_CONV_DYNAMIC.\n\t(costs::has_unexpected_spills_p): Support RVV_M1_DYNAMIC.\n\t(costs::record_potential_unexpected_spills): Ditto.\n\t(costs::better_main_loop_than_p): Support RVV_M1_DYNAMIC and\n\tchange the else-case behavior of RVV_DYNAMIC.\n\t* config/riscv/riscv-vector-costs.h: Rename members.\n\t* config/riscv/riscv.opt: Add m1-dynamic option.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.target/riscv/rvv/autovec/dyn-lmul-m1-1.c: New test.\n---\n gcc/config/riscv/riscv-opts.h                 |  7 ++-\n gcc/config/riscv/riscv-string.cc              |  8 +--\n gcc/config/riscv/riscv-vector-costs.cc        | 51 ++++++++++++-------\n gcc/config/riscv/riscv-vector-costs.h         |  7 +--\n gcc/config/riscv/riscv.opt                    |  3 ++\n .../riscv/rvv/autovec/dyn-lmul-m1-1.c         | 20 ++++++++\n 6 files changed, 70 insertions(+), 26 deletions(-)\n create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/dyn-lmul-m1-1.c","diff":"diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h\nindex 2b6553ff87d..a9b3a7aea21 100644\n--- a/gcc/config/riscv/riscv-opts.h\n+++ b/gcc/config/riscv/riscv-opts.h\n@@ -89,7 +89,10 @@ enum rvv_max_lmul_enum {\n   RVV_DYNAMIC = 9,\n   /* For dynamic LMUL based on conversions, set LMUL based on\n      type size ratio.  */\n-  RVV_CONV_DYNAMIC = 10\n+  RVV_CONV_DYNAMIC = 10,\n+  /* For M1-preferred dynamic LMUL, only allow LMUL>=2 when\n+     iteration count is known.  */\n+  RVV_M1_DYNAMIC = 11\n };\n \n enum riscv_multilib_select_kind {\n@@ -158,7 +161,7 @@ enum rvv_vector_bits_enum {\n \n /* The maximum LMUL according to user configuration.  */\n #define TARGET_MAX_LMUL                                                        \\\n-  (int) ((rvv_max_lmul == RVV_DYNAMIC || rvv_max_lmul == RVV_CONV_DYNAMIC) \\\n+  (int) ((rvv_max_lmul >= RVV_DYNAMIC && rvv_max_lmul <= RVV_M1_DYNAMIC)       \\\n \t ? RVV_M8 : rvv_max_lmul)\n \n /* TLS types.  */\ndiff --git a/gcc/config/riscv/riscv-string.cc b/gcc/config/riscv/riscv-string.cc\nindex 3e7896b36fc..34474978fdf 100644\n--- a/gcc/config/riscv/riscv-string.cc\n+++ b/gcc/config/riscv/riscv-string.cc\n@@ -1090,7 +1090,7 @@ use_vector_stringop_p (struct stringop_info &info, HOST_WIDE_INT max_ew,\n     return false;\n \n   int max_lmul = TARGET_MAX_LMUL;\n-  if (rvv_max_lmul == RVV_CONV_DYNAMIC)\n+  if (rvv_max_lmul == RVV_CONV_DYNAMIC || rvv_max_lmul == RVV_M1_DYNAMIC)\n     max_lmul = RVV_M1;\n \n   if (CONST_INT_P (length_in))\n@@ -1360,7 +1360,7 @@ expand_rawmemchr (machine_mode mode, rtx dst, rtx haystack, rtx needle,\n \n   unsigned int isize = GET_MODE_SIZE (mode).to_constant ();\n   int lmul = TARGET_MAX_LMUL;\n-  if (rvv_max_lmul == RVV_CONV_DYNAMIC)\n+  if (rvv_max_lmul == RVV_CONV_DYNAMIC || rvv_max_lmul == RVV_M1_DYNAMIC)\n     lmul = RVV_M1;\n   poly_int64 nunits = exact_div (BYTES_PER_RISCV_VECTOR * lmul, isize);\n \n@@ -1461,7 +1461,7 @@ expand_strcmp (rtx result, rtx src1, rtx src2, rtx nbytes,\n   machine_mode mode = E_QImode;\n   unsigned int isize = GET_MODE_SIZE (mode).to_constant ();\n   int lmul = TARGET_MAX_LMUL;\n-  if (rvv_max_lmul == RVV_CONV_DYNAMIC)\n+  if (rvv_max_lmul == RVV_CONV_DYNAMIC || rvv_max_lmul == RVV_M1_DYNAMIC)\n     lmul = RVV_M1;\n   poly_int64 nunits = exact_div (BYTES_PER_RISCV_VECTOR * lmul, isize);\n \n@@ -1611,7 +1611,7 @@ check_vectorise_memory_operation (rtx length_in, HOST_WIDE_INT &lmul_out)\n \n   /* If we've been asked to use a specific LMUL,\n      check the operation fits and do that.  */\n-  if (rvv_max_lmul != RVV_DYNAMIC)\n+  if (rvv_max_lmul != RVV_DYNAMIC && rvv_max_lmul != RVV_M1_DYNAMIC)\n     {\n       lmul_out = TARGET_MAX_LMUL;\n       if (rvv_max_lmul == RVV_CONV_DYNAMIC)\ndiff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc\nindex 95f8d6f053a..32448fbe180 100644\n--- a/gcc/config/riscv/riscv-vector-costs.cc\n+++ b/gcc/config/riscv/riscv-vector-costs.cc\n@@ -941,9 +941,10 @@ costs::cleanup_live_range_data (hash_map<basic_block, vec<stmt_point>>\n   live_ranges_per_bb.empty ();\n }\n \n-/* Compute LMUL for RVV_CONV_DYNAMIC mode based on conversion ratio.  */\n+/* Compute LMUL for RVV_CONV_DYNAMIC mode based on conversion ratio, or for\n+   RVV_M1_DYNAMIC mode based on the biggest mode.  */\n void\n-costs::compute_conversion_dynamic_lmul (loop_vec_info loop_vinfo)\n+costs::compute_conversion_m1_dynamic_lmul (loop_vec_info loop_vinfo)\n {\n   hash_map<basic_block, vec<stmt_point>> program_points_per_bb;\n   hash_map<basic_block, hash_map<tree, pair>> live_ranges_per_bb;\n@@ -956,8 +957,9 @@ costs::compute_conversion_dynamic_lmul (loop_vec_info loop_vinfo)\n \n   /* Store the computed LMUL and biggest mode for later comparison\n      in cost model.  */\n-  m_computed_lmul_from_conv = lmul;\n-  m_biggest_mode_for_conv = biggest_mode;\n+  m_computed_lmul = lmul;\n+  if (rvv_max_lmul == RVV_CONV_DYNAMIC)\n+    m_biggest_mode_for_conv = biggest_mode;\n \n   cleanup_live_range_data (program_points_per_bb, live_ranges_per_bb);\n }\n@@ -1002,6 +1004,9 @@ costs::has_unexpected_spills_p (loop_vec_info loop_vinfo)\n \thas_spills = true;\n     }\n \n+  if (rvv_max_lmul == RVV_M1_DYNAMIC)\n+    m_computed_lmul = lmul;\n+\n   cleanup_live_range_data (program_points_per_bb, live_ranges_per_bb);\n   return has_spills;\n }\n@@ -1041,10 +1046,12 @@ costs::record_potential_unexpected_spills (loop_vec_info loop_vinfo)\n {\n   /* We only want to apply the heuristic if LOOP_VINFO is being\n      vectorized for VLA and known NITERS VLS loop.  */\n-  if (rvv_max_lmul == RVV_DYNAMIC\n-      && (m_cost_type == VLA_VECTOR_COST\n-\t  || (m_cost_type == VLS_VECTOR_COST\n-\t      && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))))\n+  if ((rvv_max_lmul == RVV_DYNAMIC\n+       && (m_cost_type == VLA_VECTOR_COST\n+\t   || (m_cost_type == VLS_VECTOR_COST\n+\t       && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))))\n+      || (rvv_max_lmul == RVV_M1_DYNAMIC\n+\t  && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)))\n     {\n       bool post_dom_available_p = dom_info_available_p (CDI_POST_DOMINATORS);\n       if (!post_dom_available_p)\n@@ -1053,8 +1060,8 @@ costs::record_potential_unexpected_spills (loop_vec_info loop_vinfo)\n       if (!post_dom_available_p)\n \tfree_dominance_info (CDI_POST_DOMINATORS);\n     }\n-  else if (rvv_max_lmul == RVV_CONV_DYNAMIC)\n-    compute_conversion_dynamic_lmul (loop_vinfo);\n+  else if (rvv_max_lmul == RVV_CONV_DYNAMIC || rvv_max_lmul == RVV_M1_DYNAMIC)\n+    compute_conversion_m1_dynamic_lmul (loop_vinfo);\n }\n \n /* Decide whether to use the unrolling heuristic described above\n@@ -1153,8 +1160,8 @@ costs::better_main_loop_than_p (const vector_costs *uncast_other) const\n     }\n   else if (rvv_max_lmul == RVV_CONV_DYNAMIC)\n     {\n-      if (this->m_computed_lmul_from_conv > 0\n-\t  && other->m_computed_lmul_from_conv > 0\n+      if (this->m_computed_lmul > 0\n+\t  && other->m_computed_lmul > 0\n \t  && this->m_biggest_mode_for_conv != VOIDmode)\n \t{\n \t  int this_vf = vect_vf_for_cost (this_loop_vinfo);\n@@ -1172,7 +1179,7 @@ costs::better_main_loop_than_p (const vector_costs *uncast_other) const\n \t  this_lmul = MAX (1, MIN (this_lmul, 8));\n \t  other_lmul = MAX (1, MIN (other_lmul, 8));\n \n-\t  int target_lmul = this->m_computed_lmul_from_conv;\n+\t  int target_lmul = this->m_computed_lmul;\n \n \t  /* Prefer the LMUL that exactly matches our computed ratio.  */\n \t  if (this_lmul == target_lmul && other_lmul != target_lmul)\n@@ -1195,7 +1202,7 @@ costs::better_main_loop_than_p (const vector_costs *uncast_other) const\n \t    }\n \t}\n     }\n-  else if (rvv_max_lmul == RVV_DYNAMIC)\n+  else if (rvv_max_lmul == RVV_DYNAMIC || rvv_max_lmul == RVV_M1_DYNAMIC)\n     {\n       if (other->m_has_unexpected_spills_p)\n \t{\n@@ -1219,12 +1226,22 @@ costs::better_main_loop_than_p (const vector_costs *uncast_other) const\n \t\t  return false;\n \t\t}\n \t    }\n-\t  else\n+\t  else if (rvv_max_lmul == RVV_M1_DYNAMIC &&\n+\t\t   other->m_computed_lmul >= RVV_M2)\n+\t    {\n+\t      if (dump_enabled_p ())\n+\t\tdump_printf_loc (MSG_NOTE, vect_location,\n+\t\t\t\t \"Preferring smaller LMUL loop because\"\n+\t\t\t\t \" it is unknown NITERS and other LMUL=%d\\n\",\n+\t\t\t\t other->m_computed_lmul);\n+\t      return true;\n+\t    }\n+\t  else if (m_cost_type == VLS_VECTOR_COST)\n \t    {\n \t      if (dump_enabled_p ())\n \t\tdump_printf_loc (MSG_NOTE, vect_location,\n-\t\t\t\t \"Keep current LMUL loop because\"\n-\t\t\t\t \" it is unknown NITERS\\n\");\n+\t\t\t\t \"Keep current VLA loop because it is unknown\"\n+\t\t\t\t \" NITERS\\n\");\n \t      return false;\n \t    }\n \t}\ndiff --git a/gcc/config/riscv/riscv-vector-costs.h b/gcc/config/riscv/riscv-vector-costs.h\nindex 9a620b71938..87ac4673501 100644\n--- a/gcc/config/riscv/riscv-vector-costs.h\n+++ b/gcc/config/riscv/riscv-vector-costs.h\n@@ -107,8 +107,9 @@ private:\n   void record_potential_unexpected_spills (loop_vec_info);\n \n   /* For RVV_DYNAMIC_CONV mode, store the LMUL computed from conversion ratio\n-     and the biggest mode used in the computation.  */\n-  int m_computed_lmul_from_conv = 0;\n+     and the biggest mode used in the computation.\n+     For RVV_DYNAMIC_M1 mode, store the LMUL computed from the biggest mode.  */\n+  int m_computed_lmul = 0;\n   machine_mode m_biggest_mode_for_conv = VOIDmode;\n \n   void compute_local_program_points (vec_info *,\n@@ -129,7 +130,7 @@ private:\n   void cleanup_live_range_data (hash_map<basic_block, vec<stmt_point>> &,\n \t\t\t\thash_map<basic_block, hash_map<tree, pair>> &);\n   bool has_unexpected_spills_p (loop_vec_info);\n-  void compute_conversion_dynamic_lmul (loop_vec_info);\n+  void compute_conversion_m1_dynamic_lmul (loop_vec_info);\n   bool need_additional_vector_vars_p (stmt_vec_info, slp_tree);\n \n   void adjust_vect_cost_per_loop (loop_vec_info);\ndiff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt\nindex 70f2fb0f5d5..c0b04e6aa92 100644\n--- a/gcc/config/riscv/riscv.opt\n+++ b/gcc/config/riscv/riscv.opt\n@@ -316,6 +316,9 @@ Enum(rvv_max_lmul) String(dynamic) Value(RVV_DYNAMIC)\n EnumValue\n Enum(rvv_max_lmul) String(conv-dynamic) Value(RVV_CONV_DYNAMIC)\n \n+EnumValue\n+Enum(rvv_max_lmul) String(m1-dynamic) Value(RVV_M1_DYNAMIC)\n+\n mrvv-max-lmul=\n Target RejectNegative Joined Enum(rvv_max_lmul) Var(rvv_max_lmul) Init(RVV_M1)\n -mrvv-max-lmul=<string>\tSet the RVV LMUL of auto-vectorization.\ndiff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/dyn-lmul-m1-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/dyn-lmul-m1-1.c\nnew file mode 100644\nindex 00000000000..858a15de637\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/dyn-lmul-m1-1.c\n@@ -0,0 +1,20 @@\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -march=rv64gcv -mabi=lp64d -mrvv-max-lmul=m1-dynamic\" } */\n+\n+void\n+pixel_avg (unsigned char *restrict dst, int i_dst_stride,\n+\t   unsigned char *restrict src1, int i_src1_stride,\n+\t   unsigned char *restrict src2, int i_src2_stride, int i_width,\n+\t   int i_height)\n+{\n+  for (int y = 0; y < i_height; y++)\n+    {\n+      for (int x = 0; x < i_width; x++)\n+\tdst[x] = (src1[x] + src2[x] + 1) >> 1;\n+      dst += i_dst_stride;\n+      src1 += i_src1_stride;\n+      src2 += i_src2_stride;\n+    }\n+}\n+\n+/* { dg-final { scan-assembler-times \",m1,\" 1 } } */\n","prefixes":[]}