From patchwork Thu Aug 10 10:37:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 133868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp323201vqi; Thu, 10 Aug 2023 03:37:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEP9LhikUGfj67WY4sONj777AjBzcDxcLxnllVtrmOnaMYvc5xf38YPJksJqKFlTjdLuTme X-Received: by 2002:a05:6512:1194:b0:4f8:77db:1d9e with SMTP id g20-20020a056512119400b004f877db1d9emr1720442lfr.12.1691663866918; Thu, 10 Aug 2023 03:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691663866; cv=none; d=google.com; s=arc-20160816; b=oW7iq5aOJ1/Wwjx8AOThaL/Gcob0qyLEVqsK84wqOfESqrywnQ+JT2Qkz6qBVcKGHW H3VOBJ3YTMlBB+h9M0JlRDj8GvzwQdnkasCr50STHD/akqetGOipCjkhvvfxydeFtyrt iDXHo8GG7TJ9S6tlO23ci7L8tR4hZrC6aq2OA2al160y1Uwst0HovU+5O+kXmmn3OrLy voZSx18WYJ/Hq0JDKAggWNqskmU7F7Zj3jDZAdwiGqiV60+bRsk0FLGD7R0hKZPrHZzu dKR3vkRwtcI3xUF09C9I9nsdQGH/sp6Gg/axRHNu4AE4ymz5F9vixoCd114qJ9q7X3Hw FPNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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=vlfoNOpKgJp8OfRGWxKhwunEyJwN2j5JqesrGEv/iZM=; fh=SuV1mxSfYh/fFJBV6FW8ZDQUWC7OLSIDYxyJSOKFLBQ=; b=JUYrgIvU0Ky3eAxI0jDr8TwdZ5fv7TVNiOI2r0nrS16PgPCoq6VPSeuwjcANP7U8yZ bShHm63o9gQkglwbDih4XemWMlnW53H72QWaLmZWFGVw+VuUWRBvF1rehLkqFNtQFJ6N tk5HntoUO9/S7PKK/gHPBctCRAOm0EDQ/DFtVmgc3+4+UHf9oc5P5BMkcqETpLo6w/Tu In80OsCvZqd2XcRmmlnJQAt1/z0Buv702mRC6KiBDhuQ9NbiflXoErYMXFEERbd/Q9c/ MY9Ah3B8zwtL4X3n9fkyhLGVcKYE6sAa9aEyTboMouZVwIWLTAipAKVkG6q/9OHSdupV bzog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y8-20020a056402134800b005227524ed19si1168039edw.513.2023.08.10.03.37.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 03:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 D3CEC38582B0 for ; Thu, 10 Aug 2023 10:37:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by sourceware.org (Postfix) with ESMTPS id 667B5385840E for ; Thu, 10 Aug 2023 10:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 667B5385840E 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: bizesmtp83t1691663828trycm9fm Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 10 Aug 2023 18:37:07 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: R3vftN8GVq8d8N2/THTBr8Yq4X+5dfZamViWR+MbXNC5xhENKNJRcRa8Ro06N bnXiYe3NpOesui4pQ9hry3Gi44Jp2Iz9wuZSrxpQzLCeFt8IzD1LoRou9og87u8o3jkUWG8 IHhw77G6JiWJF/eDqxdWIP49u9I/zyFOcIKerjxA00+ML3xz+vWYNPTG5EOxXpbO/eQs9E0 gQ/ro6CrWNhEnoEVodWNCExfVWMuGktUOIlOJevWlEx6KBf5sXSxLp+h6/iQD58XbQWE98j jf44sIyL31pfRrmFKWr0cBH6zgqWU1YTjngf8/xvHgpqOuI8P/H5enAhXWhUwT1yuWaYhCy XVWBAV9NiMw8Ziqh4fY5kaBGzd4xch1agkz53dHSnYp60tjaHwJZtLYyCUg91bUv5XjNZqO G1onCyBfsvk= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 2987113779344227252 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Add MASK vec_duplicate pattern[PR110962] Date: Thu, 10 Aug 2023 18:37:05 +0800 Message-Id: <20230810103705.1697293-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773838131116549548 X-GMAIL-MSGID: 1773838131116549548 This patch fix bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110962 SUBROUTINE a(b,c,d) LOGICAL,DIMENSION(INOUT) :: b LOGICAL e REAL, DIMENSION(IN) :: c REAL, DIMENSION(INOUT) :: d REAL, DIMENSION(SIZE(c)) :: f WHERE (b.AND.e) WHERE (f>=0.) d = g ENDWHERE ENDWHERE END SUBROUTINE a PR target/110962 gcc/ChangeLog: * config/riscv/autovec.md (vec_duplicate): New pattern. --- gcc/config/riscv/autovec.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index 6cb5fa3ed27..3b396a9a990 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -287,6 +287,27 @@ ;; == Vector creation ;; ========================================================================= +;; ------------------------------------------------------------------------- +;; ---- [BOOL] Duplicate element +;; ------------------------------------------------------------------------- +;; The patterns in this section are synthetic. +;; ------------------------------------------------------------------------- + +;; Implement a predicate broadcast by shifting the low bit of the scalar +;; input into the top bit by duplicate the input and do a compare with zero. +(define_expand "vec_duplicate" + [(set (match_operand:VB 0 "register_operand") + (vec_duplicate:VB (match_operand:QI 1 "register_operand")))] + "TARGET_VECTOR" + { + poly_int64 nunits = GET_MODE_NUNITS (mode); + machine_mode mode = riscv_vector::get_vector_mode (QImode, nunits).require (); + rtx dup = expand_vector_broadcast (mode, operands[1]); + riscv_vector::expand_vec_cmp (operands[0], NE, dup, CONST0_RTX (mode)); + DONE; + } +) + ;; ------------------------------------------------------------------------- ;; ---- [INT] Linear series ;; -------------------------------------------------------------------------