From patchwork Tue Oct 24 06:22:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xu X-Patchwork-Id: 157251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1748158vqx; Mon, 23 Oct 2023 23:23:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFD9agH//x6qXIaPWm8iTYzyGNRVRIXUrxhzxAbury6y1/M6K/Nu2Q800rIqZrwR/Jwe1+c X-Received: by 2002:a05:622a:83:b0:418:110e:6179 with SMTP id o3-20020a05622a008300b00418110e6179mr15123244qtw.1.1698128595902; Mon, 23 Oct 2023 23:23:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698128595; cv=pass; d=google.com; s=arc-20160816; b=tGLy7ggtqlbK0Xcy0bdx+fO3B2ptsvkKVPXWSTqzk76nvRDVJF4Mm+aK2VMurxYQIu nP4E3d4e1BaO0nj/a2KDO7+088AuAq2uDc0yxbDQZE4wnf+8Vrn14B9KgVqKE+YM4CJA BD6K6LlAweIfboqZO4noYoCXdF66qcB7tQPXf/OEJKqf2RcYI5iTD0k7/KQzl3dIWDOB eEXe/CbBPyGDbyUXjwkxRaKGu7cbwzhh/VHN6fdDSlIZlYgPgI0Y8eKnGoGcGV4RzTcf slr4Rrd08E60hCXP2Oia/dgJzLuhsfAySmsrbCLqxdpo3bl1Ng0skDH/QqHcTFKNI1pQ ENew== 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=5CwMBiXmkzIPCGj3ED89415tOgJoCxzoScR87uAoS+I=; fh=TIHsoBKk8INYK4T4eJyplDBZCwKbkA20oDiZuvC2RHY=; b=oPkZUMlYiDkz30vqJkdYnv0gIbmu8s/nlsLnE3a6GU7tTuCaNaEbZRBSoLk7uxGkki epb0Nh7V18wiYjWJPhzOP7Hgp9GibYas9bP0fnZmp3xs+2hM4Y4i8fdcZMEhrTPc7hfA m4zaHcuClj4HV1DschWXgMdmTdb/eTdlhw59lrpo8AJZiGsPXALrwSutqAlDp3UaJYZD NedDSZhAkZ/E633ySN6aOZOTzRrZLM3rPwRJkfAxl7sq4Muv64Dv2lqIzSCd5PQtdX3h nkcD2Ms7+Ta4lcRGxhDvdb7nM5JNSV6zCPcYAXQQZGMWx1Xf2Lw/kcj6qDXCM6LVxUJ1 XUVw== 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 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 e2-20020ac84e42000000b00403dd3f7113si6391963qtw.322.2023.10.23.23.23.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 23:23:15 -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; arc=pass (i=1); 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 A791E385770B for ; Tue, 24 Oct 2023 06:23:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sgoci-sdnproxy-4.icoremail.net (sgoci-sdnproxy-4.icoremail.net [129.150.39.64]) by sourceware.org (Postfix) with ESMTP id EFDA4385840F for ; Tue, 24 Oct 2023 06:22:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFDA4385840F 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 EFDA4385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.150.39.64 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698128570; cv=none; b=BL6Z8hJpPeoV3OQ0IGzL+9wzEpCrumaGYHwphVkxLwnpbjxvOrQ+80dJSFD274uOudheeBe9Z41hyihzFYaVTkhzrFYCPv26Yc3NxPIUkQJ5aWAVx37vmT/JYg0yO/vvZ0Wd3TKKz/GO6GZuXpYle7gtL6d4LhkQjc9TtM1hzZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698128570; c=relaxed/simple; bh=MSdr4PVvbrYCf+NzpMZM5vClyAm2zf6B0kWLKsEpAV8=; h=Date:From:To:Subject:Mime-Version:Message-ID; b=OMhgX42MKVMAyylAt/SQAhnmk9oXY9Fl8W6O07RXwDWUL5gcRma/mbWZP/WWQug9+LymMvD9KDE1B5NCJrm74RNfzn6R0TvIQ4oS5zaI89DnGhAB+Fqbiz6dOdNkfDPasNOpgm8Vrtty5T4CXC8nyJu6VbZzhjoiAOltNU1Csyc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from E0002559DT1 (unknown [123.157.234.42]) by app1 (Coremail) with SMTP id TAJkCgBn2katYjdlNr8AAA--.6944S2; Tue, 24 Oct 2023 14:22:38 +0800 (CST) Date: Tue, 24 Oct 2023 14:22:41 +0800 From: "Li Xu" To: gcc-patches Cc: kito.cheng , palmer , juzhe.zhong Subject: RISC-V: Fix ICE of RVV vget/vset intrinsic[PR111935] X-Priority: 3 X-GUID: 150585BC-5662-457A-9D1D-E0C5CFF18850 X-Has-Attach: no X-Mailer: Foxmail 7.2.23.121[cn] Mime-Version: 1.0 Message-ID: <202310241422412928693@eswincomputing.com> X-CM-TRANSID: TAJkCgBn2katYjdlNr8AAA--.6944S2 X-Coremail-Antispam: 1UD129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUOh7k0a2IF6w4kM7kC6x804xWl14x267AK xVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AKwVWUJVWUGw A2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26F1j 6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxV W0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAa Y2xG8wAqx4xG62kEwI0EY4vaYxAvb48xMcIj6xIIjxv20xvE14v26r1Y6r17McIj6xkF7I 0En7xvr7AKxVWUJVW8JwAv7VC2z280aVAFwI0_Gr1j6F4UJwAm72CE4IkC6x0Yz7v_Jr0_ Gr1lF7xvr2IYc2Ij64vIr41lFcxC0VAYjxAxZF0Ew4CEw7xC0wACY4xI67k04243AVC20s 07Mx8GjcxK6IxK0xIIj40E5I8CrwCY02Avz4vE14v_GF1l42xK82IYc2Ij64vIr41l4I8I 3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxV WUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAF wI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcI k0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j 6r4UMVCEFcxC0VAYjxAxZFUvcSsGvfC2KfnxnUUI43ZEXa7IUY8rcDUUUUU== 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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: 1780616890211450940 X-GMAIL-MSGID: 1780616890211450940 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: Don't use the e.target directly. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/vget_vset.c: New test. --- .../riscv/riscv-vector-builtins-bases.cc | 13 ++-- .../gcc.target/riscv/rvv/base/vget_vset.c | 74 +++++++++++++++++++ 2 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/vget_vset.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..4c9209bec6d 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -1745,11 +1745,12 @@ public: rtx index = expand_normal (CALL_EXPR_ARG (e.exp, 1)); rtx src = expand_normal (CALL_EXPR_ARG (e.exp, 2)); poly_int64 offset = INTVAL (index) * GET_MODE_SIZE (GET_MODE (src)); - emit_move_insn (e.target, dest); - rtx subreg = simplify_gen_subreg (GET_MODE (src), e.target, - GET_MODE (e.target), offset); + rtx ret = gen_reg_rtx (GET_MODE (dest)); + emit_move_insn (ret, dest); + rtx subreg = simplify_gen_subreg (GET_MODE (src), ret, + GET_MODE (ret), offset); emit_move_insn (subreg, src); - return e.target; + return ret; } }; @@ -1780,9 +1781,9 @@ public: 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)); - poly_int64 offset = INTVAL (index) * GET_MODE_SIZE (GET_MODE (e.target)); + poly_int64 offset = INTVAL (index) * GET_MODE_SIZE (e.ret_mode ()); rtx subreg - = simplify_gen_subreg (GET_MODE (e.target), src, GET_MODE (src), offset); + = simplify_gen_subreg (e.ret_mode (), src, GET_MODE (src), offset); return subreg; } }; diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/vget_vset.c b/gcc/testsuite/gcc.target/riscv/rvv/base/vget_vset.c new file mode 100644 index 00000000000..e0d03871a64 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/vget_vset.c @@ -0,0 +1,74 @@ + +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -O0 -Wno-psabi" } */ + +#include "riscv_vector.h" + +typedef _Float16 float16_t; +typedef float float32_t; +typedef double float64_t; + +void test_vget_v_f16m8_f16m1(vfloat16m8_t src, size_t index) { + __riscv_vget_v_f16m8_f16m1(src, 0); +} + +void test_vget_v_f32m4_f32m1(vfloat32m4_t src, size_t index) { + __riscv_vget_v_f32m4_f32m1(src, 0); +} + +void test_vget_v_f64m2_f64m1(vfloat64m2_t src, size_t index) { + __riscv_vget_v_f64m2_f64m1(src, 0); +} + +void test_vget_v_i8m4_i8m1(vint8m4_t src, size_t index) { + __riscv_vget_v_i8m4_i8m1(src, 0); +} + +void test_vget_v_i16m2_i16m1(vint16m2_t src, size_t index) { + __riscv_vget_v_i16m2_i16m1(src, 0); +} + +void test_vget_v_i32m4_i32m1(vint32m4_t src, size_t index) { + __riscv_vget_v_i32m4_i32m1(src, 0); +} + +void test_vget_v_i64m4_i64m1(vint64m4_t src, size_t index) { + __riscv_vget_v_i64m4_i64m1(src, 0); +} + +void test_vset_v_f16m1_f16m4(vfloat16m4_t dest, size_t index, + vfloat16m1_t value) { + __riscv_vset_v_f16m1_f16m4(dest, 0, value); +} + +void test_vset_v_f32m1_f32m2(vfloat32m2_t dest, size_t index, + vfloat32m1_t value) { + __riscv_vset_v_f32m1_f32m2(dest, 0, value); +} + +void test_vset_v_f64m1_f64m4(vfloat64m4_t dest, size_t index, + vfloat64m1_t value) { + __riscv_vset_v_f64m1_f64m4(dest, 0, value); +} + +void test_vset_v_i8m1_i8m4(vint8m4_t dest, size_t index, vint8m1_t value) { + __riscv_vset_v_i8m1_i8m4(dest, 0, value); +} + +void test_vset_v_i16m1_i16m2(vint16m2_t dest, size_t index, + vint16m1_t value) { + __riscv_vset_v_i16m1_i16m2(dest, 0, value); +} + +void test_vset_v_i32m1_i32m4(vint32m4_t dest, size_t index, + vint32m1_t value) { + __riscv_vset_v_i32m1_i32m4(dest, 0, value); +} + +void test_vset_v_i64m1_i64m2(vint64m2_t dest, size_t index, + vint64m1_t value) { + __riscv_vset_v_i64m1_i64m2(dest, 0, value); +} + +/* { dg-final { scan-assembler-times {vl[0-9]+re[0-9]+\.v\s+v[0-9]+,\s*0\([a-z]+[0-9]+\)} 27 } } */ +/* { dg-final { scan-assembler-times {vs[0-9]+r\.v\s+v[0-9]+,\s*0\([a-z]+[0-9]+\)} 21 } } */