From patchwork Tue Aug 8 01:37:09 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: 132477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1816382vqr; Mon, 7 Aug 2023 18:38:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZBlzz0XdCOO3sEbqSpYmi4wx9XgPn8c1sficxK/bCE94vfoPcnpN98ChETBowpZlhiObW X-Received: by 2002:aa7:d4d1:0:b0:523:33df:2022 with SMTP id t17-20020aa7d4d1000000b0052333df2022mr4597617edr.13.1691458685083; Mon, 07 Aug 2023 18:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691458685; cv=none; d=google.com; s=arc-20160816; b=YwgcFy8PRj8Meoj3tEP/jN+O7uNHQWdrcoDKTdvOUSuIjJuc66HbbAJAiEOz1ZE9Jq s8X5zvC/MFrgbrkWsnms4ywCV1j6X9BZphk/LziU70EkKR5XiNTXEw+0j8p27+xcGQ+o YfnkebF2QsWE9S98xEo8GlGPpFZg3pX2xMRrTV7Uv5ZScgbGHkOTfW+9eRUrv26bdUl9 Exduukwhdr40tIps4Ejwd7c1s413kqWWVogIIHxMJiP6/i0pWaJj4b1OXOY/0xvliylY 7BJCGglPN7f3TLyNAQxn0PFDlflOG1VWidEt9q9zV1ZOia2FAq7Cn2Mdj5vdZyKppPyK 3rJA== 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=RepBvhCVIc0rXKjJ/Tfy+v0OH4+BEZSsenUklhKM6pM=; fh=SuV1mxSfYh/fFJBV6FW8ZDQUWC7OLSIDYxyJSOKFLBQ=; b=moo09613mzcPscUotCRaqPHx7zVPb2tPp/Ga3F8HJe+w9A/JQxtNZzof5gWLbEmO/v 1xMy53n4RaJNfuROged5Ojd4BlyTEnXnfJ65nnV+b18C2/cBftVJ9A1mlFLcAbLI2N9m /MVik2HGUGKc2z08phH5OBA6nLMd8jcACKZ7kP/9uyQcz4iJ0v3gw7ZP3t/7StBxGIG4 cOMeOS5rnr/8C0fPcraf4pxlQeMIgPkyaiMZmLFqLZAKPD3ww5yATyLddwKAkxIy7ame u8BB6fPGRsBAe9m2gqTUeXB9MC0jXxwciqyED5vAvRY6IC/Cy0DKeLkmOlU0jvBgoNem lKUw== 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 g10-20020aa7c58a000000b00521ce86bb68si6720574edq.473.2023.08.07.18.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 18:38:05 -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 0EF20385772B for ; Tue, 8 Aug 2023 01:37:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by sourceware.org (Postfix) with ESMTPS id A3CAA3858C41 for ; Tue, 8 Aug 2023 01:37:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3CAA3858C41 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: bizesmtp87t1691458632t9cnn0no Received: from server1.localdomain ( [58.60.1.10]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 08 Aug 2023 09:37:11 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: FnSO6BqblfQH2t5lZylnm9hrSdygZs92Sf2SCBKh4Ilv+oceM/UGSZvuq675Q Q9l3HvXdm5AG5b1xWbafhZWUhE32rhyOnKQxAfXy1dhHJSADyVRPaNHnKGmZaUZciLCsrRz QYh6jCZbaJ7F6h2jVprsXs9046Ki/9/xJFBOZYnWWjvbaLjHUhjIUNugcVHshLC9ffZ3C91 GcgkwKV+/smIAKfRZaN3UUTlXQsA6q+7ooKSsIqIdWn+o5cXog82FU1385Qikc2J2qdzNzb HnNaFqIg6ex/atEapTOwhkFzatv1SN59W3QjeTO0Plcx/2qcYKTJcQWm46peUvwZ3zxCNuB YEf1RJMAUryOGBPNc2t48iK2mRtZXuMAAr6GTnvkF7394FcFMBpfNh2ZxI4Kg== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 190845515638275473 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: Support VLS shift vectorization Date: Tue, 8 Aug 2023 09:37:09 +0800 Message-Id: <20230808013709.168452-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, 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: 1773622982404748790 X-GMAIL-MSGID: 1773622982404748790 After this patch, this following case will be well optimized: #include "riscv_vector.h" #define DEF_OP_VV(PREFIX, NUM, TYPE, OP) \ void __attribute__ ((noinline, noclone)) \ PREFIX##_##TYPE##NUM (TYPE *restrict a, TYPE *restrict b, TYPE *restrict c) \ { \ for (int i = 0; i < NUM; ++i) \ a[i] = b[i] OP c[i]; \ } DEF_OP_VV (shift, 16, int32_t, >>) ASM: shift_int32_t16: vsetivli zero,16,e32,mf2,ta,ma vle32.v v1,0(a1) vle32.v v2,0(a2) vsra.vv v1,v1,v2 vse32.v v1,0(a0) ret gcc/ChangeLog: * config/riscv/autovec.md: Add VLS shift. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS shift. * gcc.target/riscv/rvv/autovec/vls/shift-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-2.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-3.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-4.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-5.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-6.c: New test. --- gcc/config/riscv/autovec.md | 14 ++--- .../gcc.target/riscv/rvv/autovec/vls/def.h | 8 +++ .../riscv/rvv/autovec/vls/shift-1.c | 57 ++++++++++++++++++ .../riscv/rvv/autovec/vls/shift-2.c | 57 ++++++++++++++++++ .../riscv/rvv/autovec/vls/shift-3.c | 58 +++++++++++++++++++ .../riscv/rvv/autovec/vls/shift-4.c | 57 ++++++++++++++++++ .../riscv/rvv/autovec/vls/shift-5.c | 57 ++++++++++++++++++ .../riscv/rvv/autovec/vls/shift-6.c | 57 ++++++++++++++++++ 8 files changed, 358 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-3.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-5.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-6.c diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index 5e97ccba3b3..6cb5fa3ed27 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -400,9 +400,9 @@ ;; ------------------------------------------------------------------------- (define_insn_and_split "3" - [(set (match_operand:VI 0 "register_operand" "=vr") - (any_shift:VI - (match_operand:VI 1 "register_operand" " vr") + [(set (match_operand:V_VLSI 0 "register_operand" "=vr") + (any_shift:V_VLSI + (match_operand:V_VLSI 1 "register_operand" " vr") (match_operand: 2 "csr_operand" " rK")))] "TARGET_VECTOR && can_create_pseudo_p ()" "#" @@ -425,10 +425,10 @@ ;; ------------------------------------------------------------------------- (define_insn_and_split "v3" - [(set (match_operand:VI 0 "register_operand" "=vr,vr") - (any_shift:VI - (match_operand:VI 1 "register_operand" " vr,vr") - (match_operand:VI 2 "vector_shift_operand" " vr,vk")))] + [(set (match_operand:V_VLSI 0 "register_operand" "=vr,vr") + (any_shift:V_VLSI + (match_operand:V_VLSI 1 "register_operand" " vr,vr") + (match_operand:V_VLSI 2 "vector_shift_operand" " vr,vk")))] "TARGET_VECTOR && can_create_pseudo_p ()" "#" "&& 1" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/def.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/def.h index 2ef84be3b63..33916ff0698 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/def.h +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/def.h @@ -134,3 +134,11 @@ typedef double v512df __attribute__ ((vector_size (4096))); for (int i = 0; i < NUM; ++i) \ a[i] = b[i] OP c[i] ? b[i] : c[i]; \ } + +#define DEF_OP_VI_7(PREFIX, NUM, TYPE, OP) \ + void __attribute__ ((noinline, noclone)) \ + PREFIX##_##TYPE##NUM (TYPE *restrict a, TYPE *restrict b, TYPE *restrict c) \ + { \ + for (int i = 0; i < NUM; ++i) \ + a[i] = b[i] OP 7; \ + } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-1.c new file mode 100644 index 00000000000..e57a0b6bdf3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-1.c @@ -0,0 +1,57 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 -fno-schedule-insns -fno-schedule-insns2 --param=riscv-autovec-lmul=m8" } */ + +#include "def.h" + +DEF_OP_VV (shift, 1, int8_t, >>) +DEF_OP_VV (shift, 2, int8_t, >>) +DEF_OP_VV (shift, 4, int8_t, >>) +DEF_OP_VV (shift, 8, int8_t, >>) +DEF_OP_VV (shift, 16, int8_t, >>) +DEF_OP_VV (shift, 32, int8_t, >>) +DEF_OP_VV (shift, 64, int8_t, >>) +DEF_OP_VV (shift, 128, int8_t, >>) +DEF_OP_VV (shift, 256, int8_t, >>) +DEF_OP_VV (shift, 512, int8_t, >>) +DEF_OP_VV (shift, 1024, int8_t, >>) +DEF_OP_VV (shift, 2048, int8_t, >>) +DEF_OP_VV (shift, 4096, int8_t, >>) + +DEF_OP_VV (shift, 1, int16_t, >>) +DEF_OP_VV (shift, 2, int16_t, >>) +DEF_OP_VV (shift, 4, int16_t, >>) +DEF_OP_VV (shift, 8, int16_t, >>) +DEF_OP_VV (shift, 16, int16_t, >>) +DEF_OP_VV (shift, 32, int16_t, >>) +DEF_OP_VV (shift, 64, int16_t, >>) +DEF_OP_VV (shift, 128, int16_t, >>) +DEF_OP_VV (shift, 256, int16_t, >>) +DEF_OP_VV (shift, 512, int16_t, >>) +DEF_OP_VV (shift, 1024, int16_t, >>) +DEF_OP_VV (shift, 2048, int16_t, >>) + +DEF_OP_VV (shift, 1, int32_t, >>) +DEF_OP_VV (shift, 2, int32_t, >>) +DEF_OP_VV (shift, 4, int32_t, >>) +DEF_OP_VV (shift, 8, int32_t, >>) +DEF_OP_VV (shift, 16, int32_t, >>) +DEF_OP_VV (shift, 32, int32_t, >>) +DEF_OP_VV (shift, 64, int32_t, >>) +DEF_OP_VV (shift, 128, int32_t, >>) +DEF_OP_VV (shift, 256, int32_t, >>) +DEF_OP_VV (shift, 512, int32_t, >>) +DEF_OP_VV (shift, 1024, int32_t, >>) + +DEF_OP_VV (shift, 1, int64_t, >>) +DEF_OP_VV (shift, 2, int64_t, >>) +DEF_OP_VV (shift, 4, int64_t, >>) +DEF_OP_VV (shift, 8, int64_t, >>) +DEF_OP_VV (shift, 16, int64_t, >>) +DEF_OP_VV (shift, 32, int64_t, >>) +DEF_OP_VV (shift, 64, int64_t, >>) +DEF_OP_VV (shift, 128, int64_t, >>) +DEF_OP_VV (shift, 256, int64_t, >>) +DEF_OP_VV (shift, 512, int64_t, >>) + +/* { dg-final { scan-assembler-times {vsra\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 39 } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-2.c new file mode 100644 index 00000000000..9d1fa64232c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-2.c @@ -0,0 +1,57 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 -fno-schedule-insns -fno-schedule-insns2 --param=riscv-autovec-lmul=m8" } */ + +#include "def.h" + +DEF_OP_VV (shift, 1, uint8_t, >>) +DEF_OP_VV (shift, 2, uint8_t, >>) +DEF_OP_VV (shift, 4, uint8_t, >>) +DEF_OP_VV (shift, 8, uint8_t, >>) +DEF_OP_VV (shift, 16, uint8_t, >>) +DEF_OP_VV (shift, 32, uint8_t, >>) +DEF_OP_VV (shift, 64, uint8_t, >>) +DEF_OP_VV (shift, 128, uint8_t, >>) +DEF_OP_VV (shift, 256, uint8_t, >>) +DEF_OP_VV (shift, 512, uint8_t, >>) +DEF_OP_VV (shift, 1024, uint8_t, >>) +DEF_OP_VV (shift, 2048, uint8_t, >>) +DEF_OP_VV (shift, 4096, uint8_t, >>) + +DEF_OP_VV (shift, 1, uint16_t, >>) +DEF_OP_VV (shift, 2, uint16_t, >>) +DEF_OP_VV (shift, 4, uint16_t, >>) +DEF_OP_VV (shift, 8, uint16_t, >>) +DEF_OP_VV (shift, 16, uint16_t, >>) +DEF_OP_VV (shift, 32, uint16_t, >>) +DEF_OP_VV (shift, 64, uint16_t, >>) +DEF_OP_VV (shift, 128, uint16_t, >>) +DEF_OP_VV (shift, 256, uint16_t, >>) +DEF_OP_VV (shift, 512, uint16_t, >>) +DEF_OP_VV (shift, 1024, uint16_t, >>) +DEF_OP_VV (shift, 2048, uint16_t, >>) + +DEF_OP_VV (shift, 1, uint32_t, >>) +DEF_OP_VV (shift, 2, uint32_t, >>) +DEF_OP_VV (shift, 4, uint32_t, >>) +DEF_OP_VV (shift, 8, uint32_t, >>) +DEF_OP_VV (shift, 16, uint32_t, >>) +DEF_OP_VV (shift, 32, uint32_t, >>) +DEF_OP_VV (shift, 64, uint32_t, >>) +DEF_OP_VV (shift, 128, uint32_t, >>) +DEF_OP_VV (shift, 256, uint32_t, >>) +DEF_OP_VV (shift, 512, uint32_t, >>) +DEF_OP_VV (shift, 1024, uint32_t, >>) + +DEF_OP_VV (shift, 1, uint64_t, >>) +DEF_OP_VV (shift, 2, uint64_t, >>) +DEF_OP_VV (shift, 4, uint64_t, >>) +DEF_OP_VV (shift, 8, uint64_t, >>) +DEF_OP_VV (shift, 16, uint64_t, >>) +DEF_OP_VV (shift, 32, uint64_t, >>) +DEF_OP_VV (shift, 64, uint64_t, >>) +DEF_OP_VV (shift, 128, uint64_t, >>) +DEF_OP_VV (shift, 256, uint64_t, >>) +DEF_OP_VV (shift, 512, uint64_t, >>) + +/* { dg-final { scan-assembler-times {vsrl\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 39 } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-3.c new file mode 100644 index 00000000000..98822b15657 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-3.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 -fno-schedule-insns -fno-schedule-insns2 --param=riscv-autovec-lmul=m8" } */ + +#include "def.h" + +DEF_OP_VV (shift, 1, int8_t, <<) +DEF_OP_VV (shift, 2, int8_t, <<) +DEF_OP_VV (shift, 4, int8_t, <<) +DEF_OP_VV (shift, 8, int8_t, <<) +DEF_OP_VV (shift, 16, int8_t, <<) +DEF_OP_VV (shift, 32, int8_t, <<) +DEF_OP_VV (shift, 64, int8_t, <<) +DEF_OP_VV (shift, 128, int8_t, <<) +DEF_OP_VV (shift, 256, int8_t, <<) +DEF_OP_VV (shift, 512, int8_t, <<) +DEF_OP_VV (shift, 1024, int8_t, <<) +DEF_OP_VV (shift, 2048, int8_t, <<) +DEF_OP_VV (shift, 4096, int8_t, <<) + +DEF_OP_VV (shift, 1, int16_t, <<) +DEF_OP_VV (shift, 2, int16_t, <<) +DEF_OP_VV (shift, 4, int16_t, <<) +DEF_OP_VV (shift, 8, int16_t, <<) +DEF_OP_VV (shift, 16, int16_t, <<) +DEF_OP_VV (shift, 32, int16_t, <<) +DEF_OP_VV (shift, 64, int16_t, <<) +DEF_OP_VV (shift, 128, int16_t, <<) +DEF_OP_VV (shift, 256, int16_t, <<) +DEF_OP_VV (shift, 512, int16_t, <<) +DEF_OP_VV (shift, 1024, int16_t, <<) +DEF_OP_VV (shift, 2048, int16_t, <<) + +DEF_OP_VV (shift, 1, int32_t, <<) +DEF_OP_VV (shift, 2, int32_t, <<) +DEF_OP_VV (shift, 4, int32_t, <<) +DEF_OP_VV (shift, 8, int32_t, <<) +DEF_OP_VV (shift, 16, int32_t, <<) +DEF_OP_VV (shift, 32, int32_t, <<) +DEF_OP_VV (shift, 64, int32_t, <<) +DEF_OP_VV (shift, 128, int32_t, <<) +DEF_OP_VV (shift, 256, int32_t, <<) +DEF_OP_VV (shift, 512, int32_t, <<) +DEF_OP_VV (shift, 1024, int32_t, <<) + +DEF_OP_VV (shift, 1, int64_t, <<) +DEF_OP_VV (shift, 2, int64_t, <<) +DEF_OP_VV (shift, 4, int64_t, <<) +DEF_OP_VV (shift, 8, int64_t, <<) +DEF_OP_VV (shift, 16, int64_t, <<) +DEF_OP_VV (shift, 32, int64_t, <<) +DEF_OP_VV (shift, 64, int64_t, <<) +DEF_OP_VV (shift, 128, int64_t, <<) +DEF_OP_VV (shift, 256, int64_t, <<) +DEF_OP_VV (shift, 512, int64_t, <<) + +/* { dg-final { scan-assembler-times {vsll\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 41 } } */ +/* TODO: Ideally, we should make sure there is no "csrr vlenb". However, we still have 'csrr vlenb' for some cases since we don't support VLS mode conversion which are needed by division. */ +/* { dg-final { scan-assembler-times {csrr} 18 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-4.c new file mode 100644 index 00000000000..56b6ef92c83 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-4.c @@ -0,0 +1,57 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 -fno-schedule-insns -fno-schedule-insns2 --param=riscv-autovec-lmul=m8" } */ + +#include "def.h" + +DEF_OP_VI_7 (shift, 1, int8_t, >>) +DEF_OP_VI_7 (shift, 2, int8_t, >>) +DEF_OP_VI_7 (shift, 4, int8_t, >>) +DEF_OP_VI_7 (shift, 8, int8_t, >>) +DEF_OP_VI_7 (shift, 16, int8_t, >>) +DEF_OP_VI_7 (shift, 32, int8_t, >>) +DEF_OP_VI_7 (shift, 64, int8_t, >>) +DEF_OP_VI_7 (shift, 128, int8_t, >>) +DEF_OP_VI_7 (shift, 256, int8_t, >>) +DEF_OP_VI_7 (shift, 512, int8_t, >>) +DEF_OP_VI_7 (shift, 1024, int8_t, >>) +DEF_OP_VI_7 (shift, 2048, int8_t, >>) +DEF_OP_VI_7 (shift, 4096, int8_t, >>) + +DEF_OP_VI_7 (shift, 1, int16_t, >>) +DEF_OP_VI_7 (shift, 2, int16_t, >>) +DEF_OP_VI_7 (shift, 4, int16_t, >>) +DEF_OP_VI_7 (shift, 8, int16_t, >>) +DEF_OP_VI_7 (shift, 16, int16_t, >>) +DEF_OP_VI_7 (shift, 32, int16_t, >>) +DEF_OP_VI_7 (shift, 64, int16_t, >>) +DEF_OP_VI_7 (shift, 128, int16_t, >>) +DEF_OP_VI_7 (shift, 256, int16_t, >>) +DEF_OP_VI_7 (shift, 512, int16_t, >>) +DEF_OP_VI_7 (shift, 1024, int16_t, >>) +DEF_OP_VI_7 (shift, 2048, int16_t, >>) + +DEF_OP_VI_7 (shift, 1, int32_t, >>) +DEF_OP_VI_7 (shift, 2, int32_t, >>) +DEF_OP_VI_7 (shift, 4, int32_t, >>) +DEF_OP_VI_7 (shift, 8, int32_t, >>) +DEF_OP_VI_7 (shift, 16, int32_t, >>) +DEF_OP_VI_7 (shift, 32, int32_t, >>) +DEF_OP_VI_7 (shift, 64, int32_t, >>) +DEF_OP_VI_7 (shift, 128, int32_t, >>) +DEF_OP_VI_7 (shift, 256, int32_t, >>) +DEF_OP_VI_7 (shift, 512, int32_t, >>) +DEF_OP_VI_7 (shift, 1024, int32_t, >>) + +DEF_OP_VI_7 (shift, 1, int64_t, >>) +DEF_OP_VI_7 (shift, 2, int64_t, >>) +DEF_OP_VI_7 (shift, 4, int64_t, >>) +DEF_OP_VI_7 (shift, 8, int64_t, >>) +DEF_OP_VI_7 (shift, 16, int64_t, >>) +DEF_OP_VI_7 (shift, 32, int64_t, >>) +DEF_OP_VI_7 (shift, 64, int64_t, >>) +DEF_OP_VI_7 (shift, 128, int64_t, >>) +DEF_OP_VI_7 (shift, 256, int64_t, >>) +DEF_OP_VI_7 (shift, 512, int64_t, >>) + +/* { dg-final { scan-assembler-times {vsra\.vi\s+v[0-9]+,\s*v[0-9]+,\s*7} 42 } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-5.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-5.c new file mode 100644 index 00000000000..c909cb1a75a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-5.c @@ -0,0 +1,57 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 -fno-schedule-insns -fno-schedule-insns2 --param=riscv-autovec-lmul=m8" } */ + +#include "def.h" + +DEF_OP_VI_7 (shift, 1, uint8_t, >>) +DEF_OP_VI_7 (shift, 2, uint8_t, >>) +DEF_OP_VI_7 (shift, 4, uint8_t, >>) +DEF_OP_VI_7 (shift, 8, uint8_t, >>) +DEF_OP_VI_7 (shift, 16, uint8_t, >>) +DEF_OP_VI_7 (shift, 32, uint8_t, >>) +DEF_OP_VI_7 (shift, 64, uint8_t, >>) +DEF_OP_VI_7 (shift, 128, uint8_t, >>) +DEF_OP_VI_7 (shift, 256, uint8_t, >>) +DEF_OP_VI_7 (shift, 512, uint8_t, >>) +DEF_OP_VI_7 (shift, 1024, uint8_t, >>) +DEF_OP_VI_7 (shift, 2048, uint8_t, >>) +DEF_OP_VI_7 (shift, 4096, uint8_t, >>) + +DEF_OP_VI_7 (shift, 1, uint16_t, >>) +DEF_OP_VI_7 (shift, 2, uint16_t, >>) +DEF_OP_VI_7 (shift, 4, uint16_t, >>) +DEF_OP_VI_7 (shift, 8, uint16_t, >>) +DEF_OP_VI_7 (shift, 16, uint16_t, >>) +DEF_OP_VI_7 (shift, 32, uint16_t, >>) +DEF_OP_VI_7 (shift, 64, uint16_t, >>) +DEF_OP_VI_7 (shift, 128, uint16_t, >>) +DEF_OP_VI_7 (shift, 256, uint16_t, >>) +DEF_OP_VI_7 (shift, 512, uint16_t, >>) +DEF_OP_VI_7 (shift, 1024, uint16_t, >>) +DEF_OP_VI_7 (shift, 2048, uint16_t, >>) + +DEF_OP_VI_7 (shift, 1, uint32_t, >>) +DEF_OP_VI_7 (shift, 2, uint32_t, >>) +DEF_OP_VI_7 (shift, 4, uint32_t, >>) +DEF_OP_VI_7 (shift, 8, uint32_t, >>) +DEF_OP_VI_7 (shift, 16, uint32_t, >>) +DEF_OP_VI_7 (shift, 32, uint32_t, >>) +DEF_OP_VI_7 (shift, 64, uint32_t, >>) +DEF_OP_VI_7 (shift, 128, uint32_t, >>) +DEF_OP_VI_7 (shift, 256, uint32_t, >>) +DEF_OP_VI_7 (shift, 512, uint32_t, >>) +DEF_OP_VI_7 (shift, 1024, uint32_t, >>) + +DEF_OP_VI_7 (shift, 1, uint64_t, >>) +DEF_OP_VI_7 (shift, 2, uint64_t, >>) +DEF_OP_VI_7 (shift, 4, uint64_t, >>) +DEF_OP_VI_7 (shift, 8, uint64_t, >>) +DEF_OP_VI_7 (shift, 16, uint64_t, >>) +DEF_OP_VI_7 (shift, 32, uint64_t, >>) +DEF_OP_VI_7 (shift, 64, uint64_t, >>) +DEF_OP_VI_7 (shift, 128, uint64_t, >>) +DEF_OP_VI_7 (shift, 256, uint64_t, >>) +DEF_OP_VI_7 (shift, 512, uint64_t, >>) + +/* { dg-final { scan-assembler-times {vsrl\.vi\s+v[0-9]+,\s*v[0-9]+,\s*7} 42 } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-6.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-6.c new file mode 100644 index 00000000000..fdea84c39d8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/shift-6.c @@ -0,0 +1,57 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 -fno-schedule-insns -fno-schedule-insns2 --param=riscv-autovec-lmul=m8" } */ + +#include "def.h" + +DEF_OP_VI_7 (shift, 1, int8_t, <<) +DEF_OP_VI_7 (shift, 2, int8_t, <<) +DEF_OP_VI_7 (shift, 4, int8_t, <<) +DEF_OP_VI_7 (shift, 8, int8_t, <<) +DEF_OP_VI_7 (shift, 16, int8_t, <<) +DEF_OP_VI_7 (shift, 32, int8_t, <<) +DEF_OP_VI_7 (shift, 64, int8_t, <<) +DEF_OP_VI_7 (shift, 128, int8_t, <<) +DEF_OP_VI_7 (shift, 256, int8_t, <<) +DEF_OP_VI_7 (shift, 512, int8_t, <<) +DEF_OP_VI_7 (shift, 1024, int8_t, <<) +DEF_OP_VI_7 (shift, 2048, int8_t, <<) +DEF_OP_VI_7 (shift, 4096, int8_t, <<) + +DEF_OP_VI_7 (shift, 1, int16_t, <<) +DEF_OP_VI_7 (shift, 2, int16_t, <<) +DEF_OP_VI_7 (shift, 4, int16_t, <<) +DEF_OP_VI_7 (shift, 8, int16_t, <<) +DEF_OP_VI_7 (shift, 16, int16_t, <<) +DEF_OP_VI_7 (shift, 32, int16_t, <<) +DEF_OP_VI_7 (shift, 64, int16_t, <<) +DEF_OP_VI_7 (shift, 128, int16_t, <<) +DEF_OP_VI_7 (shift, 256, int16_t, <<) +DEF_OP_VI_7 (shift, 512, int16_t, <<) +DEF_OP_VI_7 (shift, 1024, int16_t, <<) +DEF_OP_VI_7 (shift, 2048, int16_t, <<) + +DEF_OP_VI_7 (shift, 1, int32_t, <<) +DEF_OP_VI_7 (shift, 2, int32_t, <<) +DEF_OP_VI_7 (shift, 4, int32_t, <<) +DEF_OP_VI_7 (shift, 8, int32_t, <<) +DEF_OP_VI_7 (shift, 16, int32_t, <<) +DEF_OP_VI_7 (shift, 32, int32_t, <<) +DEF_OP_VI_7 (shift, 64, int32_t, <<) +DEF_OP_VI_7 (shift, 128, int32_t, <<) +DEF_OP_VI_7 (shift, 256, int32_t, <<) +DEF_OP_VI_7 (shift, 512, int32_t, <<) +DEF_OP_VI_7 (shift, 1024, int32_t, <<) + +DEF_OP_VI_7 (shift, 1, int64_t, <<) +DEF_OP_VI_7 (shift, 2, int64_t, <<) +DEF_OP_VI_7 (shift, 4, int64_t, <<) +DEF_OP_VI_7 (shift, 8, int64_t, <<) +DEF_OP_VI_7 (shift, 16, int64_t, <<) +DEF_OP_VI_7 (shift, 32, int64_t, <<) +DEF_OP_VI_7 (shift, 64, int64_t, <<) +DEF_OP_VI_7 (shift, 128, int64_t, <<) +DEF_OP_VI_7 (shift, 256, int64_t, <<) +DEF_OP_VI_7 (shift, 512, int64_t, <<) + +/* { dg-final { scan-assembler-times {vsll\.vi\s+v[0-9]+,\s*v[0-9]+,\s*7} 42 } } */ +/* { dg-final { scan-assembler-not {csrr} } } */