From patchwork Tue Oct 24 07:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xu X-Patchwork-Id: 157265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1772246vqx; Tue, 24 Oct 2023 00:29:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvas28pZT8c4TN3pvbmQiP55Zg7apAfg4fbVpYV4kdrPL1J9TPo+YW0BzX8isZFxHnhhkG X-Received: by 2002:a05:622a:554:b0:419:4d8a:336 with SMTP id m20-20020a05622a055400b004194d8a0336mr14207718qtx.60.1698132579225; Tue, 24 Oct 2023 00:29:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698132579; cv=pass; d=google.com; s=arc-20160816; b=RIcrpyYrr88NAafaBpsz+aelpk011HP1wRX40kLrRP8VFruumVzSN+c8QPGC25ZDrz wrAlR+P3du6DmEZr+SD2wXKjSWcG6poAPck53lB1/cTzzPAvJA5L+QjgLnWleE9UNhx7 UKx0Rx2yfybxEoTjfKLZI46cMSUSb1drzdNRD3eWFJDGdvs/KBLRkVgPgkMXuJgKPVVO /nfU6Hzs8iRLQMsDlMYNtJdQ24gTJw1B7Qjuz9eHCVIDcVMWulUozN2oFgGcZfSpPLp8 JAScEn3/4ZN1UksozKfg/AO6x4SVb0g0cvW3VSu9ULBGJ2nPQdAWKVKbmMqxSwtGtJF4 auNQ== ARC-Message-Signature: i=2; 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:message-id:mime-version:subject :cc:to:from:date:arc-filter:dmarc-filter:delivered-to; bh=fy6Q+1kZAhwvjKLsJ3FFQoYztMR97eEq8FqzW913bzk=; fh=TIHsoBKk8INYK4T4eJyplDBZCwKbkA20oDiZuvC2RHY=; b=fOEWKu52abwV6essdYkXN4ojBAUJf/+qkhP2+MjxHcXlR1ed0CRQ+EbRkT0NYm6fmn j7ruyAna5EbKOmMbi6h6GOCeWyzIbV8BucQ8q0B+Ylcs9T68a91wXvNdduPAYlbOIDBI jOZAI/4WS2AhICFHVIp7lVcK6ETiwQ55bdajBLy0OZS/Yt432T9gaXbt7CTTA2av5w38 2F3MuQ+PD4Z3BJgwAjpKLBi/oy+XMvOLLv5cb+tLmaGJmPXlubOWmYhugXsF5LQd0YbN D4Lixypxd+0+3IVJWmZ53sN8sVb5klFLBQrvFLwIGs/TOdPAyrhEa+6iA94cZ1HGMbC7 pg+Q== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a5-20020a05622a02c500b0041972bc1dd8si6895169qtx.93.2023.10.24.00.29.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 00:29:39 -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; arc=pass (i=1); 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 03ECA3858C35 for ; Tue, 24 Oct 2023 07:29:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [20.231.56.155]) by sourceware.org (Postfix) with ESMTP id DE5C93858CDA for ; Tue, 24 Oct 2023 07:29:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE5C93858CDA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eswincomputing.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DE5C93858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=20.231.56.155 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698132556; cv=none; b=T2tu3YIW87pqlui1BPAytL+a76Ncaby49pjC9Dr5Ovp+fccvLY5Zx5DYkmkAlbVNspmuAQhC3THPP1mQooFp+NyItD5rHqrdNDDZUF2zFxeLsPDWIAf2up2Jh0x1Y10DVhJMoF5gi9PKtQ3cdfZp75jlQvOboQOawPtXYPxwWBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698132556; c=relaxed/simple; bh=KTvAFr8HyEaPD4cNrShieBvqmSYOsB5Ryp+nSUmJR00=; h=Date:From:To:Subject:Mime-Version:Message-ID; b=i9/26InZKksv084QBGj7LFuvdtmGdRVmoRjnNS7U4A0oewT660Pewva0CmHEUmAQCSTeURIJY5JPYq70pqJ5bRK0eVV7yFUc3+64gpsxHyGt2OcHgAIvsSdJp5RfT833P2Ut/5UAewV3Q6wm6bhYboqTYAJ5Rciaq2pHPNH5BE8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from E0002559DT1 (unknown [123.157.234.42]) by app2 (Coremail) with SMTP id TQJkCgD3tEJBcjdl+MMAAA--.6807S2; Tue, 24 Oct 2023 15:29:06 +0800 (CST) Date: Tue, 24 Oct 2023 15:29:09 +0800 From: "Li Xu" To: gcc-patches Cc: kito.cheng , palmer , juzhe.zhong Subject: [PATCH v2] RISC-V: Fix ICE of RVV vget/vset intrinsic[PR111935] X-Priority: 3 X-GUID: 28CDB1A9-5F4B-4FB9-BF44-18850BEE525C X-Has-Attach: no X-Mailer: Foxmail 7.2.23.121[cn] Mime-Version: 1.0 Message-ID: <202310241529094074324@eswincomputing.com> X-CM-TRANSID: TQJkCgD3tEJBcjdl+MMAAA--.6807S2 X-Coremail-Antispam: 1UD129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUOh7k0a2IF6w4kM7kC6x804xWl14x267AK xVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AKwVWUJVWUGw A2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26F1j 6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxV W0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAa Y2xG8wAqx4xG62kEwI0EY4vaYxAvb48xMcIj6xIIjxv20xvE14v26r126r1DMcIj6xkF7I 0En7xvr7AKxVWUJVW8JwAv7VC2z280aVAFwI0_Gr1j6F4UJwAm72CE4IkC6x0Yz7v_Jr0_ Gr1lF7xvr2IYc2Ij64vIr41lFcxC0VAYjxAxZF0Ew4CEw7xC0wACY4xI67k04243AVC20s 07Mx8GjcxK6IxK0xIIj40E5I8CrwCY02Avz4vE14v_GF4l42xK82IYc2Ij64vIr41l4I8I 3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxV WUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAF wI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcI k0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j 6r4UMVCEFcxC0VAYjxAxZFUvcSsGvfC2KfnxnUUI43ZEXa7IU5tsqtUUUUU== X-CM-SenderInfo: 50xoxi46hv4xpqfrz1xxwl0woofrz/ X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HTML_FONT_LOW_CONTRAST, HTML_MESSAGE, KAM_DMARC_STATUS, KAM_SHORT, MIME_BASE64_TEXT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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.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: 1780621067411550365 X-GMAIL-MSGID: 1780621067411550365 Calling vget/vset intrinsic without receiving a return value will cause a crash. Because in this case e.target is null. This patch should be backported to releases/gcc-13. PR/target 111935 gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc: fix bug. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr111935.c: New test. --- .../riscv/riscv-vector-builtins-bases.cc | 4 +++ .../gcc.target/riscv/rvv/base/pr111935.c | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr111935.c -- 2.17.1 xuli1@eswincomputing.com diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.cc b/gcc/config/riscv/riscv-vector-builtins-bases.cc index ab12e130907..0b1409a52e0 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -1740,6 +1740,8 @@ public: rtx expand (function_expander &e) const override { + if (!e.target) + return NULL_RTX; rtx dest = expand_normal (CALL_EXPR_ARG (e.exp, 0)); gcc_assert (riscv_v_ext_vector_mode_p (GET_MODE (dest))); rtx index = expand_normal (CALL_EXPR_ARG (e.exp, 1)); @@ -1777,6 +1779,8 @@ public: rtx expand (function_expander &e) const override { + if (!e.target) + return NULL_RTX; rtx src = expand_normal (CALL_EXPR_ARG (e.exp, 0)); gcc_assert (riscv_v_ext_vector_mode_p (GET_MODE (src))); rtx index = expand_normal (CALL_EXPR_ARG (e.exp, 1)); diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr111935.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr111935.c new file mode 100644 index 00000000000..0b936d849a1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr111935.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O0 -Wno-psabi" } */ + +#include "riscv_vector.h" + +inline vuint32m4_t __attribute__((__always_inline__)) transpose_indexes() { + static const uint32_t idx_[16] = {0, 4, 8, 12, + 1, 5, 9, 13, + 2, 6, 10, 14, + 3, 7, 11, 15}; + return __riscv_vle32_v_u32m4(idx_, 16); +} + +void pffft_real_preprocess_4x4(const float *in) { + vfloat32m1_t r0=__riscv_vle32_v_f32m1(in,4); + vfloat32m4_t tmp = __riscv_vundefined_f32m4(); + tmp = __riscv_vset_v_f32m1_f32m4(tmp, 0, r0); + tmp = __riscv_vset_v_f32m1_f32m4(tmp, 1, r0); + tmp = __riscv_vset_v_f32m1_f32m4(tmp, 2, r0); + tmp = __riscv_vset_v_f32m1_f32m4(tmp, 3, r0); + tmp = __riscv_vrgather_vv_f32m4(tmp, transpose_indexes(), 16); + r0 = __riscv_vget_v_f32m4_f32m1(tmp, 0); +} + +/* { dg-final { scan-assembler-times {vl[0-9]+re[0-9]+\.v\s+v[0-9]+,\s*0\([a-z]+[0-9]+\)} 10 } } */ +/* { dg-final { scan-assembler-times {vs[0-9]+r\.v\s+v[0-9]+,\s*0\([a-z]+[0-9]+\)} 8 } } */