From patchwork Fri Sep 22 03:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lehua Ding X-Patchwork-Id: 143123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5286059vqi; Thu, 21 Sep 2023 20:01:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGfU0MdqLfQwHob2AtEaBPgeVLXBGHa518NcXWKctLX/XBMDr94K2Q/UeT0X31yuJJ+94i X-Received: by 2002:aa7:d70a:0:b0:531:157d:ba2d with SMTP id t10-20020aa7d70a000000b00531157dba2dmr2110658edq.4.1695351686859; Thu, 21 Sep 2023 20:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695351686; cv=none; d=google.com; s=arc-20160816; b=nbR4+DVdjteloRJlm6FuwTHKMAmt1QYmEdRsRlduzn8D1DL5VStvMHlOG9G8jq8kB4 UvnAWjJAwd3LjtkYR4fDsjgjB/Uziwa7px/wTxGqBnh4y/QlQ2lixAHTq73Umq0x9/vs zAsx5UJzJgZoAslRbD6VM/eDWN0gfiveELo8LHqkIlmjwp0agcy4coC0aVpls8kggKNk 1MvNLOSQDTfJ5J17u+6cpGl0GwEL/QO66y8IgaSjxyIAOeatjR2ZfP9cQv7/7EMhb+1R 9ppP8Z+fpnL9yueosIXMSfa1VooUuHeINkOVgkq1z9uu3qN4SXkYxQO4pRFD/BJk6/10 KDtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=SpPqjOwXuuiqSKSBE83pjCvuKB5YTBifyaZUlB7j978=; fh=x/Q0OlwHuvCZ3FpkiZPiUSvevOYVxUAi4aNnf76mUPQ=; b=DIz9qYZb8QUMyu+qaC340Zoi2P4AVKoXFWHpl9IpPoyuRdq1rr6j5SQ5i6zcDknszG MvO/dF+dVx09XZ2dw2xSwI7OLwVs1Ys0ghEcILzO8P2GRKec0ovZN0fn+++knMMkhgSJ DNexO/w69TrJgO8mJf2UMQ5WElVjNaiGiu23Mcnm+VfnYsz+93Q3uHQergd5UOHtMJLu W5sQoMJfc1wHTfHgLCLr682PFTFZTLGH/IVNjHzLK0HhVutpn/vJwvOvBxY7A5yFX8ab 5LjEZeNU4HBdImUhjZrZSXBF60nzt9pXsGHoFZID0FEQnF0DQmHuUG47W10+Msix0JIr jQDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r24-20020a056402035800b005330a0a9f4esi2277861edw.504.2023.09.21.20.01.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 20:01:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1EDE53860C2B for ; Fri, 22 Sep 2023 03:00:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by sourceware.org (Postfix) with ESMTPS id 3B9703858C2B for ; Fri, 22 Sep 2023 03:00:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B9703858C2B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp69t1695351609tq8pjbl1 Received: from rios-cad5.localdomain ( [58.60.1.25]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 22 Sep 2023 11:00:08 +0800 (CST) X-QQ-SSF: 01400000000000C0F000000A0000000 X-QQ-FEAT: ldOlv20DOSmgJ65wxWYATfmQzwICIb8VO8q3b/63SSPf6aWnvXQ6apih7w8wn aLfvz2XlzloIalnTu4EBIRpodPKecbrCB1MUCd0UyJrRDcbwD8kr3msQ8GQ1Soz1SMZoRXM DldCG7mdu7cPYC8PSyYWCkQrZe9MpU0lDiQB2DSp1E5wEYaSn1f6EL566cHkxKd0eqWxm4e Sj3HTdSoTMM+Rx6T/WVsrvJFAV4c0eJAaAQsF4oLUo+tpVNrViJBF896tWW5na2H9yCi+5q iQZMlhXlnFmBgekzhkHxW2aAQtkdosgDYAqVQRS+6PkOKpfiTQRBhi9sm9ahd0BO7Dds9i9 +yBVk3T9IPdXw6c+LiE4A8f99TegNfOpNPbsQLNA6TmMWMo15U= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 14843210692327697108 From: Lehua Ding To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@gmail.com, rdapp.gcc@gmail.com, palmer@rivosinc.com, jeffreyalaw@gmail.com, lehua.ding@rivai.ai Subject: [COMMITTED] RISC-V: Split VLS avl_type from NONVLMAX avl_type Date: Fri, 22 Sep 2023 11:00:07 +0800 Message-Id: <20230922030007.197448-1-lehua.ding@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz6a-0 X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, TXREP, T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777705090224852986 X-GMAIL-MSGID: 1777705090224852986 This patch split a VLS avl_type from the NONVLMAX avl_type, denoting those RVV insn with length set to the number of units of VLS modes. gcc/ChangeLog: * config/riscv/riscv-protos.h (enum avl_type): New VLS avl_type. * config/riscv/riscv-v.cc (autovec_use_vlmax_p): Move comments. --- gcc/config/riscv/riscv-protos.h | 21 +++++++++++++++++++-- gcc/config/riscv/riscv-v.cc | 25 ++++++------------------- 2 files changed, 25 insertions(+), 21 deletions(-) -- 2.36.3 diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 07b4ffe3edf..d8372a7886f 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -368,10 +368,27 @@ enum vlmul_type NUM_LMUL = 8 }; +/* The RISC-V vsetvli pass uses "known vlmax" operations for optimization. + Whether or not an instruction actually is a vlmax operation is not + recognizable from the length operand alone but the avl_type operand + is used instead. In general, there are two cases: + + - Emit a vlmax operation by calling emit_vlmax_insn[_lra]. Here we emit + a vsetvli with vlmax configuration and set the avl_type to VLMAX for + VLA modes or VLS for VLS modes. + - Emit an operation that uses the existing (last-set) length and + set the avl_type to NONVLMAX. + + Sometimes we also need to set the VLMAX or VLS avl_type to an operation that + already uses a given length register. This can happen during or after + register allocation when we are not allowed to create a new register. + For that case we also allow to set the avl_type to VLMAX or VLS. +*/ enum avl_type { - NONVLMAX, - VLMAX, + NONVLMAX = 0, + VLMAX = 1, + VLS = 2, }; /* Routines implemented in riscv-vector-builtins.cc. */ void init_builtins (void); diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index f63dec573ef..e8266218394 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -284,6 +284,7 @@ public: /* Add vl operand. */ rtx len = m_vl_op; + bool vls_p = false; if (m_vlmax_p) { if (riscv_v_ext_vls_mode_p (vtype_mode)) @@ -294,7 +295,7 @@ public: len = gen_int_mode (nunits, Pmode); if (!satisfies_constraint_K (len)) len = force_reg (Pmode, len); - m_vlmax_p = false; + vls_p = true; } else if (const_vlmax_p (vtype_mode)) { @@ -302,7 +303,7 @@ public: the vsetvli to obtain the value of vlmax. */ poly_uint64 nunits = GET_MODE_NUNITS (vtype_mode); len = gen_int_mode (nunits, Pmode); - m_vlmax_p = false; + vls_p = true; } else if (can_create_pseudo_p ()) { @@ -318,7 +319,9 @@ public: add_policy_operand (); /* Add avl_type operand. */ - add_avl_type_operand (m_vlmax_p ? avl_type::VLMAX : avl_type::NONVLMAX); + add_avl_type_operand ( + vls_p ? avl_type::VLS + : (m_vlmax_p ? avl_type::VLMAX : avl_type::NONVLMAX)); /* Add rounding mode operand. */ if (m_insn_flags & FRM_DYN_P) @@ -769,22 +772,6 @@ autovec_use_vlmax_p (void) || riscv_autovec_preference == RVV_FIXED_VLMAX); } -/* The RISC-V vsetvli pass uses "known vlmax" operations for optimization. - Whether or not an instruction actually is a vlmax operation is not - recognizable from the length operand alone but the avl_type operand - is used instead. In general, there are two cases: - - - Emit a vlmax operation by passing a NULL length. Here we emit - a vsetvli with vlmax configuration and set the avl_type to VLMAX. - - Emit an operation that uses the existing (last-set) length and - set the avl_type to NONVLMAX. - - Sometimes we also need to set the VLMAX avl_type to an operation that - already uses a given length register. This can happen during or after - register allocation when we are not allowed to create a new register. - For that case we also allow to set the avl_type to VLMAX. -*/ - /* This function emits VLMAX vrgather instruction. Emit vrgather.vx/vi when sel is a const duplicate vector. Otherwise, emit vrgather.vv. */ static void