From patchwork Mon Dec 18 01:03:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xu X-Patchwork-Id: 1877167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SthT34B4Cz23ym for ; Mon, 18 Dec 2023 12:05:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64E5938582AD for ; Mon, 18 Dec 2023 01:05:16 +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 F25963858C35 for ; Mon, 18 Dec 2023 01:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F25963858C35 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 F25963858C35 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=1702861499; cv=none; b=Sy/S0k8VRkmJZw4qQRWZ+E9nBWj8Mfmwba4+r7s90tLM7c3gcf4p1gqiJwmR2ZGjmi3JgK3Q1DnQhXoefS/dQq0W5bGU975SpNCWzz8d7MoKenkIONov8VEbSdShjzntKgqzDPrI0LfUCDgREc1KSFWDsqwjNfJJuOwt4U9vh7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702861499; c=relaxed/simple; bh=pRn1mMCh0MiKcshJrEmBW6p5tDrWwNgGJfQujXY8itg=; h=From:To:Subject:Date:Message-Id; b=xaehZU+co/Jz42KdyTS0ZREr0yLLmIBRoqeBkOfXktwfPIJClufXNEavtcfXLBmlsSxu+P48lOUCQjpJwFfKS+SSqsaFQANpd/02V1+F3Itc7LTbVSldfl5K7CMkVnxAu7MbTzDSdSI5NFF4ClYfNVQ5klHGRhsnOGkeUz4Qusw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from host014-ubuntu-1804.lxd (unknown [10.12.130.31]) by app1 (Coremail) with SMTP id TAJkCgC3Qv1cmn9lrdoBAA--.19196S4; Mon, 18 Dec 2023 09:03:25 +0800 (CST) From: Li Xu To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, juzhe.zhong@rivai.ai Subject: [PATCH] RISC-V: Add viota missed avl_type attribute Date: Mon, 18 Dec 2023 01:03:48 +0000 Message-Id: <20231218010348.5529-1-xuli1@eswincomputing.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: TAJkCgC3Qv1cmn9lrdoBAA--.19196S4 X-Coremail-Antispam: 1UD129KBjvJXoWxAw1UCr45JF4ftr4UuFykKrg_yoW5KFy7pa 95t3WjyFWjyF1xWFsrtFsxWwn8GrWrJry7C397Wr9FqryUJF97ZFy5tF1xXFWxWa4FqayY vay3Cr45CF4kt37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkjb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE-syl42xK82IY c2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s 026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF 0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0x vE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv 6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07bOoGdUUUUU= X-CM-SenderInfo: 50xoxi46hv4xpqfrz1xxwl0woofrz/ X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Juzhe-Zhong This patch fixes the following FAIL when LMUL = 8: riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medany/--param=riscv-autovec-lmul=m8/--param=riscv-autovec-preference=scalable FAIL: gcc.dg/vect/slp-multitypes-2.c execution test The rootcause is we missed viota avl_type, so we end up with incorrect vsetvl configuration: vsetvli zero,a2,e64,m8,ta,ma viota.m v16,v0 'a2' value is a garbage value. After this patch: vsetvli a4,zero,e64,m8,ta,ma viota.m v16,v0 gcc/ChangeLog: * config/riscv/vector.md: Add viota avl_type attribute. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/bug-2.c: New test. --- gcc/config/riscv/vector.md | 2 +- .../gcc.target/riscv/rvv/autovec/bug-2.c | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/bug-2.c diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index a1284fd3251..7646615b12a 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -831,7 +831,7 @@ vfsqrt,vfrecp,vfmerge,vfcvtitof,vfcvtftoi,vfwcvtitof,\ vfwcvtftoi,vfwcvtftof,vfncvtitof,vfncvtftoi,vfncvtftof,\ vfclass,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,\ - vimovxv,vfmovfv,vlsegde,vlsegdff") + vimovxv,vfmovfv,vlsegde,vlsegdff,vmiota") (const_int 7) (eq_attr "type" "vldm,vstm,vmalu,vmalu") (const_int 5) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/bug-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/bug-2.c new file mode 100644 index 00000000000..9ff93d3b163 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/bug-2.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +/* { dg-require-effective-target riscv_v } */ +/* { dg-options "--param=riscv-autovec-lmul=m8 --param=riscv-autovec-preference=scalable -ftree-vectorize -fno-tree-loop-distribute-patterns -fno-vect-cost-model -fno-common -O2" } */ + +#define N 128 + +__attribute__ ((noinline)) int +main1 (unsigned short a0, unsigned short a1, unsigned short a2, + unsigned short a3, unsigned short a4, unsigned short a5, + unsigned short a6, unsigned short a7, unsigned short a8, + unsigned short a9, unsigned short a10, unsigned short a11, + unsigned short a12, unsigned short a13, unsigned short a14, + unsigned short a15, unsigned char b0, unsigned char b1) +{ + int i; + unsigned short out[N*16]; + unsigned char out2[N*16]; + + for (i = 0; i < N; i++) + { + out[i*16] = a8; + out[i*16 + 1] = a7; + out[i*16 + 2] = a1; + out[i*16 + 3] = a2; + out[i*16 + 4] = a8; + out[i*16 + 5] = a5; + out[i*16 + 6] = a5; + out[i*16 + 7] = a4; + out[i*16 + 8] = a12; + out[i*16 + 9] = a13; + out[i*16 + 10] = a14; + out[i*16 + 11] = a15; + out[i*16 + 12] = a6; + out[i*16 + 13] = a9; + out[i*16 + 14] = a0; + out[i*16 + 15] = a7; + + out2[i*2] = b1; + out2[i*2+1] = b0; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*16] != a8 + || out[i*16 + 1] != a7 + || out[i*16 + 2] != a1 + || out[i*16 + 3] != a2 + || out[i*16 + 4] != a8 + || out[i*16 + 5] != a5 + || out[i*16 + 6] != a5 + || out[i*16 + 7] != a4 + || out[i*16 + 8] != a12 + || out[i*16 + 9] != a13 + || out[i*16 + 10] != a14 + || out[i*16 + 11] != a15 + || out[i*16 + 12] != a6 + || out[i*16 + 13] != a9 + || out[i*16 + 14] != a0 + || out[i*16 + 15] != a7 + || out2[i*2] != b1 + || out2[i*2 + 1] != b0) + __builtin_abort (); + } + + return 0; +} + +int main (void) +{ + main1 (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,20,21); + + return 0; +}