From patchwork Sun Sep 10 02:33:04 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: 137849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1393755vqo; Sat, 9 Sep 2023 19:33:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfizK1yOiDAhZcjvpqYTA8E0Y8o28+J5m89xnCPN4Aot+uskySvOjBo78k9Qi4TG5m2Qcn X-Received: by 2002:a17:906:74c7:b0:993:d5bd:a757 with SMTP id z7-20020a17090674c700b00993d5bda757mr5146268ejl.19.1694313232150; Sat, 09 Sep 2023 19:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694313232; cv=none; d=google.com; s=arc-20160816; b=UCJ2kO6R6xkOx40oEBy0vafKezgyTSEk3BItWhWtfqAZ1dcGqwuBD4X2Ps0tyuu5Xb q2Dt9NcL8ZuG9oYLK/xx4uB4LchJsBsttxUWbWNHDDd7NJUhLpM3eu99EBVUGZJQVAU8 EnY3RJulVMpXTo7Y1CYIt1jjLdh0fKApCmuLgbIhIbOfRukY61JVCx1qqW7umqpPjEGc aaI5adI/blSZr3FQEwgCbhi7PxqKc9nuhAwCt6mrNWPnhDTUCdaFaTwgIXDy4phsPGZT pkWNsAYlPRGchY1XNIrdgRcYdmRP0LRzo7mtu202M+ZUDouzbUv/uYC+hwOj7CEOdGLe FvTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:to :from:dmarc-filter:delivered-to; bh=nZN0p4Lw5KrBDvrespSQ/n4iRdNfN9FRkeahbwoiwi4=; fh=arl273cIQBNH1P6XLxHQvF0scgitfd773vOV+bwQx3o=; b=O7O8UmkP1A5vp2tV3sbYPXWepxtZTxOSM7QpaMhz0t1y3CeMI1IAuaK1R7Tsyso8NW Zk+pUA9tv16Ha03DQ+FRVf1hgMtk5YbR/JzyXI+paeu5rIw/pRxBLj9IsDfDQSS6EDxO U9PvV9bRvEOB3TIDFWehdymHzaH8xARX3JY8AAOHL4DEQgYKMei5J8CbBHDCIO0EERMf c4ujEU2IgDFtUkQbOBdkW4tBaMsmXw3F2oxSWhCBfpep9UuL6m5UyKp/KAwL/KIW6tKL ICL0mlyBjbguv9lCWwHbhjZBd4ld3O7tWErpqC91fXzRUk8eZvP88pTBxBIZQ2f0q3rD h7+Q== 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 b6-20020a170906490600b009a593bf05bcsi4089330ejq.624.2023.09.09.19.33.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Sep 2023 19:33:52 -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 E4BBA3858425 for ; Sun, 10 Sep 2023 02:33:48 +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 E12D23858D1E for ; Sun, 10 Sep 2023 02:33:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E12D23858D1E 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: bizesmtp71t1694313192tqi5yve3 Received: from rios-cad122.hadoop.rioslab.org ( [58.60.1.26]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 10 Sep 2023 10:33:10 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: +FHoQ0ZR2/Zf0qfYEFmOLH73feDTHDsHjLhK19rJ0aTDxv7pvKuNbZqnuWhui gdmVjrXuMLFmmrYdqVQ8l1Sli2P/qzLl9vhj/5Mrqg+oBRzrHis3QXdK0qQOmqebkbIjoAX 1KQ4vqQ11YvXmjxhMm83PQGmWWX9DxvphCjNXn8VtBJLAREKCVRiCi2wR7u8cNUv/rAYbXX 91Wh3CQnt++nje2rLcm8qgfDmfgeDu5zKCnuYmhYjG0pioCz+Vdqzg9PUWFFN32ZKme7zZ8 1LsosmpqMzcP5N7A4jXwd2QGBRbVWhTF6Wj73H5fQBRirLMGY333e2UOGQt6iYYOVohiB89 7jjlbO9k87BqRtdqgozfX3LZ8rhmNKqGrWFQkZLZXywCETSh0Gkwzb3woEgbRhwEQsk63zo JhQo9DcpzVM= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 11284252106506594715 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Subject: [PATCH] RISC-V: Expand fixed-vlmax/vls vector permutation in targethook Date: Sun, 10 Sep 2023 10:33:04 +0800 Message-Id: <20230910023304.1946754-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=-10.3 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: , Cc: kito.cheng@sifive.com, kito.cheng@gmail.com, Juzhe-Zhong Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776616191901072587 X-GMAIL-MSGID: 1776616191901072587 When debugging FAIL: gcc.dg/pr92301.c execution test. Realize a vls vector permutation situation failed to vectorize since early return false: - /* For constant size indices, we dont't need to handle it here. - Just leave it to vec_perm. */ - if (d->perm.length ().is_constant ()) - return false; To avoid more potential failed vectorization case. Now expand it in targethook. gcc/ChangeLog: * config/riscv/riscv-v.cc (shuffle_generic_patterns): Expand fixed-vlmax/vls vector permutation. --- gcc/config/riscv/riscv-v.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index dc8c10f6ed2..bee60de1d26 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -2792,14 +2792,9 @@ shuffle_generic_patterns (struct expand_vec_perm_d *d) if (!pow2p_hwi (d->perm.encoding().npatterns ())) return false; - /* For constant size indices, we dont't need to handle it here. - Just leave it to vec_perm. */ - if (d->perm.length ().is_constant ()) - return false; - /* Permuting two SEW8 variable-length vectors need vrgatherei16.vv. Otherwise, it could overflow the index range. */ - if (GET_MODE_INNER (d->vmode) == QImode + if (!nunits.is_constant () && GET_MODE_INNER (d->vmode) == QImode && !get_vector_mode (HImode, nunits).exists (&sel_mode)) return false; @@ -2808,7 +2803,12 @@ shuffle_generic_patterns (struct expand_vec_perm_d *d) return true; rtx sel = vec_perm_indices_to_rtx (sel_mode, d->perm); - expand_vec_perm (d->target, d->op0, d->op1, force_reg (sel_mode, sel)); + /* 'mov' generte interleave vector. */ + if (!nunits.is_constant ()) + sel = force_reg (sel_mode, sel); + /* Some FIXED-VLMAX/VLS vector permutation situations call targethook + instead of expand vec_perm, we handle it directly. */ + expand_vec_perm (d->target, d->op0, d->op1, sel); return true; }